Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(reshape)
- master = read.csv('0_Masterdokument_Datenuebersicht_master.csv', header=T)
- master <- master[master$msr != 'Schweiz',]
- master$kanton <- factor(master$kanton)
- master$typ_fein <- factor(master$typ_fein)
- master$typ_grob <- NULL # stimmt nicht
- master$sprachregion <- factor(master$sprachregion)
- # add color, typ_grob code to typ_fein
- typgrobcols = data.frame(
- c(1:14),
- c(
- rep(1, 5), # metropolraum
- rep(2, 3), # nichtmetropolitane aglo 1
- rep(3, 2), # nichtmetropolitane aglo 2
- rep(4, 4) # rural
- ),
- c(
- rep(colors()[555], 5), # red, metropolraum
- rep(colors()[130], 3), # blau, nichtmetropolitane aglo 1
- rep(colors()[150], 2), # braun (gelb), nichtmetropolitane aglo 2
- rep(colors()[258], 4) # grün, rural
- ),
- stringsAsFactors=F)
- names(typgrobcols) <- c('typ_fein', 'typ_grob', 'typ_grob_col')
- master <- merge(master, typgrobcols, by=c('typ_fein'))
- ## some summary graphics about MS regions
- plot(c(master$typ_fein), master$bevölkerung, xlab='MS Typologie (klein=städtisch)', xlim=c(14, 1), ylab='Bevölkerung', main='Zusammenhang Bevölkerung / MS Typologie')
- ## scatterplot grundvers/nichtgrundvers dichte : ungefähr
- with(master, plot(grundvers/bevölkerung, nichtgrundvers/bevölkerung, col=typ_grob_col))
- ## plot ärzteverteilung schweiz
- labels <- paste(c('Grundversorger ', 'Spezialisten '), round(x/sum(x) * 100), '%', sep='')
- pie(x, labels, main='Ärzteverteilung Schweiz')
- dev.copy(pdf, 'R/output/aerztevereilung_schweiz.pdf'); dev.off()
- master <- master[order(master$bevölkerung),]
- with(master, barplot((grundvers+nichtgrundvers)/bevölkerung, border='red', density=0))
- master <- master[order(-c(master$typ_fein)),]
- par(new=T)
- with(master, barplot((grundvers+nichtgrundvers)/bevölkerung, border='green', density=0))
- ## boxplot ärzte / typ_grob
- doctors <- with(master, data.frame(typ_grob, grundvers/bevölkerung, nichtgrundvers/bevölkerung, typ_grob_col))
- names(doctors) <- c('typ_grob', 'grundvers', 'nichtgrundvers', 'typ_grob_col')
- doctors <- melt(doctors, id.vars=c('typ_grob', 'typ_grob_col'))
- names(doctors) <- c('typ_grob', 'typ_grob_col', 'which', 'dichte')
- #TODO make sure order typ_grob & typ_grob_colors always matches
- #par(mar=c(8,4,1,1))
- boxplot(dichte~typ_grob*which, data=doctors,
- xaxt='n',
- col=unique(master$typ_grob_col[order(master$typ_grob)]),
- ylab='Versorgungsdichte [Arzt/Einwohner]',
- main='Ärzteverteilung nach MS Regionen Grob Typ')
- axis(1, at=c(2.5, 6.5), tck=0, las=0, labels=c('grundvers', 'nichtgrundvers'))
- dev.copy(pdf, 'R/output/aerztevereilung_typ_grob.pdf'); dev.off()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement