[R] naming vectors/ matrices in R
erich.neuwirth at univie.ac.at
Tue Mar 31 19:16:05 CEST 2009
This is probably what you want
for (i in (1:dim(mydf))) assign(letters[i],mydf[,i])
I would not, however, recommend it.
It really does not produce very readable code.
> I would like to create a series of vectors in a loop and name them with
> I know the command letters gives me the 26 letters of the alphabet.
> For example, I have a dataframe, called A, with 6 columns.
>  "a" "b" "c" "d" "e" "f"
> I would like to extract the first letter "a", and put the first column of
> dataframe A in a vector called "a"
>  "a"
> but when I type
> Warning message:
> In e =A[, 1] :
> number of items to replace is not a multiple of replacement length
> It thinks I am trying to replace the first element of e with the first
> column of A.
> is there any other way in which I can achieve this?
> Thanks in advance
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459
More information about the R-help