[R] Using data( ) in a loop

2010-11-02 Thread McCarthy, Ian
I'm trying to generate 50+ graphs using the UScensus2000tract data.  I
need to access the data for just about all of the states, so I was
hoping to create a simple loop that will take the relevant state from my
data and load the associated census data from the UScensus2000tract
package.   Below is a sample of what I'm trying to do.  Any suggestions
are much appreciated.

 

stores=read.table(paste(path,\\Store
List.txt,sep=),header=TRUE,sep=\t)

city=stores$City

state=stores$State

city.state=data.frame(city,state)

 

state.temp=city.state$state[1]

tract - paste(state.temp,.tract,sep=)

data(tract)

Warning message:

In data(tract) : data set 'tract' not found

 

 

 

Ian McCarthy, Ph.D.

F T I 

214.397.1761 direct

214.663.1683 mobile

ian.mccar...@fticonsulting.com
mailto:firstname.lastn...@fticonsulting.com 

 

 

Confidentiality Notice:\ \ This email and any attachment...{{dropped:16}}

__
R-help@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.


Re: [R] Using data( ) in a loop

2010-11-02 Thread Dennis Murphy
Hi:

On Tue, Nov 2, 2010 at 8:06 AM, McCarthy, Ian 
ian.mccar...@fticonsulting.com wrote:

 I'm trying to generate 50+ graphs using the UScensus2000tract data.  I
 need to access the data for just about all of the states, so I was
 hoping to create a simple loop that will take the relevant state from my
 data and load the associated census data from the UScensus2000tract
 package.   Below is a sample of what I'm trying to do.  Any suggestions
 are much appreciated.


 stores=read.table(paste(path,\\StoreList.txt,sep=),header=TRUE,sep=\t)
 city=stores$City
 state=stores$State
 city.state=data.frame(city,state)

 Or more succinctly,
city.state - stores[ , c('city', 'state')]



 state.temp=city.state$state[1]
 tract - paste(state.temp,.tract,sep=)


I believe you need get() here, but I would think you'd need a path to the
state file you want to grab. See ?get

HTH,
Dennis


 data(tract)

 Warning message:

 In data(tract) : data set 'tract' not found







 Ian McCarthy, Ph.D.

 F T I

 214.397.1761 direct

 214.663.1683 mobile

 ian.mccar...@fticonsulting.com
 mailto:firstname.lastn...@fticonsulting.com





 Confidentiality Notice:\ \ This email and any attachment...{{dropped:16}}

 __
 R-help@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.


[[alternative HTML version deleted]]

__
R-help@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.