Re: [R] Using "subset" in correlation analysis

From: Mark Lyman <>
Date: Wed, 19 Mar 2008 14:08:16 +0000 (UTC)

James J. Roper <jjroper <at>> writes:

> The correlation test function says that it can do a subset where one
> specifies the subsete vector. I cannot seem to get it to work.
> For example, the command line is:
> cor.test(adults$Alt, adults$Cab, alternative="greater", method="pearson")
> So, let´s say my subset vector is "Sex". How would I state the command
> to get the test of that subset?
> Thanks in advance.
> Jim

The subset argument only applies to the formula method. It should be a boolean vector something like the following (assuming adults is a data frame):

cor.test(~ Alt + Cab, adults, Sex=="MALE", alternative="greater", method="pearson") mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Wed 19 Mar 2008 - 14:11:08 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 19 Mar 2008 - 15:30:22 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive