I have the next dataframe in R:
col1 | col2 | col3 | col4 | col5 | col6 | col7 |
---|---|---|---|---|---|---|
a | b | c | 1 | 2 | c | 1 |
c | 3 | 4 | c | 1 | NA | NA |
b | c | 5 | 6 | c | 1 | NA |
I need to delete the cells values/text before the first “c”. The dataframe I need is:
col1 | col2 | col3 | col4 | col5 |
---|---|---|---|---|
c | 1 | 2 | c | 1 |
c | 3 | 4 | c | 1 |
c | 5 | 6 | c | 1 |
as.data.frame(t(matrix(unlist(strsplit(gsub(".*(?=c)|-NA| (?=.*)","", x, perl = T), "-")), ncol = 3)))
?