Skip to content

Commit

Permalink
v0.9.1
Browse files Browse the repository at this point in the history
From NEWS.md file:

* added descriptions of validation results and details to validate() function
* added version info to package and to xml exports
* added warning to enter_new_metadata() if format = TRUE as it sometimes leads to corrupt files. using format = FALSE fixes this, but the file still contains the example data.

Merge branch 'dev'

# Conflicts:
#	DESCRIPTION
#	Makefile
#	NEWS.md
#	R/updateFromNewSheet.R
#	docs/description_emescheme.html
#	docs/index.html
#	docs/r_package_introduction.html
#	docs/user_manual.html
#	source/index.Rmd
#	vignettes/description_emescheme.Rmd
#	vignettes/user_manual.Rmd
  • Loading branch information
rkrug committed Apr 10, 2019
2 parents e4db30c + 3e0c9eb commit cea7a3e
Show file tree
Hide file tree
Showing 74 changed files with 3,082 additions and 997 deletions.
1 change: 1 addition & 0 deletions .covrignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
R/updateFromNewSheet.R
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
inst/doc
doc
Meta
/doc
Expand Down
41 changes: 19 additions & 22 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
Package: emeScheme
Title: Microcosm experiment metadata scheme
Version: 0.9
Date: 2019-04-01
Authors@R: c( person( "Rainer M.", "Krug", role = c("aut", "cre"),
email = "Rainer.Krug@uzh.ch" ), person( "Owen L.", "Petchey",
role = c("ctb"), email = "Owen.Petchey@uzh.ch" ),
person("Vanessa W.", "de Melo", role = c("ctb"), email =
"Vanessa Weber de Melo <vanessa.weberdemelo@uzh.ch>" ),
person("Frank", "Pennekamp", role = c("ctb"), email = "Frank
Pennekamp <frank.pennekamp@uzh.ch>") )
Description: This package provides and describes the Authoratative
definition of th emeScheme (Experimental Microcosm Ecology
Metadata). ---- Data imported and version bumped at Tue Mar 19
12:00:41 2019 / Europe/Zurich.
Title: Microcosm Experiment Metadata Scheme
Description: The Authoratative definition of the emeScheme (Experimental Microcosm Ecology Metadata) and tools to enter, validate and export the metadata.
---- Data updated and version bumped at Wed Apr 10 08:53:29 2019 / Europe/Zurich. ---- Data updated and version bumped at Wed Apr 10
10:51:12 2019 / Europe/Zurich.
Version: 0.9.1
emeSchemeVersion: 0.9.5
Date: 2019-04-10
Authors@R: c( person( "Rainer M.", "Krug", role = c("aut", "cre"), email = "Rainer.Krug@uzh.ch" ), person( "Owen L.", "Petchey", role = c("ctb"), email =
"Owen.Petchey@uzh.ch" ), person("Vanessa W.", "de Melo", role = c("ctb"), email = "Vanessa Weber de Melo <vanessa.weberdemelo@uzh.ch>" ),
person("Frank", "Pennekamp", role = c("ctb"), email = "Frank Pennekamp <frank.pennekamp@uzh.ch>") )
URL: https://exp-micro-ecol-hub.github.io/emeScheme/, https://github.com/Exp-Micro-Ecol-Hub/emeScheme
BugReports: https://github.com/Exp-Micro-Ecol-Hub/emeScheme/issues
DOI: https://zenodo.org/record/2620097
Depends: R (>= 3.3.0)
Imports: tools, methods, utils, magrittr (>= 1.5), dplyr (>= 0.1.8),
tibble (>= 2.1.1), readxl (>= 1.2.0), openxlsx (>= 4.1.1), XML
(>= 3.98-1.16), rlang (>= 0.3.1), taxize (>= 0.9.5), rmarkdown,
knitr, digest (>= 0.6)
Imports: tools, methods, utils, magrittr (>= 1.5), dplyr (>= 0.1.8), tibble (>= 2.1.1), readxl (>= 1.2.0), openxlsx (>= 4.1.1), XML (>= 3.98-1.16), rlang (>=
0.3.1), taxize (>= 0.9.5), rmarkdown, knitr, digest (>= 0.6)
Remotes: awalker89/openxlsx, rkrug/plantuml
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
StagedInstall: true
RoxygenNote: 6.1.1
Suggests: covr (>= 3.2.1), testthat (>= 2.0.1), googlesheets (>=
0.3.0), here (>= 0.1), kableExtra (>= 0.9.0), plantuml (>=
0.2.3.2)
GSUpdate: 2019-03-18 13:39:12
Suggests: covr (>= 3.2.1), testthat (>= 2.0.1), here (>= 0.1), kableExtra (>= 0.9.0)
Enhances: plantuml (>= 0.2.3.2)
emeSchemeUpdate: 2019-04-10 10:51:12
emeSchemeMD5: 7115b9352958a51fcb60e484a8b9754d
VignetteBuilder: knitr
44 changes: 16 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## R parts based on https://github.com/yihui/knitr/blob/master/Makefile

PKGNAME := $(shell sed -n "s/Package: *\([^ ]*\)/\1/p" DESCRIPTION)
PKGVERS := $(shell sed -n "s/Version: *\([^ ]*\)/\1/p" DESCRIPTION)
PKGNAME := $(shell sed -n "s/^Package: *\([^ ]*\)/\1/p" DESCRIPTION)
PKGVERS := $(shell sed -n "s/^Version: *\([^ ]*\)/\1/p" DESCRIPTION)
PKGSRC := $(shell basename `pwd`)


Expand Down Expand Up @@ -132,38 +132,26 @@ test:

####

############# mHelp targets #############
############# Help targets #############

list_files:
@echo PKGNAME : $(PKGNAME)
@echo PKGVERS : $(PKGVERS)
@echo PKGSRC : $(PKGSRC)
list_variables:
@echo
@echo SRCDIR : $(SRCDIR)
@echo OUTDIR : $(OUTDIR)
@echo DATADIR : $(DATADIR)
@echo
@echo VIGDIR : $(VIGDIR)
@echo VIGHTMLDIR : $(VIGHTMLDIR)
@echo
@echo READMERMD : $(READMERMD)
@echo READMEMD : $(READMEMD)
@echo
@echo VIGRMD : $(VIGRMD)
@echo TMP1 : $(TMP1)
@echo VIGHTML : $(VIGHTML)
@echo VIGHTMLOUT : $(VIGHTMLOUT)
@echo
@echo RMD : $(RMD)
@echo TMP2 : $(TMP2)
@echo HTML : $(HTML)
@echo
@echo EXAMPLEXML : $(EXAMPLEXML)
@echo "#############################################"
@echo "## Variables ################################"
make -pn | grep -A1 "^# makefile"| grep -v "^#\|^--" | sort | uniq
@echo "#############################################"
@echo ""

## from https://stackoverflow.com/a/26339924/632423
list: list_files
list_targets:
@echo
@echo "#############################################"
@echo "## Targets ###############################"
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
@echo "#############################################"
@echo

list: list_variables list_targets

#############

Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ S3method(print,emeScheme_validation)
export(as.plantuml.emeSchemeData)
export(as.plantuml.emeSchemeSet)
export(emeSchemeToXml)
export(emeSchemeVersions)
export(emeScheme_extract)
export(emeScheme_split)
export(enter_new_metadata)
Expand All @@ -36,6 +37,7 @@ importFrom(knitr,purl)
importFrom(magrittr,"%<>%")
importFrom(magrittr,"%>%")
importFrom(magrittr,equals)
importFrom(magrittr,extract)
importFrom(magrittr,extract2)
importFrom(magrittr,not)
importFrom(magrittr,set_names)
Expand All @@ -51,7 +53,9 @@ importFrom(tibble,is_tibble)
importFrom(tibble,tibble)
importFrom(tools,file_ext)
importFrom(tools,file_path_sans_ext)
importFrom(tools,md5sum)
importFrom(utils,RShowDoc)
importFrom(utils,URLencode)
importFrom(utils,browseURL)
importFrom(utils,packageDescription)
importFrom(utils,read.csv)
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# release 0.9.1
**emeScheme version 0.9.5**
* added descriptions of validation results and details to validate() function
* added version info to package and to xml exports
* added warning to enter_new_metadata() if format = TRUE as it sometimes leads to corrupt files. using format = FALSE fixes this, but the file still contains the example data.

# release 0.9
This should finalise the spreadsheet

Expand Down
1 change: 0 additions & 1 deletion R/data.emeScheme_example.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#' emeScheme_example as imported from the Google sheet.
#'
#' The dataset contains example data. It was created by using the code below.
#' @source \url{https://docs.google.com/spreadsheets/d/1OAyRM1jGL5Vho-YfPffePhwGpQtaBUeTPJV6P98f0Bc}
#'
#' @examples
#' \dontrun{
Expand Down
3 changes: 1 addition & 2 deletions R/data.emeScheme_raw.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#' emeScheme_raw as imported from the Google sheet.
#'
#' The dataset contains raw data. It was created by using the code below.
#' @source \url{https://docs.google.com/spreadsheets/d/1OAyRM1jGL5Vho-YfPffePhwGpQtaBUeTPJV6P98f0Bc}
#'
#' @examples
#' \dontrun{
#' ## Created by using
#' path <- system.fil;e( "googlesheet", "emeScheme.xlsx", package = "emeScheme")
#' path <- system.fil;e( "emeScheme.xlsx", package = "emeScheme")
#' emeScheme_raw <- read_from_excel(
#' file = path,
#' keepData = FALSE,
Expand Down
11 changes: 9 additions & 2 deletions R/emeSchemeToXml.emeSchemeSet.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,16 @@ emeSchemeToXml.emeSchemeSet <- function(

## x is of type emeSchemeSet and contains therefore child nodes -------------------------

xml <- XML::xmlNode(tag)
xml <- XML::xmlNode("emeSchemeVersion", attrs = attr(x, "emeSchemeVersion"))

# Add attributes if output == complete ------------------------------------
# Add emeSchemeVersion ----------------------------------------------------

xml <- XML::append.xmlNode(
xml,
XML::xmlNode(tag)
)

# Add attributes if output == complete ------------------------------------

if (output == "complete") {
XML::xmlAttrs(
Expand Down
36 changes: 36 additions & 0 deletions R/emeSchemeVersions.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#' Returns versions of package and emeScheme
#'
#' @param lib.loc a character vector of directory names of R libraries, or NULL.
#' The default value of NULL corresponds to all libraries currently known. If
#' the default is used, the loaded packages and namespaces are searched before
#' the libraries.
#'
#' @return a named \code{list()}, containing the following objects:
#' \itemize{
#' \item{package}{ containing an object of length on of type \code{package_version} with the version of the package}
#' \item{emeScheme}{ containing an object of length on of type \code{numeric_version} with the version of the metadata scheme emeScheme}
#' }
#'
#' @importFrom utils packageDescription
#' @export
#'
#' @examples
#' emeSchemeVersions()
emeSchemeVersions <-function (
lib.loc = NULL
)
{
pkg = "emeScheme"
res <- suppressWarnings(
packageDescription(
pkg,
lib.loc = lib.loc,
fields = c( "Version", "emeSchemeVersion")
)
)
res <- list(
package = package_version(res$Version),
emeScheme = numeric_version(res$emeSchemeVersion)
)
return(res)
}
47 changes: 37 additions & 10 deletions R/enter_new_metadata.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#' Enter new metadata to fill a new scheme
#'
#' Open \code{emeScheme.xlsx} from system.file("googlesheet",
#' "emeScheme.xlsx", package = "emeScheme") in excel. New data can be entered
#' and the file has to be saved at a different location as it is a read-only
#' file.
#' Open \code{system.file("emeScheme.xlsx", package = "emeScheme")} in excel.
#' New data can be entered and the file has to be saved at a different location
#' as it is a read-only file.
#'
#' @param file if not \code{NULL}, the te,plate will be saved to this file.
#' @param open if \code{TRUE}, the file will be opened. This can produce different results depending on the OS, browsr and browser settings.
#' @param keepData if \code{TRUE} the data entry areas will be emptied. If \code{FALSE}. the example data will be included.
#' @param format if \code{FALSE} the sheet will be opened as the googledoc sheet formated is. if \code{TRUE}, it will be formated nicely.
#' @param format if \code{FALSE} the sheet will be opened as the sheet is. if \code{TRUE}, it will be formated nicely.
#' @param overwrite if \code{TRUE}, the file specified in \code{file} will be overwritten. if \code{FALSE}, an error will be raised ehen the file exists.
#' @param verbose if \code{TRUE} print usefull information
#' @param .skipBrowseURL internal use (testing only). if \code{TRUE} skip the call of \code{browseURL()}
Expand Down Expand Up @@ -52,20 +51,44 @@ enter_new_metadata <- function(
}
)
##
fn <- file.path( tempdir(), "emeScheme.xlsx")

# Warning if `format = TRUE` ----------------------------------------------
if (format) {
warning(
"The argument `format` is set to TRUE (the default).\n",
"Corruptions of the formated xlsx filer were recently observed!.\n",
"\n",
"If the resulting xlsx file is corrupt, please use\n",
"\n",
"`format = FALSE`",
"\n",
"when calling `enter_new_metadata()`\n",
"\n",
"This does NOT delete the example data.\n"
)
}

# Temporary file name -----------------------------------------------------

fn <- tempfile(pattern = "emeScheme.", fileext = ".xlsx")

# Format if asked for, otherwise copy to fn unchanged ---------------------

if (format) {
format_emeScheme_xlsx(
fn_org = system.file("googlesheet", "emeScheme.xlsx", package = "emeScheme"),
fn_org = system.file("emeScheme.xlsx", package = "emeScheme"),
fn_new = fn,
keepData = keepData
)
} else {
file.copy(
from = system.file("googlesheet", "emeScheme.xlsx", package = "emeScheme"),
from = system.file("emeScheme.xlsx", package = "emeScheme"),
to = fn
)
}

# If file specified, copy temporary file to final destination -------------

if (!is.null(file)) {
result <- file.copy(
from = fn,
Expand All @@ -86,7 +109,9 @@ enter_new_metadata <- function(
cat_ln()
}
}
##

# If open == TRUE, open the file ------------------------------------------

if (open) {
if (verbose) {
cat_ln("Trying to open the file by opening it in the browser'", fn, "'... ")
Expand All @@ -97,7 +122,9 @@ enter_new_metadata <- function(
utils::browseURL(fn)
}
}
##

# Return invisibly the final file name ------------------------------------

invisible(fn)
}

9 changes: 5 additions & 4 deletions R/format_emeScheme_xlsx.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#' Format the \code{googlesheet/emeScheme.xlsx}
#' Format the file \code{system.file("emeScheme.xlsx", package = "emeScheme")}
#'
#' Takes no arguments. Loads \code{system.file("googlesheet", "emeScheme.xlsx", package = "emeScheme")}, formats it and saves it under the same name.
#' Takes no arguments. Loads \code{system.file("emeScheme.xlsx", package =
#' "emeScheme")}, formats it and saves it under the same name.
#' @param fn_org file name of the original excel file to be formated
#' @param fn_new file name where the final xlsx should be saved to. If missing, it will not be saved.
#' @param keepData if \code{TRUE}, data from data cells will be empty
Expand Down Expand Up @@ -160,7 +161,7 @@ format_emeScheme_xlsx <- function(
rowNames <- unlist(data[,nameCol])

dataRows <- 2:nrow(data)
dataCols <- which(colNames == "DATA"):ncol(data)
dataCols <- grep("DATA", colNames):ncol(data)

# format data range -------------------------------------------------------

Expand Down Expand Up @@ -255,7 +256,7 @@ format_emeScheme_xlsx <- function(
colNames <- unlist(data[nameRow,])

dataCols <- 2:ncol(data)
dataRows <- which(rowNames == "DATA"):nrow(data)
dataRows <- grep("DATA", rowNames):nrow(data)

# format data range -------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion R/make_example.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ make_example <- function(
)
if (name == "basic") {
format_emeScheme_xlsx(
fn_org = system.file("googlesheet", "emeScheme.xlsx", package = "emeScheme"),
fn_org = system.file("emeScheme.xlsx", package = "emeScheme"),
fn_new = file.path(".", name, "expt1_emeScheme.xlsx"),
keepData = TRUE
)
Expand Down
2 changes: 1 addition & 1 deletion R/new_emeSchemeData.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ new_emeSchemeData <- function(
# extract attributes to set -----------------------------------------------

attrToSet <- x$valueProperty
attrToSet <- attrToSet[1:(which(x$valueProperty == "DATA")-1)]
attrToSet <- attrToSet[1:(grep("DATA", x$valueProperty)-1)]

# set attributes ----------------------------------------------------------

Expand Down
4 changes: 4 additions & 0 deletions R/new_emeSchemeSet.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ attr(result, "propertyName") <- attr(x, "fileName")
class(result),
)

# Set emeSchemeVersion attribute-------------------------------------------

attr(result, "emeSchemeVersion") <- attr(x, "emeSchemeVersion")

# Return ------------------------------------------------------------------

return(result)
Expand Down
Loading

0 comments on commit cea7a3e

Please sign in to comment.