JavaScript Version of Rweb

The Javascript version of Rweb runs in 4 different browser windows and assumes your browser understands JavaScript. To start the Javascript version of Rweb click on the "Open Code Window" buttom below. This will open the window where you type R (or Splus) code. After you have typed in the code you want to execute, just click on the submit button.

At the bottom of the code page is a text area where you can enter the URL for a Web accessible dataset and a browse button for selecting a dataset on your computer. Either way, the dataset will be read in using read.table with header=T and stored in a dataframe called X. The dataframe, X, will then be attached so you can use the variable names.

After your code has be executed three more browser windows will open to display the results.

Once all of the window are open you can keep typing code into the code window, edit what's there, or erase everything and start over. You can cut and paste between an editor window and the code window. You can also cut text or images out of the Rweb windows and paste them into documents (if the document editor supports pasting images).

Here is some R code you can use to test things out.

# 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
n <- 10
g <- gl(n, 100, n * 100)
x <- rnorm(n * 100) + sqrt(codes(g))
boxplot(split(x, g), col = "lavender", notch = TRUE)


# 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
data(quakes)
coplot(long ~ lat | depth, data = quakes, pch = 21, bg = "green3")

#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)

© 1997 Jeff Banfield
Home Page <www.math.montana.edu/~umsfjban>
Email <jeff@math.montana.edu>



Last Modified: 12-Feb-1999