G. *_*eck 12
1)读入并使用R grep:
# test input
cat("a 1\n\b 2\nc 3\n", file = "myfile.dat")
grep("a", readLines("myfile.dat"), value = TRUE)
## [1] "a 1"
Run Code Online (Sandbox Code Playgroud)
2)如果你的系统和搜索路径上有grep,另一种可能性是:
shell("grep a myfile.dat")
## a 1
Run Code Online (Sandbox Code Playgroud)
在Windows上,您可以使用或findstr代替grep您安装Rtools但不在路径上shell("C:\\Rtools\\bin\\grep a myfile.dat").