column name of a table

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

column name of a table

herodote@oreka.com
hy all,

I wish to switch in a part in my code that use "read.table" to "scan", actually i use this:

tab<-scan("data.dat",what=integer(),skip=1)
dim(tab)<-c(75,length(tab)/75)
tab<-t(tab)

It gives me a new tab with 75 columns, but i when i was using read.table with headers then attach i could use the columns names to access the data values, now how can i attach the columns names that are on the first line of the file data.dat?

Any help would be great!

thks all
guillaume.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: column name of a table

Florence Combes
I am not sure to understand what you want, but maybe
colnames() is what you want.
for example

> mat
     [,1] [,2] [,3]
[1,]    1    3    5
[2,]    2    4    6
> colnames(mat)<-c("col1","col2","col3")
> mat
     col1 col2 col3
[1,]    1    3    5
[2,]    2    4    6


was it what you were looking for ?

florence.



On 12/16/05, [hidden email] <[hidden email]> wrote:

>
> hy all,
>
> I wish to switch in a part in my code that use "read.table" to "scan",
> actually i use this:
>
> tab<-scan("data.dat",what=integer(),skip=1)
> dim(tab)<-c(75,length(tab)/75)
> tab<-t(tab)
>
> It gives me a new tab with 75 columns, but i when i was using read.tablewith headers then attach i could use the columns names to access the data
> values, now how can i attach the columns names that are on the first line of
> the file data.dat?
>
> Any help would be great!
>
> thks all
> guillaume.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html