我不明白这两者之间的区别。它们对gsub函数的输出有不同的影响。
text_df <- data_frame(gsub('[[:punct:] ]+',' ',fromDB$message))
str(text_df)
控制台结果:
Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 74 obs. of 1 variable:
$ gsub("[[:punct:] ]+", " ", fromDB$message): chr "Sayın Kullanıcı...
text_df<-gsub("[.]",'',text_df)
str(text_df)
控制台结果:
chr "c(\"Sayın Kullanıcı.......")"
text_df <- data.frame(gsub('[[:punct:] ]+',' ',fromDB$message))
str(text_df)
控制台结果:
'data.frame': 74 obs. of 1 variable:
$ gsub.....punct.............fromDB.message.: Factor w/ 70 levels "
text_df<-gsub("[.]",'',text_df)
str(text_df)
控制台结果:
chr "c(52, 39, 61, 63, 55, 43, 24, 49, 23,.....)"