Closed FelipeMonts closed 6 years ago
Strange, this works for me with aqp_1.14
library(aqp)
# load sample data set, a data.frame object with horizon-level data from 10 profiles
data(sp4)
str(sp4)
depths(sp4) <- id ~ top + bottom
sliced <- slice(sp4, fm= 0:15 ~ sand + silt + clay + name + ex_Ca_to_Mg)
# check the result
class(sliced)
plot(sliced, color='clay')
Could you please send the result from sessionInfo()
? There is no slice_
method, could this be related to a namespace conflict?
Do you have a specific commit in mind when you said "relaxing of the slice()"?
Thanks
Just as I thought, this is related to dplyr
:
library(aqp)
library(dplyr)
data(sp4)
str(sp4)
depths(sp4) <- id ~ top + bottom
sliced <- slice(sp4, fm= 0:15 ~ sand + silt + clay + name + ex_Ca_to_Mg)
Error as reported:
Error in UseMethod("slice_") :
no applicable method for 'slice_' applied to an object of class "SoilProfileCollection"
I was referring to the last commit: "relaxing slice(), no need for strict=TRUE 17 days ago"
1 parent c57f09f commit e8d62c78327ee67ad06d5a0b85d8c01e8f2fa224 @dylanbeaudette dylanbeaudette committed 17 days ago
Sesion info result:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] devtools_1.13.0 tidyr_0.6.2 dplyr_0.5.0 RColorBrewer_1.1-2 MASS_7.3-47 rgeos_0.3-25
[7] rgdal_1.2-11 raster_2.5-8 sp_1.2-4 plyr_1.8.4 soilDB_1.8-7 aqp_1.10
[13] Hmisc_4.0-3 ggplot2_2.2.1 Formula_1.2-1 survival_2.41-3 lattice_0.20-35
loaded via a namespace (and not attached):
[1] Rcpp_0.12.10 compiler_3.4.0 base64enc_0.1-3 tools_3.4.0 rpart_4.1-11 digest_0.6.12
[7] jsonlite_1.4 memoise_1.1.0 tibble_1.3.0 gtable_0.2.0 checkmate_1.8.2 htmlTable_1.9
[13] Matrix_1.2-2 DBI_0.6-1 curl_2.6 gridExtra_2.2.1 httr_1.3.1 withr_1.0.2
[19] stringr_1.2.0 cluster_2.0.6 knitr_1.15.1 htmlwidgets_0.8 grid_3.4.0 nnet_7.3-12
[25] reshape_0.8.7 data.table_1.10.4 R6_2.1.1 plotrix_3.6-3 XML_3.98-1.9 foreign_0.8-67
[31] latticeExtra_0.6-28 reshape2_1.4.2 magrittr_1.5 backports_1.0.5 scales_0.4.1 htmltools_0.3.6
[37] splines_3.4.0 assertthat_0.2.0 mime_0.5 colorspace_1.3-2 stringi_1.1.5 acepack_1.4.1
[43] lazyeval_0.2.0 munsell_0.4.3
This is a namespace collision, unrelated to those commits.
Three solutions:
aqp::slice(...)
Try one of those and I'll close the ticket if one works for you. Options 1-3 work for me.
SoilDb loaded aqp as a dependency, therefore add to the instructions, "load aqp and soilDb*after loading dplyr" It works all the way! Thank you.
Thanks for testing. These packages are now fairly old: namespace collisions weren't quite as common back then.
Thank you for working on solving the issue I had as fast as you did. Excellent package!
the slice function no longer works. I have tried with the example on the introduction to SoilProfileCollection objects https://ncss-tech.github.io/AQP/aqp/aqp-intro.html and it does not work with that example either.
It seems there is a bug, probably related with the relaxing of the slice() function two weeks ago. The function slab works ok though.