Closed juandemedel closed 2 years ago
Hi @juandemedel. I'll spare you the details, but for now you can keep the variable names exactly as-is if you first convert your DataSample
to a data.frame, and tell R to preserve the column names. Like this:
data <- as.rspec(data.frame(DataSample, check.names = FALSE))
For @Bisaloo, it's this:
https://github.com/rmaia/pavo/blob/bc8673a60868fb95deccebf5594153dd3f902b92/R/as.rspec.R#L46-L49
Do you see any issue with adding check.names = FALSE
? as.rspec()
otherwise preserves numeric names when fed a df, it's just the tibble.
Do you see any issue with adding check.names = FALSE?
No, sounds good. Thanks for identifying the problem so fast!
Fixed in 4a95972d3117b7fa16cbe92956a44dbc710c597b.
@juandemedel - if you download the development version of pavo
your original code should now work as intended & preserve the numeric column names.
Hello dear community @Bisaloo, @thomased. I have been working with pavo to plot light spectrums on an aggplot. My spectral data contains several factors and each factor has several levels. For instance, the factors are Raw, 0, 25, 50, and 100 whose levels are Raw.A, Raw.B, 0.A, 0.B, 0.C, 25.A, 25.B, 25.C, 25.D, 25.E, ..., 100.A, 100.B and so on. However, once I have run my code, the factor headings turn into Raw, X0, X25, X50, and X100 instead of Raw, 0, 25, 50, and 100. Thereby, it also happens in aggplot's legend. Would you please give me some advice to fix it?
My code:
library(pavo)
library(readxl)
DataSample <- read_excel("myFile.xlsx")
DataSample
is.rspec(DataSample)
data <- as.rspec(DataSample)
specs <- procspec(specs, opt = c("max", "min"))
levels <- gsub(".[A-Z]", "", names(specs))[-1]
table(levels)