3 ms·
What kind of task was it? I’d imagine loading a csv-like file and doing some somewhat heavy calculations, R would win, but when I think of AWK problems I think
by wodenokoto 7y ago
What kind of task was it? I’d imagine loading a csv-like file and doing some somewhat heavy calculations, R would win, but when I think of AWK problems I think of text manipulation, and when I think of manipulating text I do not think of R
Disclaimer: I don’t actually write any AWK, but learning it is on my bucket list.
- arendtio 7y agoThe tasks were different. AWK -> calculate the difference between every two lines: awk -F ',' 'NR!=1{printf "%.0f\n", $1-ll}NR==1{print ""}{ll=$1}' R -> Calculate the min, median, mean, and max: d<-scan("stdin", quiet=TRUE) cat(min(d), max(d), median(d), mean(d), sep=" ") AFAIK, calculating the difference to its previous line for every line should be faster for data that is not sorted. I didn't try to write that one in R though. I am sure there ways to make both things faster, I was just surprised as I didn't expect R to be faster with those two naive implementations.