RStudio Console slow when using system command on large zip file

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.


inputFile = 'input.csv'
zipFile = ''
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

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.