After reading an HTML table, my name
column appears with records as follows:
\n\t\t\t\t\t\t\t\t\t\t\t\t\tMike Moon\n\t\t\t\t\t\t\t\t
The following code fails to generate the correct values in the First and Last name columns
separate(data=nametable, col = Name, into = c("First","Last"), sep= " ")
Curiously, the First
column is blank, while the Last
column contains only the person's first name.
How could I correctly turn this column into the First
and Last
column desired (i.e...
First Last
Mike Moon
Data example per recommendation of @r2evans and as appearing in correct answer code below:
nametable <- data.frame(Name="\n\t\t\t\t\t\t\t\t\t\t\t\t\tMike Moon\n\t\t\t\t\t\t\t\t", stringsAsFactors=FALSE)