I want to get a new data.frame from this data set,but there are some description with\"#\" between some rows and some rows contain \"#\" sign, I can use \"for\" loop under the c
I am assuming you want to read the data from external table(it's unclear from your question), so accordingly i am answering your question,Use comment.char="#" in "read.table" option, it will ignore the lines starting with #.
See ?read.table
.
So, your first line could be:
x <- read.table("comm.txt",comment.char="#"),
where "comm.txt" is file which contains data according to your given format.
You can then use following code to split columns based on delimeter "-"
library(reshape2)
LS <- lapply(seq_along(x), function(i){
colsplit(x[, i], "-", paste0(colnames(x)[i], letters[1:3]))
}
)
do.call('cbind', LS)
Hope this helps