Pipe to GPG works in R but not RStudio

I am using the below code to write an encrypted file from R. It works from R 3.4.3 console, but not in RStudio

zz <- pipe("gpg.exe --encrypt --recipient me --output C:\\Temp\\test.gpg","w")

In RStudio one difference I notice is after saving zz, the description is actually description "C:\Windows\system32\cmd.exe /c gpg.exe --encrypt --recipient me --output C:\Temp\test.gpg", but in R console the description is exactly as entered.

Both R and RStudio produce the output file test.gpg, but the test.gpg file produced in RStudio is apparently garbled and cannot be decrypted: gpg: [don't know]: 1st length byte missing

Is there a way to configure RStudio to not prepend what I'm guessing is %comspec% /C to the pipe description?

I see the same behavior within RGui, so I suspect R itself might be modifying the command depending on the host environment. That is, RStudio is not the one prepending %COMSPEC% /C to the invocation of the piped command.

Here's what I see in the R sources:

Is it possible to avoid the use of pipes altogether? Could you instead have gpg.exe read from a file, or something similar?

Thanks for the reply and pointers in the right direction. I was hoping to take advantage of the pipeline for streaming larger files. Reading or writing an entire file at once could be done with the r gpg package.

Seems a bit silly for R to bother prepending anything at all: surely the user can decide if they want a shell or some other process. However maybe the prepending is not the problem: I can run something like "echo testing | cmd.exe /c gpg --encrypt ...." and produce a usable encrypted file. But I agree it looks to be an issue with R and not RStudio.