I have 3 dataframes:
iris1<-iris[1:50, ]
iris2<-iris[51:100,]
iris3<-iris[101:150,]
And a simple function that takes the input of a dataframe and a column and multiplies that column by 100 and then returns the dataframe:
add_col<-function(df,colname)
{
df$newcol<-df [, colname]*100
return(df)
}
I can then use that function on a dataframe to get the extra column added:
iris1<-add_col(df=iris1,colname="Sepal.Length")
How can I pass all the dataframes to this function rather than repeating the above 3x (1 for each dataframe?). I assume this is a problem that will use the apply family for functions but I can't work out how to do it.