Error while using function from car package - r

I'm trying to use a few functions from car package, but while when starting the function (e.g. scatterplotMatrix or bcPower) I get a message "could not find function "scatterplotMatrix""
I I removed and installed package, updated R Studio and I still have the same problem.
A few lines from my code:
d <- read.csv2("World.csv")
d1 <- d[,c(1,16,25,27,47,56,57,58,59,70)]
d1 <- d1[complete.cases(d1), ]
scatterplotMatrix(d1[,2:9],smooth = FALSE)
I get:
Error in scatterplotMatrix(d1[, 2:9], smooth = FALSE) :
could not find function "scatterplotMatrix"

Related

FW function in R is not working for my dataset

Hi I am trying to use the Finlay Wilkinson regression function FW in R for yield stability analysis. I tried running this, but am getting the below error
Error in FW(y = yield, VAR = genotype, ENV = location, method = "OLS")
: object 'genotype' not found
My data file has the headers 'yield', 'genotype' and 'location' on it. Not sure what I am doing wrong here, since I just followed the syntax from the original publication. Please help!
My code below:
crop <- read.csv("barleygt6.csv", header = TRUE)
summary(crop)
install.packages("devtools")
library(devtools)
install.packages("remotes")
remotes::install_github("lian0090/FW")
library(FW)
lm1=FW(y= yield, VAR= genotype, ENV= location, method="OLS")

Wavelet function: rewrite matlab wavelet code to R

I am having matlab code:
wt = modwt(datavalue,'db1',7);
I want to conver this code to R, which I have done in following manner:
wt = modwt(datavalue,wf = 'db2',n.levels = 7)
But this keeps giving me error
Error in modwt(datavalue, wf = "db2", n.levels = 7) :
unused argument (wf = "db2")
Also if I write the code like this
wt = modwt(datavalue,'db2',7)
It gives me the following error
Error in wt.filter(filter, modwt = TRUE) : Invalid filter name.
I am using the wavelet function and probably I am not able to understand the wavelet function in R.
Is this the right of of transforming the code to R or is there any other package in R that would be better than wavelet package
I'm not fully familiar with the MATLAB function modwt. However, you can try the R package waveslim, and the function modwt.
It looks the same, see the documentation.
require(waveslim)
data(ibm)
ibm.returns <- diff(log(ibm))
ibmrWave <- modwt(ibm.returns, wf = "la8", n.levels = 4)

R Leaps Package: Regsubsets - coef "Reordr" Fortran error

I'm using the R leaps package to obtain a fit to some data:
(My dataframe df contains a Y variable and 41 predictor variables)
require(leaps)
N=3
regsubsets(Y ~ ., data = df, nbest=1, nvmax=N+1,force.in="X", method = 'exhaustive')-> regfit
coef(regfit,id = N)
When I run the code more than once (the first time works fine) I get the following error when I run the coef command:
Error in .Fortran("REORDR", np = as.integer(object$np), nrbar = as.integer(object$nrbar), :
"reordr" not resolved from current namespace (leaps)
Any help with why this is happening would be much appreciated.
A.
I had to build the package from source inserting the (PACKAGE = 'leaps') argument into the REORDR function in the leaps.R file. It now works fine every time.
The solution is related to:
R: error message --- package error: "functionName" not resolved from current namespace

R: pwfdtest produces an error message even with the test data

In R using the plm package, pwfdtest produces an error message even with the test data:
pwfdtest(log(emp) ~ log(wage) + log(capital), data = EmplUK, h0 = "fe")
Error message:
"Error in order(nchar(cnames), decreasing = TRUE) : 4 arguments
passed to .Internal(nchar) which requires 3".
Bug or am I missing something?
I had a similar question myself with a similar test (linearHypothesis). Apparently the nchar function changed, so you need to install the newest version of R and then update all your packages.
After re-installing R,
update.packages(checkBuilt=TRUE, ask=FALSE)

Locked package namespace

I am using the "BMA" package in R 3.1.0, and get an error when running one of the functions in the package, iBMA.glm. When running the example in the package documentation:
## Not run:
############ iBMA.glm
library("MASS")
library("BMA")
data(birthwt)
y<- birthwt$lo
x<- data.frame(birthwt[,-1])
x$race<- as.factor(x$race)
x$ht<- (x$ht>=1)+0
x<- x[,-9]
x$smoke <- as.factor(x$smoke)
x$ptl<- as.factor(x$ptl)
x$ht <- as.factor(x$ht)
x$ui <- as.factor(x$ui)
### add 41 columns of noise
noise<- matrix(rnorm(41*nrow(x)), ncol=41)
colnames(noise)<- paste('noise', 1:41, sep='')
x<- cbind(x, noise)
iBMA.glm.out<- iBMA.glm( x, y, glm.family="binomial",
factor.type=FALSE, verbose = TRUE,
thresProbne0 = 5 )
summary(iBMA.glm.out)
I get the error:
Error in registerNames(names, package, ".__global__", add) :
The namespace for package "BMA" is locked; no changes in the global variables list may be made.
I get the error in RStudio running R 3.1.0 on Ubuntu.
on Windows 7, from RStudio and the R console I get a similar error:
Error in utils::globalVariables(c("nastyHack_glm.family", "nastyHack_x.df")) :
The namespace for package "BMA" is locked; no changes in the global variables list may be made.
I also get the same error when running my own data in the function. I'm not clear on what this error means and how to work around the error to be actually able to use the function. Any advice would be appreciated!

Resources