gender <- read.csv('00_BEG_1_1_5.csv', sep = ";")
age.5.groups <- read.csv('00_BEG_1_5_4.csv', sep=";")
gender.neu <- gender[-1]
names <- c("RK", "EVK", "EVFK", "ORTH", "J", "Sonst", "Keine")
Religion <- names
gender <- cbind(gender.neu,Religion)
p <- ggplot(data=gender, aes(x=Religion, y=Prozent)) +
geom_bar(stat="identity", fill="#099dd9") +
ylab("Prozentsatz der Population") +
xlab(enc2utf8("Religionszugehörigkeit")) +
ggtitle("Verteilung der Religonszugehörigkeit")
plot_ly(p)
#invisible(plotly_POST(p, filename = "r-docs/gender_religion_distribution_germany"))
gender.only <- as.factor(Religion)
gender.only <- gather(gender, "Gender", "n", 3:4)
gender.only <- gender.only[,-1:-2]
total <- sum(gender.only$n)
each.gender.n <- gender.only %>% group_by(Gender) %>% summarize(sum(n))
total.w <- each.gender.n[[2]][[2]]
total.m <- each.gender.n[[2]][[1]]
w.ratio <- total.w / total
m.ratio <- total.m / total
gender.only['Prozent'] <- gender.only$n/total
p1 <- ggplot(gender.only, aes(x=Religion, y=Prozent, fill=Gender)) +
geom_bar(stat='identity', width = 1) +
ylab("Prozentualer Anteil der Gesamtpopulation") +
xlab("Religionszugehörigkeit") +
ggtitle("Verteilung der Religonszugehörigkeit")
plot_ly(p1)
#invisible(plotly_POST(p1, filename = "r-docs/gender_religion_stackedBarplot_germany"))
p2 <- ggplot(gender.only, aes(x=Religion, y=Prozent, fill=Gender)) +
geom_bar(stat='identity', width = 1) +
facet_grid(facets=.~Gender) +
ylab("Prozentualer Anteil des jeweiligen Geschlechts") +
xlab("Religionszugehörigkeit") +
ggtitle("Verteilung der Religonszugehörigkeit")
plot_ly(p2)
## Warning in is.na(e1): is.na() applied to non-(list or vector) of type
## 'NULL'
## Warning in is.na(e1): is.na() applied to non-(list or vector) of type
## 'NULL'
#invisible(plotly_POST(p2, filename = "r-docs/gender_religion_distribution_germany"))
Plotly Pie Chart
p5 <- plot_ly(gender, labels = Religion, values = Anzahl, type = "pie")
p3 <- plot_ly(gender, labels = Religion, values = M, type = "pie")
p4 <- plot_ly(gender, labels = Religion, values = W, type = "pie")
p.atheist <- plot_ly(subset(gender.only, Religion=="Keine"), labels=Gender, values=n, type="pie")
#p3 <- plot_ly(subset(gender.only, Gender=='M'), labels = Religion, values = n, type = "pie")
#p4 <- plot_ly(subset(gender.only, Gender=='W'), labels = Religion, values = n, type = "pie")
p6 <- ggplot(gender.only, aes(x=Gender, y=Prozent, fill=Religion)) +
geom_bar(stat="identity",aes(show.legend=Prozent), width = 1) +
ylab("Anteil in Prozent") +
xlab("Religionszugehörigkeit") +
ggtitle("Verteilung der Religonszugehörigkeit")
p6 <- plot_ly(p6)
p6
## Religionszugehoerigkeit Gesamtpopulation
p5
# Religionszugehoerigkeit Maenner
p3
# Religionszugehoerigkeit Frauen
p4
#Geschlechterverteilung Atheisten
p.atheist
#invisible(plotly_POST(p3, filename = "r-docs/gender_religion_pieChartTotal_germany"))
#invisible(plotly_POST(p4, filename = "r-docs/gender_religion_pieChartFemale_germany"))
#invisible(plotly_POST(p5, filename = "r-docs/gender_religion_pieChartMale_germany"))
#invisible(plotly_POST(p1, filename = "r-docs/gender_religion_stackedBarplot_byGender_germany"))
Is there any gender differences?
# Create data frame split into religious and not religous
religious <- sum(gender$Anzahl[-7])
not.religious <- sum(gender$Anzahl[7])
gender.dif <- as.data.frame(rbind(religious, not.religious))
df.names <- c("religious", "not religious")
rownames(gender.dif) <- df.names
colnames(gender.dif) <- "n"
# Create data frame split into religious male and female population
df <- as.data.frame(cbind(sum(gender[-7,3]),sum(gender[-7,4])))
colnames(df) <- c("M", "W")
df <- rbind(df,gender[7,3:4])
# Addjust rownames for proper merge afterwards
rownames(df) <- rownames(gender.dif)
# Merge data frames now
gender.dif <- cbind(gender.dif, df)
# Clean temporary variables
rm(df.names, df, religious, not.religious)
Familienstand VS Geschl & Alter in Gruppen VS Geschlecht
gender.fam <- read.csv("00_BEV_10_19.csv", sep = ";")
# females only
df.religionist.f <- gender.fam[1:6,10:16]
# sum up the columns and transform the new variable to a data frame
x<-apply(df.religionist.f, 2, function(x){sum(x, na.rm = T)})
df.temp <- tbl_df(as.data.frame(matrix(x, ncol=7)))
names(df.temp) <- names(x)
df.religionist.f <- df.temp
# clean temporary variables
rm(df.temp, x)
# males only
df.religionist.m <- gender.fam[1:6, 3:9]
# sum up the columns and transform the new variable to a data frame
x<-apply(df.religionist.m, 2, function(x){sum(x, na.rm = T)})
df.temp <- tbl_df(as.data.frame(matrix(x, ncol=7)))
names(df.temp) <- names(x)
df.religionist.m <- df.temp
# clean temporary variables
rm(df.temp,x)
atheist.fam <- gender.fam[7,c(-1,-2)]
atheist.fam <- melt(subset(gender.fam[,c(-1,-2)], Religion=="Keine"))
## Using religion as id variables
df.religionist.m <- melt(df.religionist.m)
## No id variables; using all as measure variables
df.religionist.f <- melt(df.religionist.f)
## No id variables; using all as measure variables
# Beziehungsstatus maennliche Atheisten
plot_ly(atheist.fam[1:7,], labels = variable, values=value, type="pie")
# Beziehungsstatus maennlich & Religion zugehoerig
plot_ly(df.religionist.m, labels= variable, values=value, type="pie")
# Beziehungsstatus weibliche Atheisten
plot_ly(atheist.fam[7:14,], labels= variable, values=value, type="pie")
# Beziehungsstatus weiblich & Religion zugehoerig
plot_ly(df.religionist.f, labels= variable, values=value, type="pie")
age.gender.groups <- read.csv("00_BEV_10_15.csv", sep=";")
df <- tbl_df(age.gender.groups[-7:-8,-1])
df <- tbl_df(as.data.frame(apply(df[-2],2,sum)))
Ergebnisse Paper
# Meaningfulness
Religionists <- 3.22
Nones <- 2.95
Atheists <- 2.57
meaning <- data.frame(Condition=factor(c("Religionists", "Nones", "Atheists"),levels=c("Religionists", "Nones", "Atheists")),means=c(Religionists, Nones, Atheists))
ggplot(meaning, aes(y=means, x=Condition)) +
geom_point(aes(color=Condition), size=3) +
stat_summary(fun.y=mean,geom="line", aes(group=1), alpha=.35)+
ylab("Estimated marginal means") +
ggtitle("Degree of meaningfulness (range 0-5),\ncontrolled for sex, age education and family status")

