[R] does R have a command the same with Stata's loop command: ` '

Patrick Burns pburns at pburns.seanet.com
Wed Aug 4 11:41:43 CEST 2010


So you *can* do it.  There is a question
remaining of whether you *should* do it.
More R-ish is to use a list.

On 04/08/2010 01:39, jim holtman wrote:
> ?paste
> ?assign
>
> On Tue, Aug 3, 2010 at 8:29 PM, Hey Sky<heyskywalker at yahoo.com>  wrote:
>> hey, Rers
>>
>> in Stata therer is a loop command ` ' which could do the following:
>>
>> forvalue i=1/10 {
>>   gen x`i'=expression
>> }
>>
>> this will generate variable: x1,x2,,,,,x10. so, does R have a corresponding one
>> to this?
>>
>>
>> And one more very basic question: after I open a file and modify it, such as
>> generate some new variables and change some old ones, how to use the changed
>> dataset in analysis, except the method save and reload it?
>>
>>
>> I have tried but did not get the right thing done:
>> mydata<-read(flie=".....")
>> ........
>> detach()
>> attach(names of my data set)
>>
>>
>> any answer are appreciated.
>>
>> Nan
>> from Montreal
>>
>>
>>
>> ______________________________________________
>> 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.
>>
>
>
>

-- 
Patrick Burns
pburns at pburns.seanet.com
http://www.burns-stat.com
(home of 'Some hints for the R beginner'
and 'The R Inferno')



More information about the R-help mailing list