Re: [R] data.frame

From: P Ehlers <ehlers_at_math.ucalgary.ca>
Date: Thu 25 May 2006 - 00:13:46 EST

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
>



R-help@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 Received on Thu May 25 00:21:42 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 25 May 2006 - 02:10:26 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.