[R] data frames

Thomas Lumley tlumley at u.washington.edu
Tue Sep 11 21:41:51 CEST 2001


On Tue, 11 Sep 2001 aolinto at bignet.com.br wrote:

> Dear R-list members
>
> Here goes a question on data frames:
>
> I want to create a new data frame excluding some records
> (rows) from an existing one.
>
> Considering the data frame "fish.dat" at the end of this
> message, I can make a boxplot(Ring~Radius) and identify the
> points at rows 11 and 25 as outliers.
>
> With the command fish.dat[c(11, 25),] I can identify which
> fishes are related to these rows (fishes #4 and #1).
>
> With subset(fish.dat,reg==1) I can display all records from
> fish 1. My first question is:
> How can I list all records from fishes 1 and 4 at once?

subset(fish.dat,reg %in% c(1,4))

> Now I want to create a new data frame without the records from
> fishes 1 and 4.
>
> The only way I know is to type
> newfish.dat <- fish.dat[-c(2,4,6,10,11,15, ... ),]


subset(fish.dat, !(reg %in% c(1,4)))




	-thomas

Thomas Lumley			Asst. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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