2
我是R的新程序員。我有一些保存在文件夾中的文章(.txt)。 現在我可以在R中導入文章了。我有兩種方法,我不知道哪一個更好。如何使用某些關鍵字來查找哪些文章包含這些關鍵字?
這裏是我的代碼:
# 1
library(tm)
cname <- file.path("D:/magazine_pass")
docs <- Corpus(DirSource(cname), readerControl=list(reader=readPlain))
# 2
dir.list <- list.files("D:/magazine_pass" , full.name = TRUE)
for(i in 1:length(dir.list)){
file0 <- dir.list[i]
s <- readLines(file0,encoding="ASCII")
s <- sapply(s,function(row) iconv(row, "ASCII", "ASCII", sub=""))
}
而且我也試圖用一些biokeywords(ex.clean energy,wearable device)
找到該文章包含這些關鍵字。 我該怎麼辦?
請讓我看看代碼並簡單描述它。非常感謝。
非常感謝! – Bruce