I am running testthat in Rstudio (Windows 0.98.1056), and I get the following error. It seems to have appeared after I updated Rstudio and the installed R packages, but I suspect the two may not be directly related. The error occurs also on a very simple test file. Has anyone encountered this?
file: tests/test-all.R
library(testthat)
library(matrixUtils)
test_package("matrixUtils")
file: tests/testthat/matrixUtils-test.R
context("testa")
test_that("subsetting by one dimension", {
a <-1
expect_equal(a, 1)
})
Error message:
==> Sourcing R files in 'tests' directory
Error: '\.' is an unrecognized escape in character string starting "'\." Execution halted
Exited with status 1.
sessionInfo() R version 3.1.1 (2014-07-10) Platform: x86_64-w64-mingw32/x64 (64-bit)
locale: [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] grid stats graphics grDevices utils datasets methods base
other attached packages: [1] magrittr_1.1.0 matrixUtils_0.2 testthat_0.8.1 dplyr_0.2.0.99 reshape2_1.4 ggplot2_1.0.0 gridExtra_0.9.1 [8] zoo_1.7-11
loaded via a namespace (and not attached): [1] assertthat_0.1 colorspace_1.2-4 digest_0.6.4 gtable_0.1.2 lattice_0.20-29 MASS_7.3-34 munsell_0.4.2 [8] parallel_3.1.1 plyr_1.8.1 proto_0.3-10 Rcpp_0.11.2 scales_0.2.4 stringr_0.6.2 tools_3.1.1
>
It's hard to check your error without the package. Some ideas:
This was a similar error reported in #187 on github/hadley/testthat.
Update testthat package. Latest is 0.9.1.
Issue was closed but looks hard to reproduce. #hadley suggests a fix
check that devtools is enabled under project options in RStudio
renkun-ken added library(devtools) as a last resort in his Rprofile.
I start RStudio without .Rprofile which runs library(devtools). Test from Test package does not work, then I run devtools::test() as you suggest, and it works.
If this does not work. Check your paths and use file.path() to create paths using strings in your package. This error seems to crop up with paths misspecified.
Hope this helps gappy and you get the "woot" happy test messages soon!
M
Related
I'm working with roxygen2 and for some reason I can't get it to run.
I've tried:
> devtools::load_all()
> devtools::document()
which resulted in:
Updating xxxx documentation
Loading xxxx
First time using roxygen2. Upgrading automatically...
Writing NAMESPACE
Error in file(con, "r") : cannot open the connection
In addition: Warning message: In file(con, "r") : cannot open file
'C:\Users\xxxxxxx': Permission denied
I also tried:
> roxygen2::roxygenise()
yielding:
Loading xxxx
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
cannot open file 'C:\Users\xxxxxxxx': Permission denied
I've tried installing the 6.1.0 and 6.0.1 versions of roxygen, with same results.
Any solutions? Thanks.
(Note) The following is the my Session Info:
>sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] stringi_1.2.4 usethis_1.3.0 glue_1.3.0 git2r_0.23.0
RCurl_1.95-4.11
[6] bitops_1.0-6 rlang_0.2.1 testthat_2.0.0 roxygen2_6.1.0
devtools_1.13.6
loaded via a namespace (and not attached):
[1] Rcpp_0.12.18 digest_0.6.15 withr_2.1.2 commonmark_1.5 R6_2.2.2
[6] backports_1.1.2 magrittr_1.5 rstudioapi_0.7 xml2_1.2.0
tools_3.5.1
[11] stringr_1.3.1 yaml_2.2.0 compiler_3.5.1 memoise_1.1.0
This appears to be a minor bug in latest roxygen2 6.1.0.
See https://github.com/klutometis/roxygen/issues/766 with short term solution being offered by gustavdelius via devtools::install_github("gustavdelius/roxygen").
I imagine this will be resolved in next release of roxygen2.
Just to follow-up on this, even after using the solution above and updating to the most updated version of roxygen2 (7.0.1) I kept getting the same error. After some debugging, I found that in one of my functions I had an empty #' line in the documentation of the function. Once I omitted the empty line, I was able to run roxygenize my functions and create the documentation. Hope this helps!
I got the similar error and updating the package didn't help. Then I found I have an empty #example for one function (I plan to add the example later). I deleted the line and the problem got resolved. In my case empty #' didn't cause any problem.
I am reading in some excel data into R in a loop because I have a bunch of files. This is something that I do regularly. I am having some trouble though and I'm not sure even how to make reproducible example. So i have all the files that I want in one directory and I am reading them in using this set of commands:
## Because I want warnings to stop the loop at a certain file so I can diagnose
options(warn=2)
xl_load_in <- c()
for (x in list.files(pattern="*\\.xls")) {
cat(x, "\n ")
u <- read_excel(x,col_types=c("text","text","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","text"))
xl_load_in <- tbl_df(rbind(xl_load_in, u))
}
options(warn=0)
So this is both a tool to read in files but also, using the warn toggle, I can diagnose which files aren't reading in correctly.
Now the problem: From a fresh reboot and I can rename and save the excel files in the directory. If, however, I run the above R code, I lose the permission to save or rename the excel file where the loop broke (There are small issues with the excel files that have to rectified manually). For example if I try to rename the file upon which the loop broke I get this windows error:
The action can't be completed because the file is open in RStudio R
Session.
If I reboot, I can again modify the file in question. But before the reboot I can't save or rename the file. Can anyone explain this behaviour where R or Rstudio seems to be taking over my permissions?
Update If I close RStudio, the permissions are returned. If I do the same sequence of commands above using RGUI for Windows, the problem in replicated indicating the issue is not an RStudio problem.
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_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] stringr_1.1.0 readxl_0.1.1 lubridate_1.6.0 dplyr_0.5.0 purrr_0.2.2 readr_1.0.0 tidyr_0.6.0 tibble_1.2
[9] ggplot2_2.2.0 tidyverse_1.0.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.7 assertthat_0.1 R6_2.2.0 grid_3.3.2 plyr_1.8.4 DBI_0.5-1 gtable_0.2.0
[8] magrittr_1.5 scales_0.4.1 stringi_1.1.2 lazyeval_0.2.0 tools_3.3.2 munsell_0.4.3 colorspace_1.3-0
So I installed an old version of ggplot2 with install_version from devtools (0.9.1 or something) to see how it worked - over the previously installed 2.0.0 version by the way. I then upgraded the version and it surprisingly gave me version 1.0.0, not the current 2.0.0.
Now when I do an install.packages("ggplot2") I get the same 1.0.0. Also selecting "Check for package upgrades.." item from the Rstudio menu it tells me "All packages up to date".
What gives? Isn't the newest version of ggplot now 2.0.0? Here is my session info:
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] devtools_1.9.1 ggplot2_1.0.0 dplyr_0.4.3 shiny_0.12.2 RevoUtils_7.5.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.2 magrittr_1.5 MASS_7.3-43 munsell_0.4.2 colorspace_1.2-6
[6] xtable_1.8-0 R6_2.1.1 stringr_1.0.0 plyr_1.8.3 tools_3.2.2
[11] parallel_3.2.2 grid_3.2.2 gtable_0.1.2 DBI_0.3.1 htmltools_0.2.6
[16] assertthat_0.1 digest_0.6.8 reshape2_1.4.1 memoise_0.2.1 mime_0.4
[21] stringi_1.0-1 scales_0.3.0 jsonlite_0.9.19 httpuv_1.3.3 proto_0.3-10
>
Here are the repositories it is seeing:
> AP <- available.packages()
> apdf <- data.frame(AP)
> unique(apdf$Repository)
[1] http://mran.revolutionanalytics.com/snapshot/2014-12-01/src/contrib
[2] http://www.stats.ox.ac.uk/pub/RWin/src/contrib
2 Levels: http://mran.revolutionanalytics.com/snapshot/2014-12-01/src/contrib ...
>
Update:
Thanks to Dirk, I see what happened. Looks like installing RRO package reset my CRAN repository. I can also sort of see why that had to be, although maybe I should have got a warning about it. From this blog entry I see how to fix it too. http://www.r-bloggers.com/permanently-setting-the-cran-repository/
Run
AP <- available.packages() # possibly with repo options
and examine the result set.
That is what your R session knows about packages, and it is a function of
the R version; you generally want the newest series (and you have 3.2.*)
the repos you select (which you did not show)
Edit: I typically use options("repos") to check which repositories I have, and I tend to control that from Rprofile.site. But you seem to have RevoR and I do not know how/if that interacts.
Not quite understanding what "lazyeval" is, I was trying to install and run the package to use dplyr within a function.
When I ran
library(lazyeval)
I got the error message:
Error in library(lazyeval) : there is no package called 'lazyeval'
even after successfully installing.
Now, though, when I try to run any standard dplyr script, I get the following error message:
Error in loadNamespace(name) : there is no package called 'lazyeval'
It's as if the lazyeval has over-written dplyr, but I can't actually use lazyeval.
Has anyone run into this issue? If so, how did you resolve?
Some info:
sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] grid splines stats graphics grDevices utils datasets
[8] methods base
other attached packages:
[1] scales_0.2.4 gridExtra_0.9.1 ggplot2_1.0.0 forecast_5.4
[5] timeDate_3010.98 reshape2_1.4 xts_0.9-7 zoo_1.7-11
[9] lubridate_1.3.3 dplyr_0.4.1 plyr_1.8.1
loaded via a namespace (and not attached):
[1] assertthat_0.1 colorspace_1.2-4 DBI_0.3.1 digest_0.6.4
[5] fracdiff_1.4-2 gtable_0.1.2 lattice_0.20-29 magrittr_1.0.1
[9] MASS_7.3-35 memoise_0.2.1 munsell_0.4.2 nnet_7.3-8
[13] parallel_3.1.2 proto_0.3-10 quadprog_1.5-5 Rcpp_0.11.1
[17] stringr_0.6.2 tools_3.1.2 tseries_0.10-32
When I run .libPaths(), I get two directories:
[1] "C:/Users/MTULLA/Documents/R/win-library/3.1"
[2] "C:/Program Files/R/R-3.1.2/library"
In the first, I can find both dplyr and lazyeval, both with .dll files. In the second, I can't find either
I also got this message when running the lesson 1 of Getting and Cleaning Data on Swirl.
Package ‘dplyr’ loaded correctly!
Error in loadNamespace(name) : there is no package called ‘lazyeval’
Reinstalling packages also didn't work
It was solved by updating my R version using the {installr} package
It can be resolved by installing the package with all the dependencies, using:
install.packages("dplyr", dependencies = TRUE)
It will install others like lazyeval, knitr etc. Worked for me to solve the
Error in loadNamespace(name): there is no package called ‘lazyeval’ issue.
This question already has answers here:
Error: could not find function ... in R
(10 answers)
Closed 8 years ago.
I am using R:
library(qpcR)
final<-cbind.na(datum_seq, amb.temp)
Error: could not find function "cbind.na"
I have looked on the internet, and it suggests that I need to have the up to date version of R and qpcr package.
Confirmed in the sessionInfo(), I have the latest version. Could there another reason why it cannot find the function?
R version 3.1.2 (2014-10-31)
Platform: i386-w64-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] plyr_1.8.1 qpcR_1.4-0 Matrix_1.1-4 robustbase_0.92-3 rgl_0.95.1201
[6] minpack.lm_1.1-8 MASS_7.3-35
loaded via a namespace (and not attached):
[1] DEoptimR_1.0-2 grid_3.1.2 lattice_0.20-29 Rcpp_0.11.2 tools_3.1.2
cbind.na is an internal variable to the qpcR package. If you must call this function directly, you can do so using qpcR:::cbind.na.
See help(':::') for details on internal and external variables.
Before using this, note the following (from the help page):
"It is typically a design mistake to use ::: in your code since the corresponding object has probably been kept internal for a good reason. Consider contacting the package maintainer if you feel the need to access the object for anything but mere inspection."