C:\Program Files\R\R-2.9.0\bin\R.exeNext you have to open a command prompt (Start > All programs > Accessories > Command prompt). Now type
C:\Program Files\R\R-2.9.0\bin\Rin it. You'll be greeted by the familiar R prompt.
cat("It works!\n") #cat simply prints its arguments without #any embellishment. x = 1:100 print(x)Now open a command prompt and navigate to your desktop folder (which is V:\desktop in the Penn State labs!) Now type
plotR checks if there is a graphics window already open. If it is, then the plot is isplayed there, else a new graphics window is created for the plot. It is possible for the user to explicitly create a new graphics window. In Windows the command is
win.graph()In Linux one could use
x11()Only one of the graphics windows is active at a time, and all subsequent plotting commands will direct their output to it. By default, the most recently created graphics window is the active one. However we can use the function
dev.setto activate some other graphics window.
plot(1:10) #Creates graphics window 1, and plots in it
win.graph() #Creates a new graphics window (blank) plot(1:100) #Draws in the new window
plot(1:3) #Draws again in the same new window
dev.set(2) #Depending on your setting #you may need to change 2 #to something else. The number #is given in the title bar of #the window you want to activate plot(1:5) #Plots in the activated window
evalmay prove handy in such a situation. The
pastefunction combines strings (after converting its arguments to strings, if needed).
paste("X",1:10) paste("X",1:10,sep="") paste("X",1:10,sep="",collapse="+") #Try abbreviating 'collapse'!This function proves particularly useful in conjunction with the
quas = read.table('SDSS_quasar.dat',head=T) names(quas) paste(names(quas),collapse="+")With the
evalfunction you can execute a command. This is useful when the command is parsed from a programmatically generated string.
x = seq(-10,10,.1) comm = 'plot(x,sin(x),ty="l")' eval(parse(text=comm))
install.packages('mclust','v:\\Desktop')The second argument is not needed if you had write-access to the default R package location in your machine. But you do not have that access in the Penn State lab machines. So we are specifying a location that we can write to. You'll be prompted to choose a repository from where to download the package. Choose something close to us (e.g., the one with PA 1 in its name). To load the package type
library('mclust','v:\\Desktop')The main function in this package is
Mclust. Here is a nice document that I pulled off the web. It describes its usage in the context of astronomy.