I'm encountering a strange behavior in RStudio. When I run the reprex below in a normal R terminal, timeElapsed
is 0.1 sec. When I run the reprex in the RStudio Console, timeElapsed
is 5.7 sec. The bigger the zip file, the longer the command takes in the RStudio Console. I'm baffled.
I'm using R 3.6.3 and RStudio 1.3.1073 on MacOS 10.15.6.
library('data.table')
inputFile = 'input.csv'
zipFile = 'input.zip'
outputFile = 'output.csv'
d = CJ(col1 = 1:1e4, col2 = 1:1e4)
fwrite(d, inputFile)
if (file.exists(zipFile)) unlink(zipFile)
zip(zipFile, inputFile)
timeStart = Sys.time()
system(sprintf('unzip -p %s | head -n 10 > %s', zipFile, outputFile))
timeElapsed = Sys.time() - timeStart