Reputation: 4180
I have a dataset that looks like the one below:
ID Message
1 .
2 .
3 Click_screen
4 Blank screen
5 .
6 .
7 .
The actual dataset has 48 columns and 50,000 rows.
Importing this dataset with read.table() is problematic because of the string "Blank screen", which has a space between the two sub-strings. For example, I got an error message like:
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
line 4 did not have 48 elements
I wonder if there is any way to circumvent this problem in R rather than change the original dataset in Excel.
EDIT: Just to add, I tried to set fill to TRUE, and I got an error message below:
Error in read.table(file.choose(), header = T, fill = T) :
duplicate 'row.names' are not allowed
Upvotes: 0
Views: 376
Reputation: 42639
If the file is space-separated (as opposed to tab-separted), you might want read.fwf, along with a vector of field widths. If the file is tab-separated, you might want read.table(sep='\t',...).
Upvotes: 1
Reputation: 121568
It depends on your local separator but try this
read.table(fileName,fill=TRUE,header=FALSE,sep =';')
Upvotes: 1