[R] Performing same steps on multiple dataframes using a loop - vijay

Bert Gunter gunter.berton at gene.com
Sat Jan 18 08:11:59 CET 2014


Is this homework? Most of us object to doing homework here.

If not, have you gone through any R tutorials? This looks like pretty
basic stuff, and one has to wonder if you can't do this, why are you
using R at all?

Cheers,
Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
H. Gilbert Welch




On Fri, Jan 17, 2014 at 8:46 PM, Vijay <vijaychowdhari at gmail.com> wrote:
> I have three data frames df.1, df.2 and df.3. All have the same structure I.e here is df.1
>
> Name                    network             speed
> Atlanta_Ga.           LTE.                    10
> Hartford_CT.          HSPA.                  4
> Seattle_WA.           LTE.                     12
>
> I want to perform a couple of steps on each data frame and store the transformed dataframes as df.1cleaned, df.2cleaned etc......
>
> Here are the steps to perform.
>
> 1.Create a new column named state, given by the last two letters of the name field
> 2. Only keep rows where network is HSPA
> 3. Multiple the speed column by 1000
>
> So df.1cleaned would look like
> Name                Network.       Speed.     State
> Hartford_CT.     HSPA.           10000.      CT
>
> Can someone help me come up with a loop or a function that loops through all dataframes and produces all three dataframes
>
> Thanks
> Vijay
>
>
> Sent from my iPad
> ______________________________________________
> 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.




More information about the R-help mailing list