这应该非常简单,但我无法解决。我从str_match_all函数得出我认为是矩阵的东西。尽管出现,但事实并非如此。通过对sapply [1,2]中的索引进行硬编码,我能够从“矩阵”的第一行提取时间戳记值。我想对矩阵中的最后一个条目执行相同的操作,并认为我可以轻松地提取矩阵中的行数来执行此操作,例如[nrow(sm),2],但不能!参见下文:
sm <- str_match_all(regex_text, regex_list[row, "regex_pattern"] )
print(sm)
#This gives me this (which is good):
# [[1]]
# [,1] [,2] [,3]
# [1,] "09/08/2014 13:01CONTENT_ACCESS.preparing" "09/08/2014 13:01" "CONTENT_ACCESS.preparing"
# [2,] "09/08/2014 13:06CONTENT_ACCESS.preparing" "09/08/2014 13:06" "CONTENT_ACCESS.preparing"
# [3,] "09/08/2014 13:08CONTENT_ACCESS.preparing" "09/08/2014 13:08" "CONTENT_ACCESS.preparing"
#Get the first timestamp
start_t_stamp <- sapply(sm, function(x) x[1,2])
print(start_t_stamp)
# Also good, I get [1] "09/08/2014 13:01"
#Get the last timestamp. How do extract the 'number of rows' in sm?
#This returns NULL
print(nrow(sm))
#transform to matrix???
t_sm <- t(sm)
#This then prints "[1,] Character,9"
print(t_sm)
#Therfore this prints 1
print(nrow(t_sm))
预先感谢...