R could not find function "checkAtAssignment" while running rworldmap - r

I need your help with R not being able to run a function with rworldmap package.
When using rworldmap package in R and trying to 'joinCountryData2Map'
sPDF <- joinCountryData2Map (myframe, joinCode = "NAME", nameJoinColumn = "location", verbose = TRUE, suggestForFailedCodes = TRUE )
I get the following error:
Error in mapWithData#data <- cbind(mapWithData#data, dF[matchPosnsInUserData, :
could not find function "checkAtAssignment"
Calls: joinCountryData2Map
Execution halted
My guess is that R needs methods package, which I could not find for my R version.
Any suggestings why I 'could not find function "checkAtAssignment"'?
My R version is 3.0.2 Patched.

Using rworldmap package requires loading library(methods). I am writing it here because it was really not obvious.

Dunno what "R 3.0.2 Patched" means, but yes you are correct that somehow you don't have the methods package, which is included in the standard installation package. How about reinstalling R from the binaries or source tarball at CRAN -- that should solve your problem.

Related

How to use function "get_data_structure"

I try to use the function "get_data_structure" but got an error as below.
Could anyone know how to fix it?
Thank you in advance
get_data_structure("DUR_D")
Error in data.frame(data_structure#concepts) :
trying to get slot "concepts" from an object (class "data.frame") that is not an S4 object
The problem appears to be a bug in the version of the OECD package on CRAN. If you install the development version, it works. First, close R and reopen a clean new session, then run this:
remotes::install_github("https://github.com/expersso/OECD")
library(OECD)
get_datasets()
get_data_structure("DUR_D")
remotes::install_github("https://github.com/expersso/OECD")
library(OECD)
dataset <- "DUR_D"
dstruc <- get_data_structure(dataset)
Try with get_dataset("DUR_D") i.e. without -s. as get_datasets() with -s will return a dataframe of available datasets.
It is a bug in the package OECD 0.2.5.
It works with the package version 0.2.4 which you can install from CRAN's archived package section (https://cran.r-project.org/src/contrib/Archive/OECD).
If you want to access the archived package version directly in R, use the following code:
devtools::install_version("OECD", version = "0.2.4", repos = "https://stat.ethz.ch/CRAN/")
Note that this requires the package 'devtools' to be installed.

how to add new R packages in azure machine learning for time series anomaly detection

I am trying to find out time series anomaly detection in which i need to install new R packages. In this i m following https://github.com/business-science/anomalize site. In this i needed to install 2 packages: tidyverse and anomalize.
can anyone help me on installing package mentioned above as I am getting
error "package or namespace load failed for tidyverse"
Also while adding zip of tidyverse and anomalize do I need to add any other packages and dependencies in that as I am adding only those 2 packages thinking there r no other dependencies I needed for those 2?
you can see in code that I created R_Package.zip and put tidyverse.zip and anomalize.zip in that that
dataset1 <- maml.mapInputPort(1)
data.set <- data.frame(installed.packages())
#install.packages(“src/R_Package/tidyverse_1.2.1.zip”, lib = “.”,
repos = NULL, verbose = TRUE);
#library(tidyverse, lib.loc=”.”, verbose=TRUE);
install.packages("src/tidyverse.zip",lib=".",repos=NULL,verbose=TRUE)
library(R_package, lib.loc = ".", verbose=TRUE);
install.packages("src/anomalize.zip",lib=".",repos=NULL,verbose=TRUE)
library(R_package, lib.loc = ".", verbose=TRUE);
#success <- library("tidyverse", lib.loc = ".",
logical.return = TRUE, verbose = TRUE)
#library(tidyverse)
maml.mapOutputPort("dataset1");
Regarding the error message, notice that it may take some time for the installed packages to become actually available; quoting from Adding R Packages In Azure ML blog post:
Note: In one instance, we ran into an issue where the package was not
loaded into the workspace immediately. We had to wait about half an
hour before we could use the package. You may be running into this
issue as well if you see a message that looks something like this
and you’ve used the above method to check which packages are in your
workspace and the package in question appears on that list. If this is
the case, we suggest waiting a bit before running your experiment
again.
AFAIK yes, you also need to add the package dependencies; the SO thread Install R Packages in Azure ML contains some useful hints.

Canonical correlation analysis with ade4

Was the cca function deprecated in R's ade4 package?
library(ade4)
cca(mammals, environment)
outputs
could not find function "cca"
I can't find any documentation on this error.
There is no cca function in ade4 package version 1.7-10. However, you can use cancor from base R like below
pop <- LifeCycleSavings[, 2:3]
oec <- LifeCycleSavings[, -(2:3)]
cancor(pop, oec)
Edited
Install version 1.7-4 using the following code
library(devtools)
install_version("ade4", version = "1.7-4", repos = "http://cran.us.r-project.org")
and then run
library(ade4)
May be is not available for the newest versions of the package. Nevertheless it is suggested to use cca{vegan}, which is form the vegan library.

Sentiment analysis in R (not using tm.plugin.tags)

I'm using R version 3.0.2 and have installed the package tm. Previously, I also loaded a package called tm.plugin.tags. To get a measure of whether a text corpus was positive or negative I used the following approach:
library('tm')
library('tm.plugin.tags')
pos <- tm_tag_score(TermDocumentMatrix(corpus, control = list(removePunctuation = TRUE)), tm_get_tags("Positiv"))
tm.plugin.tags seems to be no longer available for R. This was based on the following classification system http://www.wjh.harvard.edu/~inquirer/homecat.htm and I'm wondering if there is any other package or approach that I can use to achieve a similar result.
I have emailed the package maintainer of tm so I will post an update here once/if I receive a response.
You can install tm.plugin.tags using the following command
install.packages("tm.plugin.tags", repos = "http://datacube.wu.ac.at", type = "source")
This installs without any problem
Thanks
Cheers

R function call without loading package

I want to use functions from the Bioconductor packages hypergraph and hyperdraw without loading the packages. When running an example from the hyperdraw vignette
dh1 <- hypergraph::DirectedHyperedge("A", "B", "R1")
dh2 <- hypergraph::DirectedHyperedge(c("A", "B"), c("C", "D"), "R2")
hg <- hypergraph::Hypergraph(LETTERS[1:5], list(dh1, dh2))
hgbph <- hyperdraw::graphBPH(hg)
I get the error:
Error in hyperdraw::graphBPH(hg) : could not find function "hyperedges"
If I try to load hyperedges:
hyperedges <- hyperdraw:::hyperedges
I get the error
Error in get(name, envir = asNamespace(pkg), inherits = FALSE) :
object 'hyperedges' not found
When I load both packages using library or require, I get no error (in running the above code without hypergraph:: and hyperdraw::).
The reason why I do not want to load the packages is because I am building a package which uses hyperdraw and hypergraph in only one function and I'd rather put these packages into Suggests than into Depends in my DESCRPTION file.
Does anyone have an idea how to solve this?
hyperdraw has this in it's DESCRIPTION file
Depends: R (>= 2.9.0), methods, grid, graph, hypergraph, Rgraphviz
and it's relying on finding hypergraph::hyperedges on the search() path. Personally, I think hyperdraw should include a line
importFrom(hypergraph, hyperedges)
in it's NAMESPACE file. Currently, the best thing to do is to add Depends: hyperdraw to your DESCRIPTION file, and to importFrom(hyperdraw, <whatever functions you need>). I have contacted the maintainer of hyperdraw to ask them to update the NAMESPACE as above; you could then merely Imports: hyperdraw. I think you're just making work for yourself and frustrating your users by trying to use Suggests or other approaches to subvert the need for formal dependencies.

Resources