Re: [R] Splitting Datasets

From: Jack Tanner <ihok_at_hotmail.com>
Date: Mon, 28 Mar 2011 03:28:54 +0000

Wainscott, Robert LT <robert.wainscott <at> cvn74.navy.mil> writes:

> I want to split dataset "ZIDL", into individual datasets based on the
> string content of variable "Dept".

There are many, many ways to do this, depending on what you're really after. Here's one:

depts = levels(factor(zidl$dept))
for (i in 1:length(depts)) {
  tiny.dataset = subset(zidl, dept==depts[i])   # now do whatever processing you need with tiny.dataset }

Read the Introduction to R and the help page for the subset command, i.e., ?subset



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. Received on Mon 28 Mar 2011 - 03:33:37 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 Mon 28 Mar 2011 - 03:40:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive