[R] Giving column names to a matrix

jmoreira@fe.up.pt jmoreira at fe.up.pt
Fri Oct 29 19:26:49 CEST 2004


Heloo,

I have the following problem:

orig.data	<- NULL
Inside a loop I have instructions like:
orig.data <- rbind(orig.data, ...)
After that I do:
colnames(orig.data)<-c('Data','InicioViagem', ...)
Everything works fine.
For example, the first line of the matrix is:
> orig.data[1,]
        Data InicioViagem      ...
           1        40466      ...
The problem is: I can't refer the columns by the column names.
For example:
> orig.data[1,InicioViagem]
Error: Object "InicioViagem" not found
or
> orig.data[1,]$InicioViagem
NULL
but:
> orig.data[1,2]
[1] 40466
works!

Can someone help me?

Thanks

Joao Moreira




More information about the R-help mailing list