-1

I'm using RStudio and I wanted to import csv data. This data has 3 columns and they are separated by ",".

Now I type test <- read.csv("data1.csv", sep=",") Data is imported but its imported as just ONE column.

Headers are okay, but also the headers (actually 3) are combined together in just one column.

If I set header=F, there was V1 as heading. So there really is just one column. Why is my separator not working?

kdopen
  • 8,032
  • 7
  • 44
  • 52
  • 7
    Sounds like the separator isn't really a comma. Can you actually show part of the input file? We really need a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) to help further. – MrFlick May 09 '15 at 16:12
  • in cvs data the first row is named as following: Alter.des.Hauses,"Quadratfuß","Marktwert" the second row is 33,1.812,"$90.000,00" and so on. the names in the first row are my column names and every column then has numeric values – downtoearthjoe May 09 '15 at 16:46
  • That sounds German. Have you tried `read.csv2`? – gung - Reinstate Monica May 09 '15 at 16:53
  • 1
    read.csv has a sep="," and header=TRUE by default. I made an example with the two lines that you provided and test <- read.csv("data1.csv") works fine... Could you edit the question by adding a link to the real data? – F. Correhuela May 09 '15 at 17:11

1 Answers1

0

try read_csv() from readr package

install.packages("devtools")
devtools::install_github("hadley/readr")

with your sample input

library(readr)
file <- 'Alter.des.Hauses,"Quadratfuß","Marktwert"\n33,1.812,"$90.000,00"\n'
read_csv(file) # for the actual use read_csv("file.csv") ...
read_csv2(file)
pat shipan
  • 715
  • 6
  • 13