[R] Read Unicode text (*.txt)

Abby Spurdle @purd|e@@ @end|ng |rom gm@||@com
Tue Jul 2 03:06:32 CEST 2019


> I am trying to read an excel CSV file (1.csv). When I read it as csv file
> in R, the R shows me the exact number of row. But it puts all columns in
> one column, while I have 3 or 4 columns in the data frame.
> d4 = read.table("./4.csv",sep=";",header=TRUE)

Firstly, I recommend against naming your file "1.csv".
(Start with a letter not a number).

Secondly, a CSV file should be separated by commas not semicolons.
You can specify sep=",", however, it's probably easier to use the
read.csv() function.

Note that you should be able to open your file in a text editor to see the
separators.

> I dont know why in the "save as type" box Unicode text (*.txt)

Other posters have suggested that you need to specify the encoding.
Assuming that you create your CSV file correctly in Excel, I doubt that
this is necessary, but I could be wrong...

Your comment suggests that you have saved your document as "Unicode text".
You need to tell Excel to save the file as a CSV file.
(There should be a list of save options).

Simply typing a file name with a .csv file extension is unlikely to produce
the desired result.

	[[alternative HTML version deleted]]



More information about the R-help mailing list