Skip to content

Instantly share code, notes, and snippets.

@hermesh2
Created November 22, 2015 02:39
# S Analysis --------------------------------------------------------------
plotData <- ggplot_build(plot = p)
plotData <- plotData$data
plotData <- plotData[[3]] # Extract the frecuency matrix
head(plotData)
summary(plotData)
plotData[ plotData$count > 500,]
# fill xbin ybin count density ymax ymin yint xmax xmin xint PANEL group
# 69 #A0FF00 (200,250] (350,400] 617 0.05875071 400 350 8 250 200 5 1 1
# 70 #E5ED00 (250,300] (350,400] 697 0.06636831 400 350 8 300 250 6 1 1
# 79 #FF0000 (700,750] (350,400] 942 0.08969720 400 350 8 750 700 15 1 1
# 80 #50FF00 (750,800] (350,400] 537 0.05113312 400 350 8 800 750 16 1 1
# 88 #C5F800 (250,300] (400,450] 658 0.06265473 450 400 9 300 250 6 1 1
plotDataDensity <- data.frame(Square = paste0(plotData$xbin ,"-" , plotData$ybin), Count = plotData$count)
plotDataDensity$Density <- plotDataDensity$Count / sum(plotDataDensity$Count) *100
head(plotDataDensity)
summary(plotDataDensity)
plotDataDensity[ plotDataDensity$Density > 1,]
prop.test(x = c(plotDataDensity$Count[70], plotDataDensity$Count[79]),
n = rep(sum(plotDataDensity$Count),2) )
# 2-sample test for equality of proportions with continuity correction
#
# data: c(plotDataDensity$Count[70], plotDataDensity$Count[79]) out of rep(sum(plotDataDensity$Count), 2)
# X-squared = 39.399, df = 1, p-value = 3.455e-10
# alternative hypothesis: two.sided
# 95 percent confidence interval:
# -0.03067201 -0.01598577
# sample estimates:
# prop 1 prop 2
# 0.06636831 0.08969720
# E Analysis --------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment