[R] producing a QQ plot.
Joshua Wiley
jwiley.psych at gmail.com
Sat Mar 27 11:00:56 CET 2010
Dear Philip,
It is difficult to tell what is wrong without a reproducible example.
It would be very helpful if you would provide sample data. That said,
the most obvious issue from what you have provided is that some of
your data is character. mean() and var() will not work with character
data. It needs to be numeric or coercible to numeric. I would try
specifically excluding the character data (e.g., data[,3:5] from what
I can make out).
HTH,
Josh
On Sat, Mar 27, 2010 at 2:45 AM, Philip Wong <tomb_fighter at hotmail.com> wrote:
>
> Hello everyone I'm a beginner in Stats and R, I'm using R 2.10.1. I need to
> create a multivariate qq plot, there is 8 variable group with each has 55
> number of input. An example of what I did so far, just to get my point out:
>> data=read.csv(file.choose(),header=T)
>> data
> country village group av_expen P2ary_ed no_fisher
> 1 Cook Islands Aitutaki D 5239.12747 0.6666667 666.99986
> 2 Cook Islands Mangaia C 4587.36188 0.6021505 207.69228
> 3 Cook Islands Palmerston B 7784.31874 0.1666667 24.00000
> ...
> 53 Wallis And Futuna All Futuna D 11023.30674 0.2789855 1056.63143
> 54 Wallis And Futuna Halalo B 8783.54979 0.2794118 153.51715
> 55 Wallis And Futuna Vailala A 12231.95400 0.2395833 100.00000
>
> The problem I'm having starts now. I use the following command trying to
> work out the mahalanobis before plotting the QQ plot, but the following
> error is prompt:
>> mah=mahalanobis(data,apply(data,2,mean),var(data))
> Error in FUN(x, aperm(array(STATS, dims[perm]), order(perm)), ...) :
> non-numeric argument to binary operator
> In addition: Warning messages:
> 1: In mean.default(newX[, i], ...) :
> argument is not numeric or logical: returning NA
> 2: In mean.default(newX[, i], ...) :
> argument is not numeric or logical: returning NA
> 3: In mean.default(newX[, i], ...) :
> argument is not numeric or logical: returning NA
> 4: In mean.default(newX[, i], ...) :
> argument is not numeric or logical: returning NA
> 5: In mean.default(newX[, i], ...) :
> argument is not numeric or logical: returning NA
> 6: In mean.default(newX[, i], ...) :
> argument is not numeric or logical: returning NA
> 7: In mean.default(newX[, i], ...) :
> argument is not numeric or logical: returning NA
> 8: In mean.default(newX[, i], ...) :
> argument is not numeric or logical: returning NA
> 9: In mean.default(newX[, i], ...) :
> argument is not numeric or logical: returning NA
> 10: In mean.default(newX[, i], ...) :
> argument is not numeric or logical: returning NA
>
> Then I thought to myself, maybe the error I got the wrong input for
> variable. So I adjust the variable to see is my assumption was correct to
> the command below, but I still got the same error:
>> mah=mahalanobis(data,apply(data,2,mean),var(no_fisher))
>
> I absolutely got no clue where I got wrong and don't know how to fix it.
> Anyways I thought to myself, no worries I don't use mahalanobis then I'll
> still try the QQ plot and see what happen. This is the command and the
> error I got from it:
> qqplot(qchisq(ppoints(data),ncol(data),data)
> Error in qchisq(p, df, lower.tail, log.p) :
> Non-numeric argument to mathematical function
>
> --
> View this message in context: http://n4.nabble.com/producing-a-QQ-plot-tp1693228p1693228.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.com/
More information about the R-help
mailing list