[R] Mutiplying a data frame to a list
Phil Spector
spector at stat.berkeley.edu
Mon Feb 21 21:03:55 CET 2011
Rohit-
If I understand you correctly, and your list's name is mylist,
then
mapply('*',mylist,as.numeric(names(mylist)))
will do what you want. In the future, please provide a reproducible
example.
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spector at stat.berkeley.edu
On Mon, 21 Feb 2011, Rohit Pandey wrote:
> Hi R community,
>
> I have a question I'm sure is very simple for most of you.
>
> I have a list, with each element being a matrix and the names of the
> elements are numbers (like 1,3,...). I can extract the matrices and the
> names individually. Now, I want to multiply each of the names to the
> individual list matrices (after converting to numbers of course).
>
> I could use a for loop, but the very reason I have this list is that I was
> trying to avoid loops (using lapply). So, turning to one now could defeat
> the whole purpose.
>
> Thanks in advance,
>
> --
> Thanks,
> Rohit
> Mob: 91 9819926213
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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