fetchData function no longer in mosaic package - r

I am using R 3.2.2 and installed the mosaic package. I then used the fetchData function as follows:
data<-fetchData(1,c("Web_scraping","Data_mining"))
I get the following error:
Error: Use fetchData() from the `fetch' package instead.
When I try to install the fetch package, an error says:
Warning in install.packages :
package ‘fetch’ is not available (for R version 3.2.2)
I found documentation that the mosaic package was dropping fetchData in R 3.2.2, but couldn't find what package I should use to run the function properly.

Fetch
It appears that the fetch package is currently available via GitHub at https://github.com/ProjectMOSAIC/fetch.
Installation
To install fetch from GitHub:
Open up your R console
Install devtools (if not already installed) with this command*:
install.packages("devtools")
Type y if going through the devtools installer
Install fetch with this command:
devtools::install_github("ProjectMOSAIC/fetch")
Basic Usage
If successful, fetch should be accessible by requiring the fetch package
require("ProjectMOSAIC/fetch")
and calling fetchData() like this:
data <- fetch::fetchData( ... )
* Note: According to Etienne Low-Décarie, you'll need to have the make command available on your system before running the install.packages("devtools") command.

My students have been running into this problem trying to use the textbook code from Statistical Modeling: A Fresh Approach, this semester. I'm not familiar with the syntax used in the original question (with the number as the first argument), but this does not appear to be supported syntax in the fetch::fetchData() function. The workflow that we have been using to get around this (slightly simpler than summea's answer) is:
install.packages("devtools")
devtools::install_github("ProjectMOSAIC/fetch")
data <- fetch::fetchData("whickham.csv")
Note that I cannot reproduce the example in the original question, as I get different error/warning messages:
data<-fetch::fetchData(1,c("Web_scraping","Data_mining"))
With this as the error/warning:
Error in if (show.path) return(get("path", envir = .fetchEnvironment)) :
argument is not interpretable as logical
In addition: Warning message:
In if (show.path) return(get("path", envir = .fetchEnvironment)) :
the condition has length > 1 and only the first element will be used
I hope fetch is on its way to being on CRAN, and listed as a dependency of mosaic, as this is currently causing headaches in my class.

Related

Can't get rpart to run

I'm trying to re-run some code that worked well previously. When I enter my code, I get this error:
could not find function rpart
However, when I run the find.package function, I have it:
[1] "C:/Users/maltm/Documents/R/win-library/4.0/rpart"
I also get this warning:
package ‘rpart’ was built under R version 4.0.5
It also tells me I need the stats package, which the find.package function tells me I have. Here's the error message for that:
Error: package ‘stats’ could not be loaded`
In addition: Warning message:
package ‘rpart’ was built under R version 4.0.5
Warning: namespace ‘stats’ is not available and has been replaced
by .GlobalEnv when processing object ‘<unknown>’
I just reinstalled R and have the latest version (2021.09.0,Build 351; check for updates tells me I have the latest version), so am not sure what to do here. Thanks in advance for any guidance.

Created package 'not available'

I used RStudio to create an R package ('cryptArith'). The build went fine and all relevant R files are present and functional (checked independently). When I try to load the package and use the functions I get this:
install.packages('cryptArith')
Warning message:
package ‘cryptArith’ is not available (for R version 4.0.2)
I have been unable to find any information about the source of this error.

How to update function code in an R package?

I have created and downloaded an R package using roxygen2 development tools. When I update the source code R files, the documentation updates fine, but the function code itself does not. How do I get the function code to update when I reinstall the package with install.packages("package-name")?
I have tried inserting error messages at the beginning of every function using stop("..."). When I reinstall the code, the functions do not output an error message as they should but work as they did before I updated the code.
Each time I update the code, I use the following commands:
devtools::document()
devtools::install()
install.packages("package-name", repos=NULL, type="source")
library(package-name)
Just for further information, when I try to install the package this way:
install.packages("package-name")
I get the following error message:
Warning in install.packages :
package ‘package-name’ is not available (for R version 3.6.0)
I got this same error message when my R version was 3.6.0, and even now after updating to 3.6.1
I have not uploaded the package to any repositories, so I figured this makes sense, and instead install it locally from my package files with repos=NULL.
#' Roxygen comments - this part updates
#'
#' etc.
functionName <- function(...) {
stop("...")
...
# This function should crash with an error message every time it is called,
# but instead the function body is never updated.
}
Upon reinstalling the package, I expect the output of my functions to be an error message, but instead, they output the same result as they did before I updated the package.
Documentation updates, function bodies do not.
So it turns out I found an answer to my own question...
The problem was with a warning message I was getting:
Warning message:
In body(fun) : argument is not a function
Despite not ever using body(), this function was getting called internally somewhere, and the warning prevented the code from being updated (but the documentation still updates, for some reason).
Clearing my global environment with rm(list=ls()) cleared my error.

Why do I get a syntax error in devtools::install_github?

I am new in working with linux. I am trying to analyse sequencing data using dropEst pipeline https://github.com/hms-dbmi/dropEst#dropreport. I want to run the DropReport and for that I need to install dropEstR package.
I tried by :
devtools::install_github('hms-dbmi/dropEst/dropestr' , dependencies = T)
as they suggest and I get as an error:
bash: syntax error near unexpected token
`'hms-dbmi/dropEst/dropestr','
Do you have any idea what should I do differently?
I think you are using the "wrong" shell. You have to use R/RStudio, when you want to use the devtools package. From CRAN:
Title Tools to Make Developing R Packages Easier
I just tried you command in RStudio but installation fails in the end:
ERROR: dependency 'Rcpp' is not available for package 'dropestr'
* removing 'C:/R/R-3.4.2/library/dropestr'
Installation failed: Command failed (1)
You have to run such script on RStudio for R. Import your project here and run it.
You can download it from enter link description here
Happy Coding.

Error in caretTheme() : could not find function "caretTheme"

Can somebody point me in the right direction here, I am using the caret package and I am trying to run a caretTheme but it keeps returning the error:
Error in caretTheme() : could not find function "caretTheme"
I tried install.packages('caretTheme') and receive the error
"Warning in install.packages :
package ‘caretTheme’ is not available (for R version 3.4.1 Patched)"
I have searched on github and cannot find the package listed there or am I able to find it onlinee to bruteforce install using devtools::
Can you find the package available for download anywhere?
Try installing developmental version:
devtools::install_github("topepo/caret/pkg/caret")
library(caret)
exists("caretTheme")
[1] TRUE
sessionInfo()$otherPkgs$caret$Version
"6.0-77"

Resources