Non-numeric argument to mathematical function

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])

Leave a Comment