Created
December 9, 2024 09:52
-
-
Save abikoushi/9e624797da9afe929fe37de4f81a5521 to your computer and use it in GitHub Desktop.
Run AWK query from R (change specific rows)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query_awk <- function(vpar, pdir, filename, uid){ | |
chl <- paste0("cat ", pdir, "/", filename) | |
for(i in 1:nrow(vpar)){ | |
chr <- paste0("\"", paste(vpar[i,], collapse = ", "), "\"") | |
awk <- paste0(" | awk 'NR==", uid[i], "{sub('/.*/',", chr, ")}1'") | |
chl <- paste0(chl, awk) | |
} | |
chl <- paste0(chl, " > ", pdir, "/tmp.csv") | |
mvit <- paste0("mv ", pdir, "/tmp.csv " , pdir, "/", filename) | |
system(chl) | |
system(mvit) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment