Data:
I copy and pasted the your example data to a text file called tester.txt in an attempt to reproduce your error. The file contains nothing more than the following:
00004 A009 1 Cholera, unspecified Cholera, unspecified
Read Table:
I get the following with read.table
:
df <- read.table("tester.txt")
> df
V1 V2 V3 V4 V5 V6 V7
1 4 A009 1 Cholera, unspecified Cholera, unspecified
The output here my not be delineated exactly as you expect but you can quickly modify the columns as needed. It appears that your error is caused by an item in your .txt
file not evident in your example.
Modify columns:
You mentioned that you wanted five columns so I am assuming you would like to do the following once you read your .txt
file:
df[,4] <- paste0(df$V4,df$V5)
df[,5] <- paste0(df$V6,df$V7)
df <- df[,1:5]
> df
V1 V2 V3 V4 V5
1 4 A009 1 Cholera,unspecified Cholera,unspecified