forestgeo / AGBfluxes

Compute flux of biomass at ForestGEO sites.
https://forestgeo.github.io/AGBfluxes/
GNU General Public License v3.0
2 stars 1 forks source link

PRIORITY: Help me run data_preparation() #20

Closed maurolepore closed 6 years ago

maurolepore commented 6 years ago

RE: On Thu, Oct 4, 2018 at 8:22 AM Ervan Rutishauser er.rutishauser@gmail.com wrote:

The main function works fine on my end. Could you test and let me know, please?

Unfortunately it fails on my end. I tried from the AGBfluxes package itself, and from a new project with just the data (image below). Can you see what I'm doing wrong?

image

maurolepore commented 6 years ago

BTW, when you succeed running data_preparation(), is that with a fresh session? I'm afraid you may have something loaded in your global environment that I don't.

maurolepore commented 6 years ago

@ervanSTRI ,

This issue is the priority.

Please help me figure out why data_preparation() fails to run from a fresh R environment (an R session other than yours). The next step is for you to run data_praparation() from this rstudio.cloud project. Save a permanent copy so it remains in your rstudio.cloud account:

image

That project is a clone of AGBfluxes, and the R environment is completely fresh. This means that nothing from your own computer will interfere (e.g. stuff in your .Rprofile or global environment).

From that rstudio.cloud project you can pull and push to GitHub as us usual. You may need to tell git who you are:

git config --global user.name "username"
git config --global user.email "you@example.com"

This should help you find errors that don't show up from your own computer. Fix them if you can, and let me know if you can't.

maurolepore commented 6 years ago

@ervanSTRI,

When you run data_preparation() successfully, Did you run it from a fresh session (i.e. after pressing Shift + Control + F10)? I still get the error I show below.

Also, once you get this to work, please share your output (maybe save it in inst/data_preparation-output.Rdata, or write a .csv file in inst/data_preparation-output.csv).

image

ErvanCH commented 6 years ago

I fixed the problem. For whatever reason, some mandatory data set included in BIOMASS aren't loaded. I add to debug, catch the data and save it into /data. This is tedious and probably not very clean. We might want to explore that to understand what happen and why the external functions do not work. At least, the function now works properly. I noticed another issue: the ggplot (aes) isn't working at last step, despite the fact that "ggplot2" is mentioned in "import" file. In fact, it seems that both packages ("BIOMASS" and "ggplot2" ) fail to be loaded properly. Maybe we declare them again in the main function # @imports ... ???

maurolepore commented 6 years ago

@ervanSTRI

At least, the function now works properly.

Unfortunately, it doesn't run neither in my computer nor in rstudio.cloud. Please confirm that you are runing the same code (see below), and that your session is fresh -- meaning that:

  1. You restart before you run (Shift + Control + F10)
  2. Your global options are set as I show you below -- which avoids your current session from loading stuff from older sessions.

Finally, once you do this please share your output as I explained in https://github.com/forestgeo/AGBfluxes/issues/20#issuecomment-429180272.

Code and output

# Document: devtools::document() or (Shift + Control + D)
# Build: devtools::build() or Shift + Control + B)
# Install: devtools::install() or click Install and Restart
# Restart session (Control + Shift + F10)

library(AGBfluxes)

data_preparation(
  site = "barro colorado island",
  stem = TRUE,
  taper_correction = TRUE,
  fill_missing = TRUE,
  use_palm_allometry = TRUE,
  flag_stranglers = TRUE,
  dbh_stranglers = 500,
  maxrel = 0.2,
  output_errors = TRUE,
  DATA_path = NULL,
  exclude_interval = NULL
)

image

Tools > Global Options

image

maurolepore commented 6 years ago

... ggplot (aes) isn't working at last step, despite the fact that "ggplot2" is mentioned in "import" file.

This is surprising. Unfortunately I can't reproduce this until I get the some output. In the mean time, I'll refer to all functions in ggplot2 explicitely (as ggplot2::function()). (This will make the code quite messy but I don't worry for now. I'll cleanup once I can test the outputs.) Now I can remove ggplot2 from imports.R.

maurolepore commented 6 years ago

... it seems that both packages ("BIOMASS" and "ggplot2" ) fail to be loaded properly....For whatever reason, some mandatory data set included in BIOMASS aren't loaded.

I'm exploring BIOMASS

maurolepore commented 6 years ago

Good news. I found the data in BIOMASS/data on CRAN's GitHub. I document this in data-raw/data-BIOMASS_package.R.

image

maurolepore commented 6 years ago

This ends my cleanup for now. I hope you can make data_preparation() run and I'll follow from there. A good place to ensure that runs not only for you but for any user is in README.Rmd. If you knit the file and the output shows an error, then something is wrong. Knitr runs a fresh sesison every time you knit. Notice, however, that after you fix the package and re-install it, you may need to Clear Kniter's Cache: