This is the code and error message I am getting:
> library(caret)
Error : object ‘semester’ is not exported by 'namespace:lubridate'
Error: package or namespace load failed for ‘caret’
I am using a mac. I also use this at work on a PC and haven't had any problems.
I also ran sessionInfo() as adivsed
> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X Yosemite 10.10.5
locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] lattice_0.20-34 factoextra_1.0.5 FactoMineR_1.36 e1071_1.6-8
[5] GGally_1.3.0 ggrepel_0.6.5 RColorBrewer_1.1-2 stringr_1.2.0
[9] tidyr_0.6.1 dplyr_0.7.3 data.table_1.10.4 ggplot2_2.2.1
loaded via a namespace (and not attached):
[1] reshape2_1.4.1 kernlab_0.9-25 splines_3.3.3
[4] colorspace_1.3-2 prodlim_1.6.1 survival_2.40-1
[7] rlang_0.1.2 ModelMetrics_1.1.0 glue_1.1.1
[10] bindrcpp_0.2 foreach_1.4.3 bindr_0.1
[13] plyr_1.8.4 lava_1.5 dimRed_0.1.0
[16] robustbase_0.92-7 timeDate_3012.100 munsell_0.4.3
[19] gtable_0.2.0 leaps_3.0 codetools_0.2-15
[22] class_7.3-14 DEoptimR_1.0-8 Rcpp_0.12.9
[25] scales_0.4.1 flashClust_1.01-2 ipred_0.9-6
[28] scatterplot3d_0.3-40 CVST_0.2-1 stringi_1.1.2
[31] RcppRoll_0.2.2 ddalpha_1.2.1 grid_3.3.3
[34] tools_3.3.3 magrittr_1.5 lazyeval_0.2.0
[37] tibble_1.3.4 cluster_2.0.5 DRR_0.0.2
[40] pkgconfig_2.0.1 MASS_7.3-45 Matrix_1.2-8
[43] lubridate_1.5.6 gower_0.1.2 assertthat_0.1
[46] reshape_0.8.6 iterators_1.0.8 R6_2.2.0
[49] rpart_4.1-10 nnet_7.3-12 nlme_3.1-131
You may have outdated dependencies. Try updating all installed packages. Then install "caret" with all dependencies : (install.packages("caret", dependencies = TRUE)). Worked for me!
I just ran into the same issue, except I got stuck at updating (reinstalling) the lubridate package. Some of the errors I got looked something like:
./cctz/include/civil_time_detail.h:37: error: expected nested-name-specifier before ‘year_t’
./cctz/include/civil_time_detail.h:37: error: ‘year_t’ has not been declared
./cctz/include/civil_time_detail.h:37: error: expected ‘;’ before ‘=’ token
./cctz/include/civil_time_detail.h:37: error: expected unqualified-id before ‘=’ token
turned out my gcc compiler (running RHEL 6.8) was too old (4.4.7). Since I couldn't upgrade the compiler itself, I installed a devtoolset.
then, I fixed my problem by enabling the devtoolset before running R:
scp enable devtoolset-4 R
Related
I just upgraded R and R Studio to the most recent versions.
I am trying to load the package RHRV and R Studio aborts the session due to a fatal error. It is associated with the following error:
loading package: tcltk
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Loading required package: tkrplot
The command:
library("tcltk")
gives the following error message:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Warning message:
running command ''/usr/bin/otool' -L '/Library/Frameworks/R.framework/Resources/library/tcltk/libs//tcltk.so'' had status 1
Running the following command crashes R Studio:
library("tkrplot")
Here is some additional information of interest:
sessionInfo("tcltk")
R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11 (El Capitan)
locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8
attached base packages:
[1] tcltk
loaded via a namespace (and not attached):
[1] Rcpp_0.12.2 Formula_1.2-1 cluster_2.0.3 magrittr_1.5 splines_3.2.2 MASS_7.3-43 grDevices_3.2.2
[8] munsell_0.4.2 colorspace_1.2-6 lattice_0.20-33 minqa_1.2.4 stringr_1.0.0 plyr_1.8.3 tools_3.2.2
[15] utils_3.2.2 nnet_7.3-10 grid_3.2.2 gtable_0.1.2 nlme_3.1-121 latticeExtra_0.6-26 stats_3.2.2
[22] datasets_3.2.2 survival_2.38-3 lme4_1.1-10 digest_0.6.8 base_3.2.2 Matrix_1.2-2 gridExtra_2.0.0
[29] RColorBrewer_1.1-2 nloptr_1.0.4 reshape2_1.4.1 ggplot2_1.0.1 acepack_1.3-3.3 graphics_3.2.2 effects_3.0-4
[36] rpart_4.1-10 stringi_1.0-1 methods_3.2.2 scales_0.3.0 Hmisc_3.17-0 lmerTest_2.0-29 foreign_0.8-65
[43] proto_0.3-10
sessionInfo("tkrplot")
R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11 (El Capitan)
locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8
attached base packages:
character(0)
other attached packages:
[1] tkrplot_0.0-23
loaded via a namespace (and not attached):
[1] Rcpp_0.12.2 Formula_1.2-1 cluster_2.0.3 magrittr_1.5 splines_3.2.2 MASS_7.3-43 grDevices_3.2.2
[8] munsell_0.4.2 colorspace_1.2-6 lattice_0.20-33 minqa_1.2.4 stringr_1.0.0 plyr_1.8.3 tcltk_3.2.2
[15] tools_3.2.2 utils_3.2.2 nnet_7.3-10 grid_3.2.2 gtable_0.1.2 nlme_3.1-121 latticeExtra_0.6-26
[22] stats_3.2.2 datasets_3.2.2 survival_2.38-3 lme4_1.1-10 digest_0.6.8 base_3.2.2 Matrix_1.2-2
[29] gridExtra_2.0.0 RColorBrewer_1.1-2 nloptr_1.0.4 reshape2_1.4.1 ggplot2_1.0.1 acepack_1.3-3.3 graphics_3.2.2
[36] effects_3.0-4 rpart_4.1-10 stringi_1.0-1 methods_3.2.2 scales_0.3.0 Hmisc_3.17-0 lmerTest_2.0-29
[43] foreign_0.8-65 proto_0.3-10
Matt
With many thanks to Ben, I can provide a solution to the problem. The issue is that El Capitan has a somewhat unknown xcode issue.
Open the Terminal App and enter:
xcode-select --install
It takes a few minutes to load the patch needed to run xcode. The error described above is highlighted in several instances, and this was the workaround.
I then restarted my computer and loaded the package "tkrplot" directly from the source with the code:
install.packages("tkrplot", type="source")
Once I completed these three steps, I was able to load the package "RHRV" and the associated packages "tkrplot" and "tcltk" without issue.
You'll only have the "invalid active developer path" problem when you build package from source. If you use the pre-compiled versions from CRAN, you won't have to worry about it. Try
install.packages("tkrplot", type="binary")
Ran a test for data.table on my new installation of R and got the below errors:
> test.data.table()
Error in eval(exprs[i], envir) :
10 errors out of 8403 (lastID=1887, endian==little, sizeof(long
double)==16, sizeof(pointer)==8) in inst/tests/tests.Rraw on Tue Apr 03
11:28:16 2018. Search tests.Rraw for test numbers: 546, 1693.4, 1693.5,
1693.6, 1693.7, 1693.9, 1702.1, 1702.2, 1702.3, 1702.4.
All errors were of the kind:
Test testnum ran without errors but failed check that x equals y:
Where testnum is the test that failed (from above message).
Some more details:
R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 LC_MONETARY=English_Canada.1252
[4] LC_NUMERIC=C LC_TIME=English_Canada.1252
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] rmarkdown_1.9 curl_3.1 caret_6.0-78 lattice_0.20-35 xts_0.10-1 zoo_1.8-1
[7] nlme_3.1-131.1 hexbin_1.27.2 testthat_2.0.0 plyr_1.8.4 knitr_1.20 bit64_0.9-7
[13] bit_1.1-12 ggplot2_2.2.1 lubridate_1.7.2 data.table_1.10.5 gmad_0.0.0.9000 reshape2_1.4.3
[19] reshape_0.8.7
loaded via a namespace (and not attached):
[1] httr_1.3.1 ddalpha_1.3.1.1 tidyr_0.8.0 sfsmisc_1.1-2 splines_3.4.4
[6] foreach_1.4.4 prodlim_1.6.1 assertthat_0.2.0 highr_0.6 stats4_3.4.4
[11] DRR_0.0.3 yaml_2.1.17 robustbase_0.92-8 ipred_0.9-6 pillar_1.2.1
[16] backports_1.1.2 glue_1.2.0 digest_0.6.15 colorspace_1.3-2 recipes_0.1.2
[21] htmltools_0.3.6 Matrix_1.2-12 psych_1.7.8 timeDate_3043.102 pkgconfig_2.0.1
[26] CVST_0.2-1 broom_0.4.3 purrr_0.2.4 scales_0.5.0 gower_0.1.2
[31] lava_1.6 tibble_1.4.2 withr_2.1.1 nnet_7.3-12 lazyeval_0.2.1
[36] mnormt_1.5-5 survival_2.41-3 magrittr_1.5 evaluate_0.10.1 MASS_7.3-49
[41] dimRed_0.1.0 foreign_0.8-69 class_7.3-14 tools_3.4.4 stringr_1.3.0
[46] kernlab_0.9-25 munsell_0.4.3 bindrcpp_0.2 compiler_3.4.4 RcppRoll_0.2.2
[51] rlang_0.2.0 grid_3.4.4 iterators_1.0.9 labeling_0.3 gtable_0.2.0
[56] ModelMetrics_1.1.0 codetools_0.2-15 R6_2.2.2 dplyr_0.7.4 bindr_0.1
[61] rprojroot_1.3-2 stringi_1.1.6 Rcpp_0.12.15 rpart_4.1-13 DEoptimR_1.0-8
[66] tidyselect_0.2.4
Using RStudio as the IDE, version 1.1.442 gmad is a local package (does not have any conflicting function names, basically a package to access some private APIs).
Not sure if this is cause for concern - didn't encounter this on any previous installations. I've seen the answer for test.data.table() error message but it's for an older version and I am seeing multiple errors (vs one).
EDIT
Restarted RStudio, test run fines when no packages (other than base) are loaded (not even data.table).
Get errors after loading some packages.
I've copied the output for both cases. Too long to post in this question - here's a pastebin link and here's another for GoogleDrive.
Regarding my local package gmad:
NAMESPACE imports:
import(data.table)
import(ggplot2)
import(httr)
importFrom(lubridate,round_date)
DESCRIPTION imports:
Imports:
data.table,
lubridate,
ggplot2,
ggmap,
httr
All other packages are installed from CRAN (versions noted in the session info above).
data.table and lubridate use the same function names for some date/time-related functions so the order of loading both libraries decides which function from which package is called by the unit tests.
See this issue for details: https://github.com/Rdatatable/data.table/issues/1135
I think to test the correct installation of data.table you shouldn't load lubridate at all.
If you want to use date/time functions in your code you have to choose which masking is better for you and load the libraries in the desired order...
library(lubridate)
library(data.table)
test.data.table() # runs without errors
If you reset the R session and load data.table first you will get some unit test errors
library(data.table)
library(lubridate)
test.data.table() # runs with unit test errors
saying e. g.
Running test id 546 Test 546 ran without errors but failed check that
x equals y:
I'm trying to read data in the XPT format into R (the format can be found for example in the NHANES data). I found two functions doing this:
library("Hmisc")
sasxport.get("C:/path/file.XPT")
and
library("SASxport")
read.xport("C:/path/file.XPT")
The sasxport.get works, so I'm basically fine, but still inquisitive enough to understand (and solve) the following error: after the installation of the SASxport package, I cannot load it. When I run library("SASxport"), I get the error message:
Error: package or namespace load failed for ‘SASxport’:
object ‘label<-.data.frame’ is not exported by 'namespace:Hmisc'
Adopting this suggestion, I also ran
remove.packages(c("SASxport", "Hmisc"))
install.packages('Hmisc', dependencies = TRUE)
install.packages('SASxport', dependencies = TRUE)
what did not change the error message.
This is my sessionInfo():
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] Hmisc_4.1-1 ggplot2_2.2.1 Formula_1.2-2 survival_2.41-3 lattice_0.20-35
loaded via a namespace (and not attached):
[1] Rcpp_0.12.14 pillar_1.0.1 compiler_3.4.3 RColorBrewer_1.1-2 plyr_1.8.4
[6] base64enc_0.1-3 iterators_1.0.9 tools_3.4.3 rpart_4.1-11 digest_0.6.13
[11] tibble_1.4.1 gtable_0.2.0 htmlTable_1.11.1 checkmate_1.8.5 rlang_0.1.6
[16] icenReg_2.0.7 Matrix_1.2-12 foreach_1.4.4 rstudioapi_0.7 yaml_2.1.16
[21] gridExtra_2.3 coda_0.19-1 stringr_1.2.0 cluster_2.0.6 knitr_1.18
[26] htmlwidgets_0.9 grid_3.4.3 nnet_7.3-12 data.table_1.10.4-3 foreign_0.8-69
[31] latticeExtra_0.6-28 magrittr_1.5 scales_0.5.0 backports_1.1.2 codetools_0.2-15
[36] htmltools_0.3.6 splines_3.4.3 colorspace_1.3-2 stringi_1.1.6 acepack_1.4.1
[41] lazyeval_0.2.1 munsell_0.4.3
The last update of SASxport happend nearly two years ago (2016-03-11). So the Hmisc package it imports might have changed in the meantime. Looking up the Hmisc archive I found the version number on 2016-03-11 to be 3.17-2. So installing this version fixes the problem:
library("devtools")
install_version("Hmisc", version = "3.17-2")
Two reasons speak against using SASxport in this case:
You need to use a old version of a package which might happer your work in later steps.
SASxport needs Hmisc for a task that Hmisc can do already by itself, so SASxport is expendable when reading in XPT files.
I am using the GO.db package in R (v3.3.2) to access information about the Gene Ontology. I can see by running the GO.db command that my annotations are outdated. (I know there are a newer set of annotations released in 2017).
> GO.db
GODb object:
| GOSOURCENAME: Gene Ontology
| GOSOURCEURL: ftp://ftp.geneontology.org/pub/go/godatabase/archive/latest-lite/
| GOSOURCEDATE: 2016-Sep21
| Db type: GODb
| package: AnnotationDbi
| DBSCHEMA: GO_DB
| GOEGSOURCEDATE: 2016-Sep26
| GOEGSOURCENAME: Entrez Gene
| GOEGSOURCEURL: ftp://ftp.ncbi.nlm.nih.gov/gene/DATA
| DBSCHEMAVERSION: 2.1
I've tried uninstalling and reinstalling the package, but the GOSOURCEDATE value remains unchanged.
I want to find out what sequence of R commands will allow me to load the newer annotations. Do I need to install a newer version of R?
The Bioconductor version information is as follows:
> BiocInstaller::biocLite()
BioC_mirror: https://bioconductor.org
Using Bioconductor 3.4 (BiocInstaller 1.24.0), R 3.3.2 (2016-10-31).
The output of the sessionInfo command is as follows (includes a lot of unrelated packages that my application also loads.
> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 LC_MONETARY=English_Canada.1252
[4] LC_NUMERIC=C LC_TIME=English_Canada.1252
attached base packages:
[1] parallel stats4 stats graphics grDevices utils datasets methods base
other attached packages:
[1] cowplot_0.8.0 ggplot2_2.2.1 xlsx_0.5.7 xlsxjars_0.6.1 rJava_0.9-8
[6] reshape2_1.4.2 metap_0.8 GO.db_3.4.0 annotate_1.52.1 XML_3.98-1.9
[11] org.Hs.eg.db_3.4.0 AnnotationDbi_1.36.2 IRanges_2.8.2 S4Vectors_0.12.2 Biobase_2.34.0
[16] BiocGenerics_0.20.0 homologene_1.0 magrittr_1.5 tidyr_0.7.1 dplyr_0.7.3
[21] readr_1.1.1 tmod_0.31
loaded via a namespace (and not attached):
[1] beeswarm_0.2.3 purrr_0.2.3 lattice_0.20-34 colorspace_1.3-2 htmltools_0.3.6 blob_1.1.0
[7] rlang_0.1.2 glue_1.1.1 DBI_0.7 bit64_0.9-7 RColorBrewer_1.1-2 bindrcpp_0.2
[13] bindr_0.1 plyr_1.8.4 pca3d_0.10 stringr_1.2.0 munsell_0.4.3 gtable_0.2.0
[19] htmlwidgets_0.9 memoise_1.1.0 knitr_1.17 httpuv_1.3.5 Rcpp_0.12.12 xtable_1.8-2
[25] scales_0.5.0 jsonlite_1.5 mime_0.5 bit_1.1-12 ellipse_0.3-8 hms_0.3
[31] digest_0.6.12 stringi_1.1.5 tagcloud_0.6 shiny_1.0.5 grid_3.3.2 tools_3.3.2
[37] bitops_1.0-6 rgl_0.98.1 lazyeval_0.2.0 RCurl_1.95-4.8 tibble_1.3.4 RSQLite_2.0
[43] pkgconfig_2.0.1 assertthat_0.2.0 R6_2.2.2 plotwidgets_0.4
I couldn't find your question on the support site, so I can give you one here.
It seems that you are using Bioconductor version 3.4. It appears that all of your annotation packages are out-of-date. If you want to use the current release annotations, you will have to update your version of R to the current release version (3.4.1) and then run the command BiocInstaller::biocLite("biocUpgrade").
How can I open my getwd() folder directly from the R console? This is useful if I want to see something I've recently just exported there. A google search has revealed nothing and I don't have the capability to build a function.
If you actually want a file browser you could create a function to open the directory. This is done differently based on the operating system you're using but this should cover most bases
opendir <- function(dir = getwd()){
if (.Platform['OS.type'] == "windows"){
shell.exec(dir)
} else {
system(paste(Sys.getenv("R_BROWSER"), dir))
}
}
If you don't need it to be cross platform you can reduce it down to just the code for your OS. But if you just want to view the files in a given directory then using dir should be good enough.
You can use dir() or list.files() to display the files in the current working directory or file.choose() to browse the directory and choose a file. All three default to the current working directory.
I'd suggest using:
utils::browseURL(getwd())
Posting an answer because the above function did not work for me - got around it buusing a macOS terminal command via a system call from within R (session info below).
Function
opendir <- function(directory = getwd()){
system(sprintf('open %s', shQuote(directory)))
}
Session Info
> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8
attached base packages:
[1] stats graphics grDevices utils
[5] datasets methods base
other attached packages:
[1] here_0.1 htmlwidgets_1.3
[3] openxlsx_4.1.0.1 tictoc_1.0
[5] plotly_4.9.0 jsonlite_1.6
[7] ggplot2_3.1.1 lubridate_1.7.4
[9] httr_1.4.0 data.table_1.12.2
loaded via a namespace (and not attached):
[1] zip_2.0.2 Rcpp_1.0.1
[3] RColorBrewer_1.1-2 later_0.8.0
[5] pillar_1.4.0 compiler_3.6.0
[7] plyr_1.8.4 tools_3.6.0
[9] digest_0.6.19 packrat_0.5.0
[11] tibble_2.1.1 gtable_0.3.0
[13] viridisLite_0.3.0 pkgconfig_2.0.2
[15] rlang_0.3.4 shiny_1.3.2
[17] rstudioapi_0.10 crosstalk_1.0.0
[19] yaml_2.2.0 withr_2.1.2
[21] dplyr_0.8.1 stringr_1.4.0
[23] rprojroot_1.3-2 grid_3.6.0
[25] tidyselect_0.2.5 glue_1.3.1
[27] R6_2.4.0 processx_3.3.1
[29] purrr_0.3.2 tidyr_0.8.3
[31] magrittr_1.5 ps_1.3.0
[33] promises_1.0.1 backports_1.1.4
[35] scales_1.0.0 htmltools_0.3.6
[37] assertthat_0.2.1 xtable_1.8-4
[39] mime_0.6 colorspace_1.4-1
[41] httpuv_1.5.1 labeling_0.3
[43] stringi_1.4.3 lazyeval_0.2.2
[45] munsell_0.5.0 crayon_1.3.4