# NOT RUN {
data(ver)
ver$Frequency = log(ver$Frequency)
plot(density(ver$Frequency))
# plot separate densities for opaque and transparent words
ver.transp = ver[ver$SemanticClass == "transparent",]$Frequency
ver.opaque = ver[ver$SemanticClass == "opaque", ]$Frequency
ver.transp.d = density(ver.transp)
ver.opaque.d = density(ver.opaque)
xlimit = range(ver.transp.d$x, ver.opaque.d$x)
ylimit = range(ver.transp.d$y, ver.opaque.d$y)
plot(ver.transp.d, lty = 1, col = "black",
xlab = "frequency", ylab = "density",
xlim = xlimit, ylim = ylimit, main = "")
lines(ver.opaque.d, col = "darkgrey")
legend(6,0.25, lty=rep(1,2), col=c("black", "darkgrey"),
legend=c("transparent", "opaque"))
# test whether the difference is significant
ks.test(jitter(ver.transp), jitter(ver.opaque))
# }
Run the code above in your browser using DataLab