I have a column in my dataframe:
Colname
20151102
19920311
20130204
>=70
60-69
20-29
I wish to split this column into two columns like:
Col1 Col2
20151102
19920311
20130204
>=70
60-69
20-29
How can I achieve this result?
do.call(cbind, split(df, cumsum(grepl('>', df$Colname))))
if you want as two separate columns.indx <- cumsum(grepl('>', df$Colname)); df1 <- data.frame(Col1=df$Colname, Col2=df$Colname, stringsAsFactors=FALSE); df1[!indx,1] <- ''; df1[indx,2] <- ''