How to fix 'could not find function mvOutlier' in R - r

I am trying to remove outliers from my dataset using the mvOutliers function in MVN in R. However, upon executing the program, I get the error, could not find function "mvOutlier".
I have installed all the packages from MVN to mvoutlier. I have also imported MVN but also tried importing mvoutlier but still I am getting the same error.
I am using the following code for outlier removal
library(MVN)
M <- mvOutlier(data, method = "quan", label = TRUE)
Comb_Data=M$newData
I expect the Comb_Data to contain the outlier free dataset but all I am getting is the error:
Error in mvOutlier(dat, method = "quan", label = TRUE) : could not
find function "mvOutlier"
Any help in this matter would be appreciated.

Related

DartR - Error in FUN(X[[i]], ...) : only defined on a data frame with all numeric variables

I am very much a novice with R and am attempting to run a script that will filter a set of SNPs for 6 populations. I've successfully run this script before but I'm getting a new error in the initial stages of the script.
I've not been able to find anything similar to my issue online, though a few have the same error. The error comes up when R is trying to read in the SNP data and the function and error are as follows from the console screen:
>FijiHomaGL <- gl.read.dart(filename = "genCSV_modified.csv", ind.metafile = "COV_file.csv",
+ nas = "-", topskip = 6, lastmetric = TRUE, probar = TRUE)
Starting gl.read.dart
Starting utils.read.dart
Reading in the SNP data
Error in FUN(X[[i]], ...) :
only defined on a data frame with all numeric variables
A screenshot of the .csv file I'm trying to run
I'm not able to include the actual file but a screenshot is linked above for a general idea of the layout.
Any help is much appreciated I am very new so let me know if there is anything else I should include! Thanks in advance. The package being used for this function is dartR but I can't add it as a tag.

BiodiversityR::accumcomp.long function not found

I am trying to use the function accumcomp.long in the Biodiversity.R package in order to adjust my species accumulation curves in ggplot.
However, calling the function accumcomp.long gives me an error, suggesting that this function perhaps does no longer exists.
accum.long1 <- accumcomp.long(Accum.1, ci=NA, label.freq=5)
Error in accumcomp.long(Accum.1, ci = NA, label.freq = 5) :
could not find function "accumcomp.long"
The function BiodiversityR::accumcomp.long
returns
Error: 'accumcomp.long' is not an exported object from 'namespace:BiodiversityR'
I am not certain whether this is an issue with the package, the way the package is loaded into my R space, or perhaps unrelated to the package simply the format of my data.
My community and environment files are of dataframe class. I have tried loading them as .csv files as well as .rda files, but the error remains.
??accumcomp.long
renders "No results found".
I am using R version 3.5.3 (2019-03-11)
Any suggestions as to what else I could try?
Thanks in advance!
I re-installed the package BiodiversityR and included force = T (as per this thread https://community.rstudio.com/t/could-not-find-function-error-even-though-fun-is-in-namespace-and-has-an-rd-file/91243). I then reloaded the package. I am not sure what force = T does, but the accumcomp.long function now works.

When using the function boxCox in R I keep getting this error "Error in as.data.frame.default(

I have the correct package alr4 which contains cars so it shouldn't be a problem with the function itself
box <- lm(Distance~Speed, data = stop)
boxCox(box)
This is the error
Error in as.data.frame.default(data, optional = TRUE) : cannot coerce class ‘"function"’ to a data.frame
The lm function runs just fine on its own, and I have used it in other analysis just fine, so it isn't an issue there. I am mostly just confused about the error and how to fix it. If you have suggestions or know why it happens that would be appreciated! Thanks

How to fix the error "argument "modelName" is missing, with no default" when using MVN package

I am using the MVN package, in R, to find whether each class of the dataset iris is multivariate normal or not.
I used the below code earlier in the day and generated results from it. However, I went to revisit it and now keep getting the following error message:
Error in mvn(data = iris[Species == m[1], 1:4], mvnTest = c("mardia")) :
argument "modelName" is missing, with no default
Can not figure out what this means and how to fix it !
Code:
#Mardia's Test
SM<-mvn(data=iris,subset="Species", mvnTest="mardia")
SM$multivariateNormality
SetosaPlot<-mvn(data=iris, subset="Species", multivariatePlot="qq")
You loaded the mclust package. When you did so you should have seen a warning
The following object is masked from ‘package:MVN’: mvn
So now mvn() is calling mclust::mvn() (i.e. the mvn function in the mclust package) rather than MVN::mvn().
In general you can make sure you get the version from the MVN package by using
MVN::mvn(data=iris, subset="Species", multivariatePlot="qq")
If you want to know where R is finding mvn, try find("mvn")
In general, to resolve these kinds of problems you should start a clean R session, so that you know you're starting with no packages loaded.
(By the way, no real data set is ever truly multivariate normal; you're not testing "whether it is MVN or not", but rather whether it is close enough to MVN that you can't reject the null hypothesis of multivariate normality ...)

R programming language mmedist The moment function must be defined. fdistrplus package

I'm trying to fit a distribution to some data using the function fdist from the package fdistrplus.
I've started learning R recently and got a hold of this package that I thought could do everything I needed.
When trying to use it to fit to a pareto distribution, I had to input my definitions of the pareto distribution like so:
ppareto = function(x,alpha,theta){
(1-(theta/(x+theta))^alpha)*(x>=0)
}
dpareto = function(x,alpha,theta){
(alpha*theta^alpha*(x+theta)^(-alpha-1))*(x>=0)
}
rpareto = function(n,alpha,theta){
l = array(as.numeric(NA),n)
ltmp = runif(n,0,1)
l = teta/ltmp^(1/alpha)-theta
return(l)
}
When calling
fitdist(data,"pareto",method = "mme")
It said it could not find the "dpareto" function. That is resolved by the code above.
Afterwards it said it needed an order parameter and a empirical moment parameter.
It's my understanding that the order parameter is the vector of orders that I want the routine to use as it's basis for the calculation.
So I tried:
fitdist(data,"pareto",method="mme",order=c(1,2))
As I saw in the examples of the package pdf.
Then it complained that:
Error in mmedist(data, distname, start = start, fix.arg = fix.arg, ...) :
The moment function must be defined.
Okay, next step:
momentfunc = function(x,order){mean(x^order)}
To define the function.
Then I tried
fitdist(data,"pareto",method="mme",order=c(1,2),memp=momentfunc)
Error in mmedist(data, distname, start = start, fix.arg = fix.arg, ...) :
The moment function must be defined.
Then I tried:
fitdist(data,"pareto",method="mme",order=c(1,2),memp="momentfunc")
Error in mmedist(data, distname, start = start, fix.arg = fix.arg, ...) :
The moment function must be defined.
I've searched the web, found examples of the pareto dist and followed them step by step all to no avail...
I've searched stackoverflow and found nothing.
So here I am. If anyone could help me I would be much obliged.
Is it my dumb mistake? Is it a bug in the package?
I've tried this on Windows 7, R 3.1.0
and on MacOS, R 3.0.1 (where I get a warning that the package was built under R 3.0.2)
Thanks in advance
you have to install and load the 'actuar' package

Resources