1 |
x1 |
|
x2 |
|
op |
|
xlab |
|
ylab |
|
frame.plot |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (x1, x2, op = TRUE, xlab = "X", ylab = "Rel. Freq.",
frame.plot = TRUE)
{
x1 <- x1[!is.na(x1)]
temp1 <- sort(unique(x1))
freq1 <- NA
for (i in 1:length(temp1)) {
freq1[i] <- sum(x1 == temp1[i])
}
x2 <- x2[!is.na(x2)]
temp2 <- sort(unique(x2))
freq2 <- NA
for (i in 1:length(temp2)) {
freq2[i] <- sum(x2 == temp2[i])
}
rmfreq1 = freq1
nval1 = sum(freq1)
freq1 <- freq1/length(x1)
tfreq1 <- freq1
tfreq1[1] <- 0
tfreq1[2] <- max(freq1)
rmfreq2 = freq2
nval2 = sum(freq2)
freq2 <- freq2/length(x2)
tfreq2 <- freq2
tfreq2[1] <- 0
tfreq2[2] <- max(freq2)
plot(c(temp1, temp2), c(tfreq1, tfreq2), xlab = xlab, ylab = ylab,
type = "n", frame.plot = frame.plot)
points(temp1, freq1, pch = "*")
points(temp2, freq2, pch = "o")
if (op) {
lines(temp1, freq1)
lines(temp2, freq2, lty = 2)
list(n1 = nval1, n2 = nval2)
}
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.