[R] data.frame

P Ehlers ehlers at math.ucalgary.ca
Wed May 24 16:13:46 CEST 2006


Sara,

You didn't read your data into R correctly.

If your data are really in the form you posted (one long column
of mixed data types and lots of blank lines), then I would:

1. remove the blank lines with my text editor and save (say, mydata.txt)

2. scan() the variable names into a vector

  nm <- scan("mydata.txt", what = "", nlines = 13)

3. scan() the data values into a list

  x <- scan("mydata.txt",
            what = list(0,0,"",0,0,0,0,0,0,0,0,0,""),
            skip = 13)

4. attach the names

  names(x) <- nm

5. convert to data frame

  DF <- data.frame(x)

(You really shouldn't post your whole data set; a couple of records
would have been sufficient.)

Peter Ehlers


Sara Mouro wrote:
> Dear all,
> 
>  
> 
> Does any one knows why should I get the following error message, when trying
> to do a simple data.frame??
> 
>  
> 
> DataF<-data.frame(Subject,BiomR,Spp,Capas,Litter,Herbs,LitterD,MaxCanH,DDifS
> p,DSSp,Slope, CanDens,NearestSp)
> 
>  
> 
> Erro em data.frame(Subject, BiomR, Spp, Capas, Litter, Herbs, LitterD,  : 
> 
>         arguments imply differing number of rows: 202, 0
> 
>  
> 
>  
> 
> The data I am using is:
> 
>  
> 
> 
> Subject
> 
> BiomR
> 
> Spp
> 
> Capas
> 
> Litter
> 
> Herbs
> 
> LitterD
> 
> MaxCanH
> 
> DDifSp
> 
> DSSp
> 
> Slope
> 
> CanDens
> 
> NearestSp
> 
> 
> 1
> 
> 140.74
> 
> Qfa
> 
> 2
> 
> 1.460
> 
> 0
> 
> 0.778
> 
> 8
> 
> 70
> 
> 3.663
> 
> 28
> 
> 2.280
> 
> Ear
> 
> 
> 2
> 
> 7.26
> 
> Aun
> 
> 2
> 
> 0.660
> 
> 0
> 
> 0.477
> 
> 8
> 
> 110
> 
> 3.988
> 
> 34
> 
> 2.476
> 
> Ear
>



More information about the R-help mailing list