apply an already defined function to all data-frames at once
I already have defined a function (which works fine). Nevertheless, I have
20 data-frames in the working space to which I want to apply the same
function (dat1 to dat20).
So far it looks like this:
dat1 <- func(dat=dat1)
dat2 <- func(dat=dat2)
dat3 <- func(dat=dat3)
dat4 <- func(dat=dat4)
...
dat20 <- func(dat=dat20)
However, is there a way to do this more elegant with a shorter command,
i.e. to apply the function to all data-frames at once?
I tried this, but it didn´t work:
> mylist <- paste0("dat", 1:20, sep="")
>
> lapply(mylist, func)
Thanx in advance!
No comments:
Post a Comment