Closed regnans closed 3 years ago
Round 2, on pc.
Testing in Windows. Noticed this warning, but it did not stop code, so could go unnoticed.
WARNING: Rtools is required to build R packages, but is not currently installed.
Please download and install Rtools 4.0 from https://cran.r-project.org/bin/windows/Rtools/.
This website says: “Note that rtools40 is only needed build R packages with C/C++/Fortran code from source. By default, R for Windows installs the precompiled “binary packages” from CRAN, for which you do not need rtools!”
Running OK. Error at same point.
Error in sample_info %>% select(Plant_Species = Latin Species, Species_Code = species code, : could not find function "%>%"
library(magrittr)
loads fine but does not solve issue.
library(dplyr)
solves issue.
Runs to line144
Error in qplot(cal.plsr.data[, paste0(inVar)], geom = "histogram", main = paste0("Calibration Histogram for ", : could not find function "qplot”
library(ggplot2)
Starts again …
histograms <- grid.arrange(cal_hist_plot, val_hist_plot, ncol=2) Error in grid.arrange(cal_hist_plot, val_hist_plot, ncol = 2) : could not find function "grid.arrange"
Installed R tools and started again. Restarted R Studio On second time through did not need to load dplyr
Everything ran. Labeling on some figures was a bit clunky (figure number labels sometimes not completely in the box, so hard to interpret).
Round 3, back on Mac. Restarted R Studio. Everything ran fine. So in summary, on both machines I had to start running stuff, manually load dplr and then restart to get it to work. Perhaps.
@regnans well first, yay it finally worked! But those issues are troubling and, annoyingly, more R/Rstudio than the package itself! That makes it very difficult to try and deal with.
My initial thought is that R wanted you to respond to upgrades with packages before running. Maybe we need to tell users to first install the package and answer any and all R prompts about upgrading packages.
I don't, for the life of me, understand why dplyr gave you such issues other than perhaps the install got corrupted the first time?
Not sure, but did it tell you you needed magittr? That isn't a dependency? Strange
As for plots, the best place to see those are in the output folder. the on screen is just to make it easier but the versions written to file are far better, and don't have those issues.
The challenge is that most of the problems, if not all, are issues with R and Rstudio, including how Rstudio plots graphs when the graph size/ graph window size is small but doesn't actually indicate a bug and as I said the graphic files will be fine.
Going to have to think about if/how any of this can be addressed other than telling users that these could be R issues they deal with and how to try and get around them
in effect the output figures will /should look more like these versions
Not sure, but did it tell you you needed magittr? That isn't a dependency? Strange
No, it didn't tell me it needed magittr. When it failed on %>%
I searched for what packages that was in, and that led me to magittr and dplyr.
My initial thought is that R wanted you to respond to upgrades with packages before running. Maybe we need to tell users to first install the package and answer any and all R prompts about upgrading packages.
I think that is reasonable. There are a few things that could be included in the README to help newbies get started. It seemed that getting all of the packages up and then restarting R Studio sorted everything out. I'd be happy to help write some text for the README to help out the less R literate.
@regnans that would be very helpful thanks!
@regnans some questions
1) "Load code into operating environment: how should this be done? Can someone add? (I hacked my way around this by cut and paste, but is there a better way?)."
I don't follow this? The scripts load all of the packages into R already
#--------------------------------------------------------------------------------------------------#
### Load libraries
# make sure required tools are available
req.packages <- c("devtools")
new.packages <- req.packages[!(req.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages, dependencies=c("Depends", "Imports",
"LinkingTo"))
# install spectratrait package
devtools::install_github(repo = "TESTgroup-BNL/PLSR_for_plant_trait_prediction", dependencies=TRUE)
list.of.packages <- c("pls","dplyr","reshape2","here","plotrix","ggplot2","gridExtra","spectratrait")
invisible(lapply(list.of.packages, library, character.only = TRUE))
#--------------------------------------------------------------------------------------------------#
Again I think you issue was that you needed to first address R asking you what packages to update and because you skipped over that it failed? So does that mean we need another comment about first updating your packages first, then loading the R package and run it? @neo0351 ? That is, how would we tell folks to update R/packages and not conflate that with loading the R package?
2) "Initial run to install packages: Step 1 in the example code will check for tools and packages and install what is required. An internet connection is required to run this step. The user will be required to respond to several prompts. (Suggested responses for standard set up; 1, Yes)."
This is true, but true for and R or R package. So are you asking that we explain how to update R first? or explain what it means to load R packages? Some clarification would help to make sure I understand what text would be helpful
3) "Dealing with errors: This code was tested across a variety of operating systems and environments. In the case where most packages were being installed for the first time running subsequent Steps resulted in "could not fund function" errors in some instances. To avoid these errors it is recommended that the user restart their operating environment after installing packages in Step 1."
I think most problems are with people who just need to get their R environ ready. So wonder how we can walk someone through that? Again lots of this is, we expect a certain level of understanding of using R. We arent really expected to train someone how to use R, are we? Thats what I struggle with
This step is about how to get the code running before the scripts load packages. I'm talking SUPER basic here. I see the code in GitHUb - how does the user get that into R/RStudio? cut and paste? link to Github? save the script as *.R somewhere and load from there? Run from Github? I don't know possibilities or the best way - very much a newbie question here.
No, this was not about updating R. My intention was to provide guidance to what prompts the user will expect to see to get the packages loaded.
I agree. The user should have some experience with R. This is not meant to be a "how to R". But, this was an error that I encountered on multiple systems, so others who don't have a lot of experience or are new to these specific packages might also encounter this issue.
@regnans hmm......
For 1 I see your point and I don't yet have a very basic solution. Its too hard to express here whats up but there seems to be some issue with the fundamental "how do we get the code to a user" issue. That would usually be git clone or download zip and extract but I don't see any easy way right now to just download one of the scripts. THat said they do open in a browser which does mean you can do copy and paste
But I think you are saying there needs to be a way to get the script locally so they can open in R studio and run it?
Lets think about this
Some people unfamiliar with GitHub would look for a "save as", which doesn't exist. Your suggested solution of instructions to download the zip and run from there is good. I will update that section in the README.
@regnans when you have a chance, lets make sure the latest PR addresses this and if so we can then close
yes, closing.
I'm trying to be "that reviewer" that has no idea what they are doing with GitHub or R. (not that far from the truth).
Running spectra-trait_reseco_lma_plsr_example.R I had some issues getting started, but will make that a different issue. Once I had a the code running in R Studio (v1.4, with R 4.0.3), these are potential issues.
At Line 31: install devtools. Outputs list of packages (n = 56). Instructions about "enter one or more numbers" seem to be repeated and confusing.
Entered “1” Next output message:
Entered “Yes” (maybe guidance to this should be given in instructions).
Continued running chunks, all working until Line 99.
Tried to load packages that might help with "%>%"
Testing ended at this point. Unable to continue. I have recently used dplr in other code without an issue. Not sure what has changed.