Lazyeval over-writing dplyr? - r

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.

Related

Install.packages("ggplot2") installing older version (1.0.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.

Using addPosLimit and osMaxPos throws "error in PosLimit[, "MaxPos"] : incorrect number of dimensions"

Even if I copy paste example from blog.fosstrading.com/2011/08/tactical-asset-allocation-using.html I get this error:
error in PosLimit[, "MaxPos"] : incorrect number of dimensions
Is this a bug or am I missing something?
Output from sessionInfo():
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
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] dplyr_0.4.3 quantstrat_0.9.1687 foreach_1.4.2
[4] blotter_0.9.1695 PerformanceAnalytics_1.4.3662 FinancialInstrument_1.2.0
[7] quantmod_0.4-5 TTR_0.23-0 xts_0.9-7
[10] zoo_1.7-12
loaded via a namespace (and not attached):
[1] Rcpp_0.12.1 lattice_0.20-33 codetools_0.2-14 assertthat_0.1 grid_3.2.2
[6] R6_2.1.1 DBI_0.3.1 magrittr_1.5 iterators_1.0.7 tools_3.2.2
[11] parallel_3.2.2
You have dplyr loaded. It defines a lag function that masks the generic function, stats::lag. dplyr::lag does not do any method dispatch, so there's a lag method somewhere that isn't being called when it should be.
dplyr also masks the first and last generics defined in xts, which may also cause problems.
A short-term work-around is to call library(dplyr) first, so first and last in xts will mask their couterparts in dplyr. The long-term solution is that all packages should explicitly import all functions they use to avoid issues caused by the sequence in which packages are loaded/attached (note that user's non-packaged code will still be affected by package load/attach order).

Can not install shinyTable successfully

I followed the instruction on the Github. It returned me an error like this:
install_github("shinyTable", "trestletech")
Downloading github repo trestletech/shinyTable#master
Error in curl::curl_fetch_memory(url, handle = handle) :
Timeout was reached
In addition: Warning message:
Username parameter is deprecated. Please use trestletech/shinyTable
Then, I tried to download the repo zip file and installed the shinyTable from local zip file in R studio. After that, I library(shinyTable). It return me an error.
> install.packages("D:/UserData/xxxx/Downloads/shinyTable-master.zip", repos = NULL)
Installing package into ‘D:/UserData/xxxx/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
> library(shinyTable)
Error in library(shinyTable) : there is no package called ‘shinyTable’
This is sessionInfo() result:
R version 3.2.1 (2015-06-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
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] shinyRGL_0.1.0 devtools_1.8.0 rJava_0.9-7
loaded via a namespace (and not attached):
[1] rgl_0.95.1247 Rcpp_0.12.0 digest_0.6.8 mime_0.3 R6_2.1.0 xtable_1.7-4 git2r_0.10.1
[8] magrittr_1.5 httr_1.0.0 stringi_0.5-5 curl_0.9.2 xml2_0.1.1 tools_3.2.1 stringr_1.0.0
[15] shiny_0.12.2 httpuv_1.3.3 rversions_1.0.2 htmltools_0.2.6 tcltk_3.2.1 memoise_0.2.1
Does anyone know the reason and tell me how to install it? Thank you.
I had similar issues recently. Can you try this:
library(devtools)
install_git("https://github.com/trestletech/shinyTable")

R cannot load package forecast due to namespace error

I tried installing all the dependant packages and also tried another repo source as recommended in another post here.
R version 3.2.0 x64
install.packages("fracdiff")
install.packages("Rcpp")
install.packages("RcppArmadillo")
install.packages("colorspace")
install.packages("forecast", dep=T)
install.packages("forecast", repos=c("http://cran.rstudio.com"),dep=T)
library("forecast")
then I get
Loading required package: zoo
Attaching package: ‘zoo’
The following objects are masked from ‘package:base’:
as.Date, as.Date.numeric
Loading required package: timeDate
Error : .onAttach failed in attachNamespace() for 'forecast', details:
call: fun(libname, pkgname)
error: 4 arguments passed to .Internal(nchar) which requires 3
In addition: Warning message:
package ‘forecast’ was built under R version 3.2.1
Error: package or namespace load failed for ‘forecast’
sessionInfo()
R version 3.2.0 (2015-04-16)
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 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] Hmisc_3.16-0 ggplot2_1.0.1 Formula_1.2-1 survival_2.38-1 lattice_0.20-31 zoo_1.7-12 timeSeries_3012.99 timeDate_3012.100
loaded via a namespace (and not attached):
[1] Rcpp_0.11.6 cluster_2.0.1 magrittr_1.5 MASS_7.3-41 splines_3.2.0 forecast_6.1 munsell_0.4.2
[8] colorspace_1.2-6 quadprog_1.5-5 stringr_1.0.0 plyr_1.8.3 tools_3.2.0 nnet_7.3-9 parallel_3.2.0
[15] gtable_0.1.2 latticeExtra_0.6-26 tseries_0.10-34 digest_0.6.8 gridExtra_0.9.1 RColorBrewer_1.1-2 reshape2_1.4.1
[22] acepack_1.3-3.3 rpart_4.1-9 fracdiff_1.4-2 stringi_0.4-1 scales_0.2.5 foreign_0.8-63 proto_0.3-10
I tried to reproduce. I get no message about either loading timeDate or the error you see. I do get a message about loading pkg:zoo. The package loads and announces its version number. Try updating to R version 3.2.1, since that is where a new argument to nchar was introduced:
new$Text[ grep("nchar", news$Text) ]
• nchar(x, *) and nzchar(x) gain a new argument keepNA which governs how the result for NAs in x is determined. For the R 3.2.x series, the default remains FALSE which is fully back compatible. From R 3.3.0, the default will change to keepNA = NA and you are advised to consider this for code portability.

cryptic error message in testthat

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

Resources