[R] data manipulation

John Fox jfox at mcmaster.ca
Thu Apr 14 03:11:40 CEST 2005


Dear Yoko,

If you're sure that the data are complete, then data <-
matrix(scan("file-name"), ncol=29) should do the trick. Then to name the
columns of the data matrix, colnames(data) <- c("one", "two", etc.). [Of
course, you'd substitute meaningful names.]

I hope this helps,
 John

--------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
-------------------------------- 

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Yoko Nakajima
> Sent: Wednesday, April 13, 2005 7:56 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] data manipulation
> 
> Hello,
> my question is about the data handling.
> 
> I have a data set that is lined as:
> 
> 4 1 17 1 1
>  -5.1536 -0.1668 -2.3412 -0.5062  0.9621  0.3640  0.3678 
> -0.5081 -0.2227
>   0.8142 -0.0389 -0.0445 -0.0578 -0.1175 -0.1232  0.8673 
> -0.1033 -0.0796
>  -0.0341 -0.1716 -0.1801 -0.7014  0.6578  0.5611
> 4 1 17 2 1
>  -5.1536 -0.1668 -2.3412 -0.5062  0.9621  0.3640  0.3678 
> -0.5081 -0.2227
>   0.8142 -0.0389 -0.0445 -0.0578 -0.1175 -0.1232  0.8673 
> -0.1033 -0.0796
>  -0.0341 -0.1716 -0.1801 -0.7014  0.6578  0.5611
> 
> This means that 29 variables are together as a set. You saw 
> two sets of them in example. I have about 1000 sets (of 29 
> variables) in my data. When I "scan" this data set, the 
> result comes with 7 columns and it is not possible, so far, 
> to read the table by column wise, and thus it is not possible 
> to analyze the data. I would like to know whether there is a 
> way to solve this problem, say, by arranging columns or 
> increasing the number of columns of data matrix by R.
> 
> Also, I would like to know how you could name each column of 
> the data so that you could use the individual column separately.
> 
> Sincerely.
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html




More information about the R-help mailing list