Create multiple dataframes using subset function
Suppose i have a dataframe that has variables a1 a2 a3...each of which
takes values between 1-10....I need to create 3 separate dataframes for
each of a1>2, a2>2, a3>2.. i have 300 such variables, so i dont want to do
this manullay.. I am a R novice and hence a little weak with the loops i
guess..Could you please help me out?. is there a way to put the 300
variable list in amacro and call each vaalue of the the macro list?
I need something like below for each of the 300 variables.. (Also my
variables are not a1 a2 a3, so i need to change the name each time for
creating the dataframe)
for (i in 1:3){ a_&i <- subset(df,a&i>2) }
Any help would be appreciated..
Thaks!
No comments:
Post a Comment