Description Usage Arguments Value Author(s) See Also Examples
Use system grep
(*NIX only). For large files this is much faster
than reading the file into R and grepping the columns.
1 | grep_system(pattern, filename, options = "")
|
pattern |
|
filename |
|
options |
|
character
vector
output from cut
Thomas P. Harte
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | tab<- read.csv(text='Name,Age,Salary,ID
Dick,38,32k,1
Tom,21,21k,2
Harry,56,NA,3',
header=TRUE,
stringsAsFactors=FALSE
)
for (col in which(col_classes(tab)=="character"))
tab[, col]<- tutils::trim(tab[, col])
tab
filename<- paste(tempfile(), ".csv", sep="")
write.csv(tab, file=filename, row.names=FALSE, quote=FALSE)
grep_system("Tom", filename)
grep_system("Dick", filename)
grep_system("harry", filename, options="-i")
unlink(filename)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.