Error in boxM function after installing package and invoking library successfully - r

Code:
install.packages("biotools")
library(biotools)
boxM(train1[,2:6],train1[,1])
Error:
Error in boxM(train1[, 2:6], train1[, 1]) : could not find function
"boxM"
The package has been installed successfully as per console. Even after checking the checkbox for enabling the library, getting the same issue.

You may try "heplots" package. It contains boxM function as well.

Related

Why am I getting this error when loading the redist package in R?

I've recently run into an error that I have not encountered before in RStudio. I'm currently using the newest version of R, 4.1.2. I've installed a package called "redist" and when I load the package in RStudio, I get the following error:
Error: package or namespace load failed for ‘redist’:
.onLoad failed in loadNamespace() for 'units', details:
call: udunits_init(path)
error: no database found!
The following code snippet ist what I used to install and run the package.
install.packages("redist", dependencies = TRUE)
library(installr)
I'm not really sure where to look for this error or how to fix this. Has anyone run into something similiar or does anyone have any advice on what to do?
Messing around with some things, I've come upon a solution that works, even though this may be related to the package itself.
Before loading the redist package, it's necessary to load the udunits2 package. Loading the library then works.

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.

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.

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"

fetchData function no longer in mosaic package

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.

Resources