Non-numeric argument to mathematical function
cluster-analysis, p-value, r
Solution
You are trying to pass a dataframe to a function that is requesting a numeric vector:
> is.numeric(iris[,-5])
[1] FALSE
> str(iris[,-5])
'data.frame': 150 obs. of 4 variables:
$ Sepal.Length: num -0.898 -1.139 -1.381 -1.501 -1.018 ...
$ Sepal.Width : num 1.0156 -0.1315 0.3273 0.0979 1.245 ...
$ Petal.Length: num -1.34 -1.34 -1.39 -1.28 -1.34 ...
$ Petal.Width : num -1.31 -1.31 -1.31 -1.31 -1.31 ...
Try passing just a single column, like:
pnorm(iris[,1])
Problem
I want to get pvalues from a data set. I have not had any problems to use pnorm, but I have now. ``` data(iris) iris[,-5]<- scale(as.matrix(iris[,-5])) # K-Means Cluster Analysis fit <- kmeans(iris[,-5], 5) # 5 cluster solution # get cluster means aggregate(iris[,-5],by=list(fit$cluster),FUN=mean) # append cluster assignment mydata <- data.frame(iris, fit$cluster) pval<- pnorm(iris[,-5]) ``` After this, I get message of "Error in pnorm(q, mean, sd, lower.tail, log.p) : Non-numeric argument to mathematical function". What is the problem? I do not understand why this is happening. Please let me know.