# Frequency of crisis
Religionists <- 4
Nones <- 5
Atheists <- 4
meaning <- data.frame(Condition=factor(c("Religionists", "Nones", "Atheists"),levels=c("Religionists", "Nones", "Atheists")),means=c(Religionists, Nones, Atheists))
ggplot(meaning, aes(x=Condition, y=means, fill=Condition)) +
geom_bar(color="black", stat='identity') +
#stat_summary(fun.y=mean,geom="line", aes(group=1), alpha=.35)+
ylab("% of crisis of meaning") +
ggtitle("Frequencies of crisis of meaning (%)\ncontrolled for sex, age education and family status")

Prepare Table 1 as data frame
Order <-cbind(c(1.78, 2.00, 2.44, 2.30),
c(1.66, 2.69, 3.32, 2.83),
c(1.16, 2.31, 2.57, 3.02),
c(1.51, 2.50, 2.98, 2.84),
c(2.92, 3.42, 3.90, 3.39),
c(2.77, 3.43, 3.74, 3.43))
Selftranscendence <- cbind(c(1.96, 0.13, 1.32, 2.63, 2.03,1.17, 0.72),
c(2.91, 0.40, 2.72, 3.55, 2.87,2.51, 1.72),
c(3.02, 0.16, 2.33, 3.34, 2.33,2.29, 0.87),
c(2.85, 0.29, 2.45, 3.39, 2.61,2.30, 1.34),
c(3.03, 2.49, 3.44, 2.72, 3.23,3.15, 2.73),
c(3.04, 1.01, 3.50, 2.68, 3.19,2.97, 2.09))
Selfactualisation<- cbind(c(1.62, 2.22, 1.84, 2.25, 2.40,2.12, 2.34, 1.24),
c(3.08, 3.47, 2.85, 3.67, 2.90,3.35, 3.49, 2.99),
c(3.01, 3.49, 2.92, 3.61, 2.42,3.74, 4.15, 2.74),
c(2.91, 3.35, 2.77, 3.51, 2.69,3.36, 3.60, 2.73),
c(2.50, 2.83, 2.66, 3.54, 2.90,2.68, 3.29, 2.87),
c(2.71, 2.92, 2.82, 3.65, 2.85,2.87, 3.45, 3.00))
Wellbeing<-cbind(c(2.10, 2.17, 2.13, 2.63,2.28,1.44, 2.04),
c(4.07, 3.76, 3.43, 3.67, 3.90,2.89, 3.73),
c(3.04, 2.78, 2.33, 3.38, 3.13,1.93, 2.67),
c(3.53, 3.28, 2.94, 3.47, 3.48,2.43, 3.21),
c(3.58, 3.27, 2.99, 3.14, 3.80,3.07, 3.83),
c(3.54, 3.31, 2.90, 3.28, 3.64,3.00, 3.73))
df <- data.frame(rbind(Selftranscendence, Selfactualisation,Order,Wellbeing))
colnames(df) <- c("Low-commitment","Broad-commitment","Selfactualization", "Atheists","Religionists","Nones")
rownames(df) <- c("Social commitment", "Explicit religiosity", "Unison with nature", "Self knowledge", "Health", "Generativity", "Spirituality","Challenge", "Individualism", "Power", "Development", "Achievement", "Freedom","Knowledge", "Creativity","Tradition", "Practicality", "Morality","Reason","Community", "Fun", "Love", "Comfort", "Care", "Attentiveness", "Harmony")
df["Var"] <- as.factor(rownames(df))
#df.molten <- melt(df)
Plot sources of meaning while comparing each atheist cluster to religionsts/nones
low <- melt(df, id.vars = "Var", measure.vars = c("Low-commitment", "Religionists", "Nones"))
borad <- melt(df, id.vars = "Var", measure.vars = c("Broad-commitment", "Religionists", "Nones"))
self.actual <- melt(df, id.vars = "Var", measure.vars = c("Selfactualization", "Religionists", "Nones"))
athesits <- melt(df, id.vars = "Var", measure.vars = c("Atheists", "Religionists", "Nones"))
p1 <- ggplot(low, aes(y=value,x=Var,colour=variable,group=variable,shape=variable)) +
#geom_point(aes(color=variable),size=2.5) +
geom_line(data=low[low$variable=="Low-commitment",], aes(x=Var, y=value, colour=variable), size = 1, alpha = .75) +
geom_line(data=low[low$variable!="Low-commitment",], aes(x=Var, y=value, colour=variable), size = .75, alpha = .35) +
scale_y_continuous(breaks=seq(0,5,.75))+
coord_flip() +
scale_colour_discrete(name="Condition")+
scale_shape_discrete(name="Condition")+
scale_linetype_discrete(name="Condition")+
ylab("Mittelwert") +
xlab("")+
ggtitle("'Low-commitment' Atheisten im Vergleich zu 'Religionists' und 'Nones'")+
theme(plot.title = element_text(size=20, face="bold",
margin = margin(30, 0, 30, 0)),
axis.title.y = element_text(face="bold"),
axis.title.x = element_text(face="bold", vjust=0.35))+
geom_text(data=low, aes(Var, value, label=value), size=3, show.legend =F) +
theme_linedraw() +
theme(plot.margin = unit(c(0,2,0,2), "cm"))
p2 <- ggplot(borad, aes(y=value, x=Var, colour=variable, group=variable,shape=variable)) +
#geom_point(aes(color=variable),size=2.5) +
geom_line(data=borad[borad$variable=="Broad-commitment",], aes(x=Var, y=value, colour=variable), size = 1, alpha = .75) +
geom_line(data=borad[borad$variable!="Broad-commitment",], aes(x=Var, y=value, colour=variable), size = .75, alpha = .35) +
scale_y_continuous(breaks=seq(0,5,.75))+
coord_flip() +
scale_colour_discrete(name="Condition")+
scale_shape_discrete(name="Condition")+
scale_linetype_discrete(name="Condition")+
ylab("Mittelwert") +
xlab("")+
ggtitle("'Broad-commitment' Atheisten im Vergleich zu 'Religionists' und 'Nones'")+
theme(plot.title = element_text(size=20, face="bold",
margin = margin(20, 0, 20, 0)),
axis.title.y = element_text(face="bold"),
axis.title.x = element_text(face="bold", vjust=0.35))+
geom_text(data=borad, aes(Var, value, label=value), size=3, show.legend =F) +
theme_linedraw() + theme(plot.margin = unit(c(0,2,0,2), "cm"))
p3 <- ggplot(self.actual, aes(y=value, x=Var, colour=variable, group=variable,shape=variable)) +
#geom_point(aes(color=variable),size=2.5) +
geom_line(data=self.actual[self.actual$variable=="Selfactualization",], aes(x=Var, y=value, colour=variable), size = 1, alpha = .75) +
geom_line(data=self.actual[self.actual$variable!="Selfactualization",], aes(x=Var, y=value, colour=variable), size = .75, alpha = .35) +
scale_y_continuous(breaks=seq(0,5,.75))+
coord_flip() +
scale_colour_discrete(name="Condition")+
scale_shape_discrete(name="Condition")+
scale_linetype_discrete(name="Condition")+
ylab("Mittelwert") +
xlab("")+
ggtitle("'Selfactualization' Atheisten im Vergleich zu 'Religionists' und 'Nones'")+
theme(plot.title = element_text(size=20, face="bold",
margin = margin(30, 0, 30, 0)),
axis.title.y = element_text(face="bold"),
axis.title.x = element_text(face="bold", vjust=0.35),
legend.key=element_rect(fill='pink'))+
geom_text(data=self.actual, aes(Var, value, label=value,color=variable), size=3, show.legend =F) +
theme_linedraw() + theme(plot.margin = unit(c(0,2,0,2), "cm"))
p4 <- ggplot(athesits, aes(y=value, x=Var, colour=variable, group=variable,shape=variable)) +
#geom_point(aes(color=variable),size=2.5) +
geom_line(data=athesits[athesits$variable=="Atheists",], aes(x=Var, y=value, colour=variable), size = 1, alpha = .75) +
geom_line(data=athesits[athesits$variable!="Atheists",], aes(x=Var, y=value, colour=variable), size = .75, alpha = .35) +
scale_y_continuous(breaks=seq(0,5,.75))+
coord_flip() +
ylab("Mittelwert") +
ggtitle("Atheisten insgesamt im Vergleich zu 'Religionists' und 'Nones'")+
scale_colour_discrete(name="Condition")+
scale_shape_discrete(name="Condition")+
scale_linetype_discrete(name="Condition")+
theme(plot.title = element_text(size=20, face="bold",
margin = margin(30, 0, 30, 0)),
axis.title.y = element_text(face="bold"),
axis.title.x = element_text(face="bold", vjust=0.35),
legend.key=element_rect(fill='pink'))+
geom_text(data=athesits, aes(Var, value, label=value), size=3, show.legend =F) +
theme_linedraw()
p1

p2

p3

#grid.arrange(p2,p3, layout_matrix=rbind(c(1,2)))