User Tools

Site Tools


r-tutorial

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
r-tutorial [2011/10/13 00:00]
liuyipei
r-tutorial [2011/10/13 00:07]
liuyipei
Line 12: Line 12:
 # R as a graphics tool # R as a graphics tool
 # Define a vector named cars with five values # Define a vector named cars with five values
-cars <- c(1,3,6,4,9)+my.vector <- c(1,3,6,4,9)
  
-Plot the values in cars with default options +Some basic variables that come with R to play with 
-plot(cars)+head(cars) 
 +dim(cars)
  
-r <- rlnorm(1000) +plot(x=cars$speedy=cars$dist 
-h <- hist(r, plot=F, breaks=c(seq(0, max(r)+1, by=0.1))) +     main="cars", 
-plot(h$counts, +     xlab="speed", 
-     log="xy", +     ylab="dist"
-     pch=20, +hist(cars$speed)
-     col="blue", +
-     main="log-normal distribution", +
-     xlab="Value", +
-     ylab="Frequency")+
  
 # Primitive data types # Primitive data types
Line 181: Line 178:
  
 my.data <- as.matrix(read.table("http://www.stanford.edu/~kjung/my.data.txt", sep="\t")) my.data <- as.matrix(read.table("http://www.stanford.edu/~kjung/my.data.txt", sep="\t"))
-                      
  
 # The columns of a matrix can have symbolic names # The columns of a matrix can have symbolic names
r-tutorial.txt · Last modified: 2011/10/15 12:05 by liuyipei