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
First, remove the rows starting with #
from your one-column data frame x
:
vec <- grep("^[^#]", x[[1]], value = TRUE)
Then, create a new data frame based on the remaining data:
data.frame(V1 = gsub("(.*\\:[0-9]+) .*", "\\1", vec),
V2 = gsub(".* ([0-9]+) [0-9]+ [0-9]+ *$", "\\1", vec))
# V1 V2
# 1 2013-08-27 16:00:00 200
# 2 2013-08-27 16:00:01 200
# 3 2013-08-27 16:00:02 200
# 4 2013-08-27 16:00:03 200