How to save files from Rstudio AMI EC2 on my local

2020-02-29 07:09发布

问题:

I have installed Rstudio server Amazon EC2. It works fine, but I can't understand how to save files on my local computer...

In example,

x=5
write.csv(x,file="x.csv")
getwd()
[1] "/home/rstudio"

I can see the file in my working directory, but I cannot change w.d...

setwd("C:\\Users\\Paul\\Documents\\R")
Error in setwd("C:\\Users\\Paul\\Documents\\R") : 
  cannot change working directory

EDIT: I get Network error: Connection timeout... if i use instructions from codingthis.com/platforms/ec2/… using Putty... Or "Host does not exist" if I use winSCP...

Any suggestions?

Best regards!

回答1:

If you can't make SCP work, here's a simpler way. First I'll show how to save a plot, then how to save a CSV file that you've made with R.

You've started your EC2 instance of RStudio, thanks to helpful instructions elsewhere...

Now you've made a plot and you want to save that plot... Look at the plot window for the "Export" button and click that, then click 'save plot as image' (or PDF if you prefer)

Follow the prompt and save it in the default location...

Now switch from the plot window to the files window by clicking on the 'Files' tab in RStudio... You should see your plot image file in the list there. Now click 'More' then "Export..."

You can edit the file name at this point...

And then after you click download it will download to your default download directory...

If you've used R to make a csv file of output, you can export that to your download directory in the same way, you can see my file 'd.csv', here with the checked box next to it in the 'Files' window. I've clicked on the 'More...' button, then 'Export...'

Now I can edit the name, click 'Download' and will go to my default download directory:

Does that answer your question? If your next question will be "how do I get files into RStudio on EC2?", please first experiment with the "Upload" button in the 'Files' window of Rstudio.