choroplethr sudden error in choro$render - r

very new to R, and this is my first question so please be kind :)
I was working with the choroplethr/choroplethrMaps/choroplethrZip packages for a few days without any issues, but suddenly, I keep getting the an error when I try to visualize a map--I have pasted the output below, and any help would be deeply appreciated.
The most perplexing issue for me is why it suddenly stopped working--I didn't add anything to the script--I get the same error with choroplethr/choroplethrMaps as well. Many thanks for your expertise and patience!
data(df_pop_zip)
choro = ZipChoropleth$new(df_pop_zip)
choro$title = "2012 ZCTA Population Estimates"
choro$ggplot_scale = scale_fill_brewer(name="Population", palette=2, drop=FALSE)
choro$set_zoom_zip(state_zoom="florida", county_zoom=NULL, msa_zoom=NULL, zip_zoom=NULL)
choro$render()
Error in FUN(X[[i]], ...) : attempt to apply non-function

I believe that your error can be solved by typing the following:
# install.packages("devtools")
library(devtools)
install_github("choroplethr", "arilamstein")
library(choroplethr)
If I install choroplethr from CRAN I can replicate your error. If I install it from github I can solve it. Note that the actual R code is currently the same in both github and CRAN, because I recently submitted a new version to CRAN.
When I load the version of choroplethr from CRAN I get this warning:
> library(choroplethr)
Warning message:
package ‘choroplethr’ was built under R version 3.2.4
However, the current version of R is 3.2.3. So it looks like CRAN is using different version of R for what they are distrbuting to the public and what they are using to build packages. I'm not sure why this is.
Note that while I think this solution will work for you, I don't find it particularly satisfying or elegant. I could probably install the development version of R to see if I can replicate (and debug) the issue myself. But at this point I'd rather wait until they officially release the new version to see if it is still present. I really don't have much experience with the development versions of R.

Related

Could not find LoadFile() even if a guide says it should exist, am I or the guide wrong? In R

I need to perform an analytic hierarchical process (AHP) on a dataset using R. I have basic understanding of navigation and can follow most guides to perform rudiment analyses. However, I'm not comfortable enough to be sure if I or the guide is wrong.
The guide I've followed is this: https://www.r-bloggers.com/analytic-hierarchy-process-ahp-with-the-ahp-package/.
(I run R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch")
1: I have (successfully) installed and loaded the AHP package using:
devtools::install_github("gluc/ahp", build_vignettes = install.packages("data.tree"))
2: I have (successfully) set working directory using:
setwd("myworkingdirectory")
3: I have attempted (PROBLEM) loaded the file to a variable using:
myahp <- LoadFile("myAHPfile.txt")
Error: could not find function "LoadFile"
3x: As diagnosis I run:
getAnywhere("LoadFile")
no object named ‘LoadFile’ was found
For your information: Step 3x is inspired by this SO answer (Error: could not find function ... in R)
Can someone tell me what I am doing wrong? I greatly appreciate any help.
Both. The guide refers to an old version of the gap package from github. With the latest version from cran (0.2.11), the function is now called Load, and the file format has changed.
If you just want to goof around with the package, I can recommend the online app at ipub.com.
If you insist on following the guide, make sure you get version 0.1.1 from github

Error: could not find function "forceAndCall" - outdated base package?

I would like to apply the function 'fit.tcopula' from the package 'QRM' - Quantitative Risk Management and get the following error message:
fit.tcopula(Udata, method = 'Kendall')
Error: could not find function "forceAndCall"
Since I have applied the 'Udata' to different copulas from the package 'copula' already - and it worked fine - I assume the input is not an issue.
To my understanding 'forceAndCall' is part of the base package. I use the R version 3.1.3.
According to the documentation the QRM package depends R(>=3.0.1), so my version should be OK. However, listing all functions of my base package with
library(help = 'base')
reveals that the forceAndCall-Function is not there. What would the remedy be? Installing R version 3.2.1?
The reason I ask and not just do it is that I do not possess admin rights for my PC and therefore would be happy to get an opinion beforehand.
I posted the question though I already have the answer as it might be interesting to others.
Upgrading to R version 3.2.1 is the/one solution to the problem!

Error: isTRUE(gpclibPermitStatus()) is not TRUE when using fortify function, rgdal package

I am trying to work with spatial data that I downloaded here in order to make a map in ggplot2.
library(rgdal)
library(ggplot2)
library(rgeos)
df <- readOGR(mydirectory, layer = 'gem_2013_v1')
df.fort <- fortify(df, region = "AANT_INW")
I keep on getting this error when using the function fortify:
Error: isTRUE(gpclibPermitStatus()) is not TRUE
Has anyone an idea about what's going wrong here? Most appreciated!
EDIT:
As mentioned in the comments a possible duplicate of this question can be found here. It is stated that the solution of the problem can be found in installing package gpclib. I am not sure if that's the case, this package has been removed from CRAN.
I had this issue after upgrading R. I reinstalled rgdal and all was good.
I had the same problem, I had to install gpclib. I'm not sure if when you made the update it was removed from CRAN, but it's there now. It must be installed from source so you'll have to use the following code:
install.packages("gpclib", type = "source")
Note that to install with this code you'll need to have the appropriate version of Rtools installed.

R Package tm.plugin.webmining does not work with R 3.1.0 (but does with R 2.1.5)

I am using R 3.1.0, along with the tm.plugin.webmining package (within RStudio). Packages are installed fine (along with all dependencies) and I can load the library.
When I try to run a basic test however:
yahoocorpus<-WebCorpus(YahooNewsSource("Microsoft"))
I get:
Error in get(name, envir = asNamespace(pkg), inherits = FALSE) :
object '.Source' not found
This does not occur if I point RStudio to R 2.1.5
I have looked online but not found any resolution of the issue (though somebody did suggest a hack of the source code). It would be great to understand exactly what is causing the problem (and what has changed between versions to make this happen (I also tried 3.0.1, and that also does not work)
Thanks again,
Alan
I think that function WebCorpus does not exist in last version of TM package. Check the doc here!
You have 3 possibilities : DirSource, VectorSource, or DataframeSource.
You can check the source on R with:
{r}
library(tm)
getSources()
Which should give you :
[1] "DataframeSource" "DirSource" "URISource" "VectorSource" "XMLSource"
Cyrille

R package Ecdat stopped working

Before (1 week ago) the R package Ecdat was working and I have not changed anything, now I've tried to re-install the package, to have a look on the directory installation and the version it access it, and still couldn't find any answer.
I have tried with both RStudio and R to manage the problem.
library("Ecdat", lib.loc="C:/Users/Melonfarmer Johnes/Documents/R/win-library/2.15")
plot(Capm[,"rmrf"],Capm[,"rcon"])
Error in plot(Capm[, "rmrf"], Capm[, "rcon"]) : object 'Capm' not found
I don't think this would have ever worked. The data instruction to load your Capm dataset is missing :
library(Ecdat)
data(Capm)
plot(...)

Resources