lter / soilHarmonization

Homogenize LTER Soil Organic Matter Working Group data and notes
https://lter.github.io/soilHarmonization/
Other
1 stars 4 forks source link

13C not recognized by QC script #4

Closed wwieder closed 6 years ago

wwieder commented 6 years ago

There seems to be an issue with the QC script recognizing the variable '13c' (presumably because it starts with a numeric).

see BNZ2, which produces this error: Error in parse(text = x) : :1:3: unexpected symbol 1: 13c

wwieder commented 6 years ago

not surprising, but same issue for 15n

srearl commented 6 years ago

HELPER FUNCTION ggname: to surround dependent variable passed to plotting function in backticks. This problem arose when attempting to plot data sets that had column nanes starting with a number (e.g., 13c) because we need to call aes_string (as opposed to aes); ggname applied to depVar in the qcPlotsInner function.

https://stackoverflow.com/questions/13445435/ggplot2-aes-string-fails-to-handle-names-starting-with-numbers-or-containing-s

  ggname <- function(x) {
    if (class(x) != "character") {
      return(x)
    }
    y <- sapply(x, function(s) {
      if (!grepl("^`", s)) {
        s <- paste("`", s, sep="", collapse="")
      }
      if (!grepl("`$", s)) {
        s <- paste(s, "`", sep="", collapse="")
      }
    }
    )
    y
  }