Example 3 -- More plots created by R

This page is for Linux only!!
  1. About R script
    Here just a demostrate that use PHP to receive and show the plot which automaticly created by R. And all the scripts can be finded in the R Help or see the R website R-project and R-CRAN.

  2. Lowess (cars)

        
      data(cars)
      plot(cars, main = "lowess(cars)")
      lines(lowess(cars), col = 2)
      lines(lowess(cars, f=.2), col = 3)
      legend(5, 120, c(paste("f = ", c("2/3", ".2"))), lty = 1, col = 2:3)
    

    Click here to see the plot created by R.

  3. Kmeans Clustering (2D example)

        
      # a 2-dimensional example
      library(mva)
      x <- rbind(matrix(rnorm(100, sd = 0.3), ncol = 2),
                 matrix(rnorm(100, mean = 1, sd = 0.3), ncol = 2))
      cl <- kmeans(x, 2, 20)
      plot(x, col = cl$cluster)
      points(cl$centers, col = 1:2, pch = 8)
    

    Click here to see the plot created by R.

  4. Hierarchical Clustering

        
      library(mva)
      data(USArrests)
      hc <- hclust(dist(USArrests), "ave")
      plot(hc)
      plot(hc, hang = -1)
    

    Click here to see the plot created by R.

  5. Survival Curve

        
      library(survival)
      data(aml)
      leukemia.surv <- survfit(Surv(time, status) ~ x, data = aml)
      plot(leukemia.surv,lty=1:2,legend.pos=0,col=c("Red","Blue"),
           legend.text=c("Maintenance", "No Maintenance"))
    

    Click here to see the plot created by R.

  6. Scatterplot Matrices

        
      data(iris)
      pairs(iris[1:4], main = "Anderson's Iris Data -- 3 species", 
            pch = 21, bg = c("red", "green3", "blue")[unclass(iris$Species)])
    

    Click here to see the plot created by R.