Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Date file was retrieved on March 14, 2014, from
- # http://hkupop.hku.hk/chinese/popexpress/ce2012/dataset/tp1403013.sav
- ############################
- # To load in the data file #
- ############################
- # Install the "foreign" package, to read in SPSS files
- install.packages("foreign")
- # Load in the "foreign" package
- library("foreign")
- # Read in the data file
- cy201403 <- read.spss("tp1403013.sav", to.data.frame=T)
- # Check if file has been read in correctly
- head(cy201403)
- ######################
- # Basic descriptions #
- ######################
- # Number of subjects = 1017
- dim(cy201403)[1]
- # Number of raters = 998
- sum(table(cy201403$CE_rating))
- ##################
- # On raw ratings #
- ##################
- # A quick scan of the distribution of the raw ratings
- table(cy201403$CE_rating)
- # Mean of raw ratings = 47.4008
- mean(cy201403$CE_rating, na.rm=T)
- # Median of raw ratings = 50
- median(cy201403$CE_rating, na.rm=T)
- # Histogram of the raw ratings
- hist(cy201403$CE_rating, main="CY Leung's rating (raw), \nMarch 2013",
- xlab="Raw Scores", ylab="Frequency", right=F, axes=F,
- breaks=seq(0, 100, 10), col="lightgray")
- axis(1, at=seq(0, 100, 10))
- axis(2, at=seq(0, 300, 50))
- # Indicate mean on plot
- abline(v=mean(cy201403$CE_rating, na.rm=T), col="red", lwd=4)
- # Indicate median on plot
- abline(v=median(cy201403$CE_rating, na.rm=T), col="blue", lwd=4)
- # Add labels
- text(mean(cy201403$CE_rating, na.rm=T), 200, "Mean", col="red", lwd=4, pos=2)
- text(median(cy201403$CE_rating, na.rm=T), 200, "Median", col="blue", lwd=4, pos=4)
- ######################
- # On weighed ratings #
- ######################
- # Calculate weighed ratings
- cy201403$weighedRating <- cy201403$CE_rating * cy201403$weight
- # Mean of raw ratings = 47.48411
- mean(cy201403$weighedRating, na.rm=T)
- # Median of raw ratings = 41.9557
- median(cy201403$weighedRating, na.rm=T)
- # Histrogram of the weighed ratings
- hist(cy201403$weighedRating, main="CY Leung's rating (weighed), \nMarch 2013",
- xlab="Weighed Scores", ylab="Frequency", right=F, axes=F,
- breaks=seq(0, 500, 10), col="lightgray")
- axis(1, at=seq(0, 500, 50))
- axis(2, at=seq(0, 140, 20))
- # Indicate mean on plot
- abline(v=mean(cy201403$weighedRating, na.rm=T), col="red", lwd=4)
- # Indicate median on plot
- abline(v=median(cy201403$weighedRating, na.rm=T), col="blue", lwd=4)
- # Add labels
- text(mean(cy201403$weighedRating, na.rm=T), 100, "Mean", col="red", lwd=4, pos=4)
- text(median(cy201403$weighedRating, na.rm=T), 100, "Median", col="blue", lwd=4, pos=2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement