Hi,
I was wondering if I could create a subset of an existing dataframe
based on a vector.
I have a dataframe (y) with 124 variables and I'd like to create a
subset of this dataframe by selecting a number of "factors" of the
variable "HOSP".
The "factors" I wish to use in the subset can be found in a vector x.
I've tried to do the following but it didn't work properly
subset(y,"HOSP==x",save.name="Z")
Because the vector x contains e.g 2 "factors" the above formulae
returned
an indexed result. Every even row contained the first factor and every
uneven row contained the second factor.
This was not the result I expected to have. I would like to have all the
values for the two factors. What am I doing wrong?
Thx for your help
Using S-Plus 6.2 for Windows.
-----Original Message-----
From: s-news-owner@lists.biostat.wustl.edu
[mailto:s-news-owner@lists.biostat.wustl.edu] On Behalf Of Richard M.
Heiberger
Sent: 10 June 2005 22:31
To: Leeds, Mark; s-news@lists.biostat.wustl.edu
Cc: cspark@clemson.edu
Subject: Re: [S] another vector question
> x <- sample(12)
> x
[1] 10 5 3 1 9 11 8 2 12 6 4 7
> which(x>9)
[1] 1 6 9
> ii <- 5:7
> ii
[1] 5 6 7
> which(x[ii] > 9)
[1] 2
> jj <- which(x > 9)
> jj
[1] 1 6 9
> ii[which(x[ii] > 9)]
[1] 6
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu. To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message: unsubscribe s-news
|