This page is designed to have a trial run with R, for research and education use only.

Going to use R at work, you should install R into your local PC.

To run Rweb gateway, just type the R (or Splus) code you want to execute into the text code window, choose one of Rweb servers, and then click on the Run button. You will get a new html page with the text output of your code followed by the graphical output (if any) from your code.

Below the text code window is the Ex.Data fields where you can enter the URL for a Web-accessible dataset or browse a dataset file on your computer for sending. Either way, the dataset will be read in using read.table with header=TRUE and stored in a dataframe called X. The dataframe, X, will then be attached so you can use the variable names.

For all webmasters of these hosts

I have no doubt that all of you will allow everyone to use your Rweb as a public resource because actually you made it accessible from anywhere in the internet.

To deny that your Rweb would be accessed from external clients, you should check $ENV{'HTTP_REFERER'}, $ENV{'REMOTE_ADDR'}, and the other environment variables in your Rweb.cgi script, or adopt an alternative to block possible access by outsiders, such as using .htaccess file.

Examples

The manuals and tutorials at the CRAN (Comprehensive R Archive Network) may help you if you are not familiar with R or S language. If you need a little help with R functions you can use the R function help page (this is just the help page included in the R distribution).

If you don't know how to program in R here is a short code snippet that shows you a little bit about what R can do. You should copy the following code and then paste it into the text code window.

A little Regression

# A little Regression
x <- rnorm(100)           # 100 random numbers from a normal(0,1) distribution
y <- exp(x) + rnorm(100)  # an exponential function with error
result <- lsfit(x,y)      # regress x on y and store the results
ls.print(result)          # print the regression results
plot(x,y)                 # pretty obvious what this does
abline(result)            # add the regression line to the plot
lines(lowess(x,y), col=2) # add a nonparametric regression line (a smoother)
hist(result$residuals)    # histogram of the residuals from the regression

Boxplots

# Boxplots
n <- 10
g <- gl(n, 100, n * 100)
x <- rnorm(n * 100) + sqrt(as.integer(g))
boxplot(split(x, g), col = "lavender", notch = TRUE)

Scatter plot matrix

# Scatter plot matrix
data("iris")
pairs(iris[1:4], main = "Edgar Anderson's Iris Data", font.main = 4, 
        pch = 19)
pairs(iris[1:4], main = "Edgar Anderson's Iris Data", pch = 21, 
        bg = c("red", "green3", "blue")[codes(iris$Species)])

Coplots

# Coplots
data(quakes)
coplot(long ~ lat | depth, data = quakes, pch = 21, bg = "green3")

perspective plots

# cited from Eiji Nakama's Rweb-jp, originally written by Hunao.
x <- seq(-10, 10, length= 30)
y <- x
f <- function(x,y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r }
z <- outer(x, y, f)
z[is.na(z)] <- 1
op <- par(bg = "white")
persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue")

Image and contour plots

# Image and contour plots (These are Owww-Ahhh plots)
opar <- par(ask = interactive() && .Device == "X11")
data(volcano)
x <- 10 * (1:nrow(volcano))
x.at <- seq(100, 800, by = 100)
y <- 10 * (1:ncol(volcano))
y.at <- seq(100, 600, by = 100)
image(x, y, volcano, col = terrain.colors(100), axes = FALSE)

rx <- range(x <- 10*1:nrow(volcano))
ry <- range(y <- 10*1:ncol(volcano))
ry <- ry + c(-1,1) * (diff(rx) - diff(ry))/2
tcol <- terrain.colors(12)
par(opar); par(mfrow=c(1,1)); opar <- par(pty = "s", bg = "lightcyan")
plot(x = 0, y = 0,type = "n", xlim = rx, ylim = ry, xlab = "", ylab = "")
u <- par("usr")
rect(u[1], u[3], u[2], u[4], col = tcol[8], border = "red")
contour(x, y, volcano, col = tcol[2], lty = "solid", add = TRUE)
title("A Topographic Map of Maunga Whau", font = 4)
abline(h = 200*0:4, v = 200*0:4, col = "lightgray", lty = 2, lwd = 0.1)
par(opar)

reading in data from a URL

short example, that also illustrates reading in data from a URL.

plot(x, y)
result <- lm(y ~ x)
abline(result)
summary(result)

Use this along with the "URL"
http://www.stat.umn.edu/geyer/somedata.txt

sem

a sample code using sem package, originally posted by Mitsuo Igarashi [fpr 2411]

library(sem)

# lower triangle of covariance matrix
data.cov <- matrix(c(
  0.862,  0,      0,      0,      0,      0,
  0.489,  1.089,  0,      0,      0,      0,
 -0.056, -0.189,  0.606,  0,      0,      0,
 -0.122, -0.222,  0.406,  0.606,  0,      0,
  0.016, -0.044, -0.089, -0.022,  0.262,  0,
  0.067,  0.133, -0.200, -0.167,  0.200,  0.533
), ncol=6, byrow=T)

rownames(data.cov) <- colnames(data.cov) <- c('V1', 'V2', 'V3', 'V4', 'V5', 'V6')

# symbolic 'ram'
data.model <- matrix(c(
 'F1  -> V1', 'a1',  NA,
 'F1  -> V2', 'a1',  NA,
 'F2  -> V3', 'a2',  NA,  
 'F2  -> V4', 'a2',  NA,
 'F3  -> V5', 'a3',  NA,
 'F3  -> V6', 'a3',  NA,
 'V1 <-> V1', 'e1',  NA,
 'V2 <-> V2', 'e1',  NA,
 'V3 <-> V3', 'e2',  NA, 
 'V4 <-> V4', 'e2',  NA,
 'V5 <-> V5', 'e3',  NA,
 'V6 <-> V6', 'e3',  NA,
 'F1 <-> F1',  NA,    1,
 'F2 <-> F2',  NA,    1,
 'F3 <-> F3',  NA,    1,
 'F1 <-> F2', 'f12', NA, 
 'F2 <-> F3', 'f23', NA, 
 'F1 <-> F3', 'f13', NA  
), ncol=3, byrow=T)

data.sem <- sem(data.model, data.cov, 30)

summary(data.sem)
The list of Rweb servers is updated periodically and automatically. Latest update