Re: [R] Splitting Datasets

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

Wainscott, Robert LT <robert.wainscott <at>> 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 mailing list PLEASE do read the posting guide 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 Please read the posting guide before posting to the list.

list of date sections of archive