[R] How to load data file without attribute names?

Jim Lemon jim at bitwrit.com.au
Sun Nov 28 00:02:05 CET 2010


On 11/27/2010 11:45 PM, 44whyfrog wrote:
>
> Hi all,
>
> I'm new to R and I'm struggling with loading a data file without attribute
> names, like:
>
> 1,72,0,5.6431,28.199
> 1,72,0,12.666,28.447
> 1,72,0,19.681,28.695
> 1,72,0,25.647,28.905
>
> It has no names for the columns nor the rows. I tried
>
> data<- read.table(path,header = FALSE, sep = ",")
>
> and it seems to work. But later, when I try qqnorm to plot the graph, it
> gives me the error msg:
>
> xy.coords(x, y, xlabel, ylabel, log) :
>    'x' and 'y' lengths differ
>
> I think the reason might be that I load the file wrongly. What should I do
> in this case?

Hi 44whyfrog,
I guess (and it's a wild one) that you have simply typed in the "usage" 
arguments, and these have little or no relation to what is in "data". If 
I were in your pond, I would first try:

names(data)

to see what the names of your columns are. If you do find columns named 
"x" and "y", try:

length(data$x)
length(data$y)

The error message may relate to the fact that you already have an "x" or 
a "y" object hanging around in your workspace, and they have different 
lengths.

Jim



More information about the R-help mailing list