Re: [R] print dataframe names in loop

2015-05-16 Thread Kai Mx
Thanks for all the input. It seems like there is no way around introducing names for the list items, but the namedList-function is really neat. Function returns are not at issue for me, I rather want to use it on plots or outputs in the console. Best, Kai On Fri, May 15, 2015 at 10:51 PM, Willi

Re: [R] print dataframe names in loop

2015-05-15 Thread William Dunlap
You can automate the adding of the names to the list with the following function, so you can replace the dflist<-list(df1,df2,df3) names(dflist)<-c("df1","df2","df3") with dflist <- namedList(df1, df2, df3) If you supply names, such in dflist <- namedList(df1, Second=df2, log(df3)) it will

Re: [R] print dataframe names in loop

2015-05-15 Thread David Winsemius
On May 15, 2015, at 10:05 AM, Kai Mx wrote: > thanks, that would work, but isn't there a maybe more elegant way to > "extract" the name from the df variable within the current for (df in > list()) loop? > You do realize that the `for` function returns NULL, I hope? I was surprised when I learn

Re: [R] print dataframe names in loop

2015-05-15 Thread Omar André Gonzáles Díaz
Two seconds using google: http://stackoverflow.com/questions/9002227/how-to-get-the-name-of-a-data-frame-within-a-list 2015-05-15 7:20 GMT-05:00 Jim Lemon : > Hi Kai, > One way is to name the components of your list with the names of the > data frames: > > df1<-data.frame(a=1:3) > df2<-data.fram

Re: [R] print dataframe names in loop

2015-05-15 Thread Kai Mx
thanks, that would work, but isn't there a maybe more elegant way to "extract" the name from the df variable within the current for (df in list()) loop? Best, Kai On Fri, May 15, 2015 at 2:20 PM, Jim Lemon wrote: > Hi Kai, > One way is to name the components of your list with the names of the

Re: [R] print dataframe names in loop

2015-05-15 Thread David Winsemius
On May 15, 2015, at 5:05 AM, Kai Mx wrote: > Hi everybody, > > I just can't figure this out: > > I have a loop trough several dataframes such as > > for (df in list(df1, df2, df3, ...)) { > ..some functions with df.. > } > > now I want to print out the current dataframes name (ie the list it

Re: [R] print dataframe names in loop

2015-05-15 Thread Jim Lemon
Hi Kai, One way is to name the components of your list with the names of the data frames: df1<-data.frame(a=1:3) df2<-data.frame(a=4:6) df3<-data.frame(a=7:9) dflist<-list(df1,df2,df3) names(dflist)<-c("df1","df2","df3") for(i in 1:length(dflist)) cat(names(dflist)[i],"\n") df1 df2 df3 Jim On F

[R] print dataframe names in loop

2015-05-15 Thread Kai Mx
Hi everybody, I just can't figure this out: I have a loop trough several dataframes such as for (df in list(df1, df2, df3, ...)) { ..some functions with df.. } now I want to print out the current dataframes name (ie the list items name) with the cat command before the actual functions to have