I am trying to load some data into R which is in the following format (as a text file)
Name Country Age
John,Smith United Kingdom 20
Washington,George USA 50
Martin,Joseph Argentina 43
The problem is that the "columns" are separated by spaces, so that they all line up well, but one line can have 5 spaces between the values ββand the next 10 spaces. So when I load it when using read.delim, I get one data.frame column with
"John,Smith United Kingdom 20"
as a first observation, etc.
Is there a way I can:
- Load data into R in a convenient format? or
- Separate character strings into separate columns as soon as I load them in single column format?
, , , 2 x (, , "United Kingdom" "United" "" "Kingdom"). , .
strsplit(data.frame[,1], sep="\\s"), , :
"John,Smith" "" "" "" "" "" "" "" "United" "" "Kingdom" "" ""...
, .