Error in clusplot function - r

I am playing with cluster analysis in R and I would like to plot the cluster:
teste<-data.frame(v1=rnorm(100),v2=rexp(100),v3=runif(100) )
fit.c<- kmeans(teste,2)
aggregate(teste,by=list(fit.c$cluster),FUN=mean)
clusplot(teste, fit.c$cluster, color=TRUE, shade=TRUE,labels=2, lines=0)
But it gives me this error:
Error in clusplot.default(teste, fit.c$cluster, color = TRUE, shade = TRUE, :
4 arguments passed to .Internal(nchar) which requires 3
Does anyone know what is happening?
Thank you

I ran your code and got no problems. I am guessing that there is a version mismatch between your R and the packages you are using. Can you make sure that your cluster package is up to date (and any other packages you are using for that matter), and/or update to the latest version of R?
If that doesn't work, can you add the sessionInfo() information? That is often helpful for diagnosing these sorts of problems.

Related

Error when using ggstatsplot - Error in 'mutate()': Caused by error in vapply()':

Just installed ggstatsplot and tried running the Example in the Documentation to just see what inputs it requires and how to manipulate the function.
library(ggstatsplot)
ggbetweenstats(mtcars, am, mpg)
I was immediately met with the error:
Error in `mutate()`:
! Problem while computing `n_label = paste0(am, "\n(n = ", .prettyNum(n), ")")`.
Caused by error in `vapply()`:
! values must be length 1,
but FUN(X[[1]]) result is length 3
I have tried multiple examples I found online of how to use the package and all result in the same error. I also tried ggwithinstats and received the same error. I updated all of my packages and have restarted R Studio at each step.
Any help would be appreciated, please let me know if I can provide any other information.
Sorry for the troubles.
This is due to update to insight package (https://github.com/IndrajeetPatil/ggstatsplot/issues/749).
EDIT on 21 May 22:
Both statsExpressions and ggstatsplot updates are now on CRAN, so all these issues should go away.
I get the exact same error.
#for reproducibility and data
set.seed(123)
library(WRS2)
library(ggstatsplot)
ggwithinstats(
data = bugs_long,
x = condition,
y = desire
)
May it is a bug?

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.

Index error when running maxnet function (maxnet package)

I use the maxnet function (maxnet package) as one of the model algorithms in an ensemble model. Sometimes, the code executes without an error. Other times, it gives me the error message you see below. I am working on a windows 10 Pro (R version 3.6.1, Rstudio version 1.2.5042).
Code:
dm.Maxent <- maxnet(p = train$species, data = train[-train$species],
maxnet.formula(p = train$species,
data = train[-train$species],
classes = "default"))
Error:
Error in intI(j, n = x#Dim[2], dn[[2]], give.dn = FALSE) :
index larger than maximal 185
train is a dataframe with 621 rows (one row for every occurrence/absence point), and 29 columns (28 columns containing variables and 1 column "species" that indicates presence or absence of the species (0/1)).
I am having the same issue. It is unpredictable, since for several species it ran fine, then out of a sudden it stopped.
I found a response on this link: https://github.com/jamiemkass/ENMeval/issues/62
In the new version of maxnet (check the Github repo, as it looks like the CRAN version gas not been updated yet), there is a new argument "addsamplestobackground". When set to TRUE, it solves some of these errors. Currently, you will have to use install_github to reinstall maxnet to use this argument. Once you do, install_github to get the dev branch version of ENMeval (v2), which will implement this by default. Hopefully that fixes these problems.
I reinstalled maxnet from github :
install.packages("remotes")
remotes::install_github("mrmaxent/maxnet")
and set addsamplestobackground = T Maybe this would help you.

Error: could not find function "makeLearner" using h2o package

I'm using h2o package and trying to create a learner using the below given code
install.packages("h2o")
library("h2o")
h2o.learner <- makeLearner("regr.h2o.deeplearning",predict.type = "response")
But I'm getting this error
> h2o.learner <- makeLearner("regr.h2o.deeplearning",predict.type = "response")
Error: could not find function "makeLearner"
Note: Few months back I used this code without any problem.
Any idea what could be possible thing for this error?
The correct code for this is simply
library(mlr)
h2o.learner = makeLearner("regr.h2o.deeplearning")
The makeLearner() is not part of H2O. It appears to be part of the mlr package. It also seems that mlr does have h2o support, so it might be as simple as adding a library(mlr) to the top of your script? (Making sure that the mlr package has been installed, already, of course.)

R '.doSnowGlobals' not found

I am working with the package random uniform Forest. I am trying to run the examples provided in the documentation:
data(iris)
XY = iris
p = ncol(XY)
X = XY[,-p]
Y = XY[,p]
iris.ruf = randomUniformForest(Species ~., XY, threads = 1)
But I get this error:
Error in checkForRemoteErrors(lapply(cl, recvResult)) :
7 nodes produced errors; first error: object '.doSnowGlobals' not found
I googled and found that this is because it is trying to use paralell computing and it does not find something it needs. I have never used paralell computing so I did not understand the explanations I have found and I do not know how to fix this problem. I also read "error: object '.doSnowGlobals' not found?".
According to the manual using "threads = 1" deactivated paralell computing, but I get the error anyways.
I have also checked and the packages paralell and doParallel are loaded.
I do not really need paralell computing and I do not know if I am "connected" to other computers, so I am not sure If that would even work. Would there be an easy way do deactivate paralell computing? Or another alternative for making this work?
The cause of the problem was that I was working on my university computer for which I do not have administrator rights. The randomUniformForest package makes use of parallel processing which uses the IP protocol (even when only one thread is used).
I tried the package on my private computer and it worked fine.

Resources