[R] problem with r import data

Gavin Simpson gavin.simpson at ucl.ac.uk
Thu Aug 6 14:21:09 CEST 2009


On Thu, 2009-08-06 at 08:37 +0000, Inchallah Yarab wrote:
> Good moorning,
> 
> yesterday, i asked for how we can import data into R i found that it
> is necessary to make the file in csv format then use L<-
> read.csv2("path of file")

Does read.csv() work instead? How is your "csv" file delimited? columns
separated by ";" or by ","?

> now i see that the dimension of my table importing into R is 1 colonne
> (i have realy 20) and (655555) the number of all my lines in the excel
> file (i want to have only the 2600 lines in my table)

So you failed to import your data correctly.

> Also, when i say to do this L[c(1,2,5)] it is not work coluns not
> define!!!!

That isn't how you select columns from a matrix-like object:

[r,c] is the usual format, you just specified elements 1,2,5. E.g.

> dat <- data.frame(X = 1:10) # 1 column data frame
> dat[c(1,2,5)]
Error in `[.data.frame`(dat, c(1, 2, 5)) : undefined columns selected

Sort out getting your data into R "correctly" first, then you can worry
about subsetting it.

HTH

G
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%




More information about the R-help mailing list