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") 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) Also, when i say to do this L[c(1,2,5)] it is not work coluns not define!!!! someone have an idea? thanks [[alternative HTML version deleted]]
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 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
?read.table and check on the options offered by read.csv2. Open the file in a text editor and see what you have. Check the delimiters and be sure that that they are either ; as specified in read.csv2 or else specify the delimiter ( sep= "???" --- On Thu, 8/6/09, Inchallah Yarab <inchallahyarab at yahoo.fr> wrote:> From: Inchallah Yarab <inchallahyarab at yahoo.fr> > Subject: [R] problem with r import data > To: r-help at r-project.org > Received: Thursday, August 6, 2009, 4:37 AM > 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") > 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) > Also, when i say to do this L[c(1,2,5)] it is not work > coluns not define!!!! > > someone have an idea? > > thanks > > > ? ? ? > ??? [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org > mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. >__________________________________________________________________ Be smarter than spam. See how smart SpamGuard is at giving junk email