Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open windows explorer with specific path using system command

Tags:

r

system

I found out that it is possible to open the windows explorer with a predefined path via the cmd.exe program using the following command:

explorer PATH 

Back in R using the following command opens up the windows explorer:

system("explorer", intern=TRUE) 

However, when I specify a path R returns the following warning message and does not open the explorer at the specified path:

> system("explorer C:\\Users\\xxx", intern=TRUE) 
character(0) 
attr(,"status") 
[1] 1 
Warning message: 
running command 'explorer C:\Users\xxx' had status 1 

I quoted the \ otherwise R complained about not recognising \U from \Users.

However, when the command is executed as we would expect the double \ are replaced by only one .

When I copy paste the explorer C:\Users\xxx bit from the R warning message into the cmd.exe program the explorer is opened up at the specified path.

Does anybody have any idea why that fails?

like image 235
user969113 Avatar asked Aug 05 '26 21:08

user969113


1 Answers

try

shell("explorer C:\\Users\\xxx", intern=TRUE) 
like image 91
shhhhimhuntingrabbits Avatar answered Aug 07 '26 15:08

shhhhimhuntingrabbits



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!