Skip to content

Instantly share code, notes, and snippets.

library(ggplot2)
movies <- movies[1:1000,]
m <- ggplot(movies, aes(x=rating))
m + geom_histogram(binwidth=0.2, colour = "darkgreen", fill = "white", size=1) + geom_rug(aes(y=-2), position="jitter", sides="b")
library(ggplot2)
movies <- movies[1:1000,]
m <- ggplot(movies, aes(x=rating))
m + geom_histogram(binwidth=0.2, colour = "darkgreen", fill = "white", size=1) + geom_point(aes(y = -2), position = position_jitter(height = 0.8), size=1)
library(ggplot2)
# create fictitious data
a <- runif(10)
b <- runif(12)
c <- runif(7)
d <- runif(15)
# data groups
group <- factor(rep(1:4, c(10, 12, 7, 15)))
#Type:
# (1) wac36 = Weight-for-age charts, birth to 36 months
# (2) lac36 = Length-for-age charts, birth to 36 months
# (3) wlc = Weight-for-recumbent length charts, birth to 36 months
# (4) hac = Head circumference-for-age charts, birth to 36 months
# (5) wsc = Weight-for-stature charts
# (6) wac20 = Weight-for-age charts, 2 to 20 years
# (7) lac20 = Stature-for-age charts, 2 to 20 years
# (8) bac = BMI-for-age charts, 2 to 20 years
# (9) bmi.adv = wac20 + lac20 + bac (for pdf export)
#Type:
# (1) wac36 = Weight-for-age charts, birth to 36 months
# (2) lac36 = Length-for-age charts, birth to 36 months
# (3) wlc = Weight-for-recumbent length charts, birth to 36 months
# (4) hac = Head circumference-for-age charts, birth to 36 months
# (5) wsc = Weight-for-stature charts
# (6) wac20 = Weight-for-age charts, 2 to 20 years
# (7) lac20 = Stature-for-age charts, 2 to 20 years
# (8) bac = BMI-for-age charts, 2 to 20 years
#
PlayTel <- function(x=character){
# load package
require(sound)
# control if the input is a character
if (!is.character(x)) stop("x must be a character")
# split the input
num <- strsplit(as.character(x), "")
# Sierra3 dithering
Sierra3Convolution <- function(a){
c <- matrix(0, nrow=dim(a)[1], ncol=dim(a)[2])
for(i in 2:(dim(a)[1]-2)){
for(j in 2:(dim(a)[2]-2)){
P <- trunc(a[i,j]+0.5)
e <- a[i,j] - P
# Sierra2 dithering
Sierra2Convolution <- function(a){
c <- matrix(0, nrow=dim(a)[1], ncol=dim(a)[2])
for(i in 2:(dim(a)[1]-2)){
for(j in 2:(dim(a)[2]-2)){
P <- trunc(a[i,j]+0.5)
e <- a[i,j] - P
# Burkes dithering
BurkesConvolution <- function(a){
c <- matrix(0, nrow=dim(a)[1], ncol=dim(a)[2])
for(i in 2:(dim(a)[1]-2)){
for(j in 2:(dim(a)[2]-2)){
P <- trunc(a[i,j]+0.5)
e <- a[i,j] - P
# Stucki dithering
StuckiConvolution <- function(a){
c <- matrix(0, nrow=dim(a)[1], ncol=dim(a)[2])
for(i in 2:(dim(a)[1]-2)){
for(j in 2:(dim(a)[2]-2)){
P <- trunc(a[i,j]+0.5)
e <- a[i,j] - P