问题
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?
回答1:
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)
来源:https://stackoverflow.com/questions/30142183/import-of-csv-data-ignoring-the-separator