3

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!

user1665355
  • 3,324
  • 8
  • 44
  • 84
  • I move files in and out of the EC2 workscape using `sftp` with [WinSCP](http://winscp.net/eng/index.php) – Ben Jun 06 '13 at 18:37
  • @user1665355 Could you please give me some more directions on how to do it?:) – user1665355 Jun 06 '13 at 18:51
  • How do you get them _into_ your EC2 instance? Just do the reverse... – Dirk Eddelbuettel Jun 06 '13 at 19:06
  • @DirkEddelbuettel Sorry Dirk I am a total beginner with AMI...I cant find the files at EC2 Manager at Amazon. I can only see the files in R studio AMI... – user1665355 Jun 06 '13 at 19:15
  • @DirkEddelbuettel please give me any suggestions on how to find and export data from rstudio AMI:) – user1665355 Jun 06 '13 at 19:30
  • There are already plenty of places you can find directions for this or similar: [1](http://www.berecursive.com/2012/amazon-ec2/transferring-files-to-an-amazon-ec2-instance-setting-up-sftp), [2](http://codingthis.com/applications/uploading-files-to-your-amazon-ec2-server-using-winscp/), [3](http://lzw-programmingjourney.blogspot.com/2011/12/set-up-ftp-server-on-amazon-aws-ec2.html) – Ben Jun 06 '13 at 19:39
  • @Ben I get Network error: Connection timeout... if i use instructions from http://codingthis.com/platforms/ec2/getting-started-for-free-with-amazon-elastic-cloud-computing-ec2/ using Putty... Or "Host does not exist" if I use WinSCP... – user1665355 Jun 06 '13 at 20:09
  • Did you delete the http:\\ from your EC2 URL when pasting it in as the hostname for WinSCP? – Ben Jun 07 '13 at 05:24
  • @Ben Yes, I did. But I still got the error. I did post a new question http://stackoverflow.com/questions/16990829/trouble-with-using-winscp-with-rstudio-amazon-ec2 please give me any suggestions on what I am doing wrong:( – user1665355 Jun 07 '13 at 18:49

1 Answers1

9

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...

enter image description here

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)

enter image description here

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

enter image description here

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..."

enter image description here

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

enter image description here

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

enter image description here

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...'

enter image description here

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

enter image description here

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.

Ben
  • 41,615
  • 18
  • 132
  • 227
  • Thank you so much Ben! I am at work right now but I actually did manage to log in with `winSCP` yesterday. I am greatful for your answer!:) Thanks:) – user1665355 Jun 08 '13 at 09:59