# useR-2010 # Credentials ==== # Account Name aaaaaa # Account Number 1234-5678-1234 # # Access Key ID: AKIAIO445ARJMS4qwerty # Secret Access Key: ISIu7OgJeEHQ6+0Pa8oJVCpyIaDCZW3E4r5t^ # Win pwd: #Check web server is running # Example 1. (Xming, PuTTY) plot(1:4) plot(5:1) x11() plot(1:3) # vnc - also slow #now WinSCP (no need in display tunneling) # Example 2. www – pdf() setwd("/var/www/html") # or setwd("/var/www/") #rename index.html pdf(’z.pdf’) plot(1:4) plot(5:1) dev.off() # Example 3. www – R2HTML() install.packages("R2HTML", repos = "http://cran.stat.ucla.edu/") library(R2HTML) file.remove("/var/www/z.html") fout= HTMLInitFile(outdir = "/var/www/", filename="z", CSSFile="http://www.stat.ucl.ac.be/R2HTML/Pastel.css") data(iris) HTML(as.title("Fisher Iris dataset / Correlation 1"),file=fout) HTML(cor(iris[,1:4]), file=fout) HTML(as.title("Fisher Iris dataset / Correlation 2"),file=fout) HTML.cormat(cor(iris[,1:4]), file=fout) png("gr1.png") plot(exp,-1,2) #dev.off() png("gr2.png") plot(sin,-9,9) dev.off() HTML('exp') HTMLInsertGraph("gr1.png", file=fout, caption="plot exp") #HTML.title('sinus') HTMLInsertGraph("gr2.png", file=fout, caption="plot sin") dev.off() # Example 4. SVG install.packages("RSvgDevice", repos = "http://cran.stat.ucla.edu/") library(RSvgDevice) devSVG(file = "zRplots.svg") #devSVG(file = "zRplots2.svg", width = 10, height = 8, # bg = "white", fg = "black", onefile=F, xmlHeader=TRUE) plot(1:9) #see plot(4:1) dev.off() # local === n=100 x= data.frame(x1= sample(2,n, replace = T) + rnorm(n, 0, .1) , x2= sample(2,n, replace = T) + rnorm(n, 0, .3)) plot(x2~x1, data=x) write.table(x, 'Z:/work/29_Conferences/1101_R/x.txt') y= read.table('Z:/work/29_Conferences/1101_R/x.txt') # remote === y= read.table('x.txt') attach(y) plot(x2~x1) install.packages("cluster", repos = "http://cran.stat.ucla.edu/") library(cluster) pamr <- pam(y, k=4) pamc <- pamr$clustering plot(x1, x2, col=pamc) #clusplot(pamr, color=TRUE, col.clus = 1:4, shade = TRUE, axes=T, labels=0) # names(pamr$ clustering)) clusplot(pamr, color=TRUE, col.clus = 1:4, shade = TRUE, labels=0) # names(pamr$ clustering)) #== Saving a Customised Linux Amazon Instance (EC2 and S3) 1) copy private key and cert key over to the EC2 instance /mnt 2) install a Amazon tool on the instance to allow you to create another AMI and store it # apt-get install unzip #Download the Amazon AMI tools onto the instance. mkdir ~/ec2 cd ~/ec2 wget http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.zip unzip ec2-ami-tools.zip ln -s ec2-ami-tools-* current vi ~/.bashrc #add the following lines to the end of the .bashrc file export EC2_AMITOOL_HOME=~/ec2/current export PATH=${PATH}:~/ec2/current/bin #And then re-initialise the configuration file source ~/.bashrc #should be able to run w/o error: # ec2-bundle-vol --help #Create your AMI.. While still on the server run the following command: ec2-bundle-vol -d /mnt -k /mnt/pk-STRINGOFTHIRTYTWOLETTERSORDIGITS.pem -c /mnt/cert-STRINGOFTHIRTYTWOLETTERSORDIGITS.pem -u XXXXXXXXXXXX # XXXXXXXXXXXX is your Amazon account number without the dashes. # wait 15 min :( #Save your new AMI to S3. ec2-upload-bundle -b [your-s3-bucket] -m /mnt/image.manifest.xml -a [aws-access-key-id] -s [aws-secret-access-key] #If the bucket doesn’t exist, it should create the bucket for you though. The keys are those crazy long keys you use to access S3. #== Register the AMI via GUI or command tool #Go back to your desktop, and issue the command: ec2-register [your_bucket]/image.manifest.xml # Install R on DEBIAN apt-cache search ^r-.* #should get you started with a list of available packages. #add to the file /etc/apt/sources.list on your computer line deb http://cran.mtu.edu/bin/linux/debian lenny-cran/ #or other CRAN mirror URLs listed in http://cran.r-project.org/mirrors.html # After installing R 2.11.0 from CRAN, you will have to update or reinstall all # R packages that have been installed with an R version lower than R 2.10.X apt-get update apt-get install r-base r-base-dev