Hi, I used read.csv(file name, header=T, sep=",") to bring in a csv file I saved in MS Excel. The strange thing is all the data ended up in one big column. The number of rows match with the number of observations, but all the variables got squeezed into one column. Also the first row where the header is, the variables names have a dot between them, replacing the comma that's in the original csv file. What did I do wrong here? -- View this message in context: http://r.789695.n4.nabble.com/import-csv-file-into-R-strange-problem-tp3810470p3810470.html Sent from the R help mailing list archive at Nabble.com.
It would appear that your file is not a csv file, but we cannot tell for sure without seeing an example of the data that you are reading in, can you cut and paste the first few lines of the file? Or post a link to a copy of the file. If the data is not able to be shared, then create a new (small) file with made up data that displays the same problems (creating the example sometimes helps you fix the problem yourself) then share that file. Also why are you specifying sep="," in read.csv? that is a bit redundant. -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of bonnieyuan Sent: Tuesday, September 13, 2011 10:09 AM To: r-help at r-project.org Subject: [R] import csv file into R, strange problem Hi, I used read.csv(file name, header=T, sep=",") to bring in a csv file I saved in MS Excel. The strange thing is all the data ended up in one big column. The number of rows match with the number of observations, but all the variables got squeezed into one column. Also the first row where the header is, the variables names have a dot between them, replacing the comma that's in the original csv file. What did I do wrong here? -- View this message in context: http://r.789695.n4.nabble.com/import-csv-file-into-R-strange-problem-tp3810470p3810470.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 13/09/11 18:08, bonnieyuan wrote:> Hi, I used read.csv(file name, header=T, sep=",") to bring in a csv > file I saved in MS Excel. The strange thing is all the data ended > up in one big column. The number of rows match with the number of > observations, but all the variables got squeezed into one column. > Also the first row where the header is, the variables names have a > dot between them, replacing the comma that's in the original csv > file. > > What did I do wrong here?Maybe Microsoft? We had the problem in South Adfrica, that if the locale was set to South African English, then the csv was ";" seperated - don't tell me why. So: check your csv if it is really a csv. Cheers, Rainer> > -- View this message in context: > http://r.789695.n4.nabble.com/import-csv-file-into-R-strange-problem-tp3810470p3810470.html > >Sent from the R help mailing list archive at Nabble.com.> > ______________________________________________ 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.- -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax : +33 - (0)9 58 10 27 44 Fax (D): +49 - (0)3 21 21 25 22 44 email: Rainer at krugs.de Skype: RMkrug -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk5wZZEACgkQoYgNqgF2egqGfgCeKWohnNQONvSge1M6Bf9OtBMP ln4An1n64fYAwNfTzc3rbD/tRXx9ksry =XYvm -----END PGP SIGNATURE-----