kamapu / vegtable

Handling vegetation-plot data sets
http://kamapu.github.io/vegtable/
7 stars 0 forks source link

Cannot run example write_juice #26

Closed orb16 closed 1 year ago

orb16 commented 1 year ago

Hi there

Just installed vegtable.

Tried loading the data (no problem) and then the write_juice function and got an error:

require(vegtable)
 data(Kenya_veg)
write_juice(Kenya_veg, "SWEA", FUN=mean)

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘write_juice’ for signature ‘"vegtable", "character", "missing"’

Any hints?

kamapu commented 1 year ago

I noticed the example was not correct and the package had some issues as well. First of all, please reinstall the packages from the development versions:

library(devtools)
install_github(repo = "ropensci/taxlist", ref = "devel")
install_github(repo = "kamapu/vegtable", ref = "devel")

Afterwards, restart your R session. In your code, you are missing the formula (which is rather documented for function crosstable()) and the argument header (I have to write a method working with missing header; see #27 ).

For instance do:

library(vegtable)

vegetation <- Kenya_veg[1:20, ]
vegetation <- cover_trans(x = vegetation, to = "cover_percent", rule = "middle")

write_juice(data = vegetation, file = "SWEA",
    formula = cover_percent ~ ReleveID + AcceptedName, FUN = mean,
    header = c("ReleveID", "COMM_TYPE"))

I hope, it helps