[R] shapiro-wilks test

Marc Schwartz MSchwartz at medanalytics.com
Fri Dec 21 21:11:05 CET 2001

> My data is in form of a table with 2 columns - colA, colB and
> I want to know if colB values are a normal distribution.
> First I read the data into R using
> d <- read.table("tab.dat",header=T)
> Then if I type
> shapiro.test(d)
> I get the error message:
> Error in "[.data.frame"(x, complete.cases(x)) :
>         undefined columns selected
> and if I type
> shapiro.test(d.colB)
> I get message:
> Error in inherits(x, "factor") : Object "d.colB" not found
> What is the correct syntax and how do I obtain this syntax
> from any help
> documentation ?

I believe that the problem that you are having is that in the first example,
you are trying to have the test performed on a data frame (data in the form
of rows and columns) rather than a data vector (a single column of data),
which is what the function requires.

In the second example, you need a different syntax to refer specifically to
"colB" as a data vector within your frame.

If you use the format:


it should work.

Note the use of the "$" to refer to the column within the frame.

You can type "help(shapiro.test)" to access the help for this particular
function.  You will note that the "x" argument in the function syntax is
defined as a numeric vector.

You can also access the general documentation via the Help menu or by typing
"help.start()". These options will provide you with access to the .PDF and
.HTML manuals and associated documentation to review some of the basic R
concepts and examples. You may wish to start with the "Introduction to R",
which covers the basics.



r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list