81 lines
3.2 KiB
R
81 lines
3.2 KiB
R
|
|
require(rworldmap)
|
||
|
|
require(ggplot2)
|
||
|
|
|
||
|
|
theCountries <- c("DE", "US", "BR")
|
||
|
|
# These are the ISO3 names of the countries you'd like to plot in red
|
||
|
|
|
||
|
|
malDF <- data.frame(country = c("DE", "US", "BR", "ZA"), malaria = c(2000, 2001, 2002, 2002), news = c(2, 3, 0, 1))
|
||
|
|
# malDF is a data.frame with the ISO3 country names plus a variable to
|
||
|
|
# merge to the map data
|
||
|
|
|
||
|
|
malMap <- joinCountryData2Map(malDF, joinCode = "ISO2", nameJoinColumn = "country")
|
||
|
|
# This will join your malDF data.frame to the country map data
|
||
|
|
|
||
|
|
mapCountryData(malMap, nameColumnToPlot="malaria", catMethod = "categorical", missingCountryCol = gray(.8))
|
||
|
|
# And this will plot it, with the trick that the color palette's first
|
||
|
|
# color is red
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
# Absolute Frequ Newsfocus Map --------------------------------------------
|
||
|
|
|
||
|
|
|
||
|
|
# # Absolute Häufigkeiten der Highlights mit Bubbles
|
||
|
|
# malMap <- joinCountryData2Map(cl_supfoc_total, joinCode = "ISO2", nameJoinColumn = "code")
|
||
|
|
# mapBubbles( dF=malMap, nameZSize="total",nameZColour="GEO3major",
|
||
|
|
# colourPalette=c("black", "yellow", "blue", "orange", "red", "white", "green"),
|
||
|
|
# oceanCol="lightblue",
|
||
|
|
# landCol="wheat",
|
||
|
|
# fill=TRUE,
|
||
|
|
# symbolSize=0.5,
|
||
|
|
# pch=21)
|
||
|
|
|
||
|
|
# Absolute Newfokus Häufigkeiten Welt:
|
||
|
|
absMap <- joinCountryData2Map(cl_supfoc_total, joinCode = "ISO2", nameJoinColumn = "code", verbose=TRUE)
|
||
|
|
mapCountryData(absMap, nameColumnToPlot="total", catMethod="fixedWidth",
|
||
|
|
numCats=5,
|
||
|
|
mapTitle="Anzahl Überraschungsfokusse weltweit",
|
||
|
|
oceanCol="lightblue",
|
||
|
|
missingCountryCol=gray(.9)
|
||
|
|
)
|
||
|
|
|
||
|
|
# Absolute Newfokus Häufigkeiten EU-Asien-Nordafrika:
|
||
|
|
mapCountryData(absMap, nameColumnToPlot="total", catMethod="fixedWidth",
|
||
|
|
numCats=5,
|
||
|
|
mapTitle="Anzahl Überraschungsfokusse Nordafrika und Asien",
|
||
|
|
oceanCol="lightblue",
|
||
|
|
missingCountryCol=gray(.9),
|
||
|
|
xlim=c(10,140),
|
||
|
|
ylim=c(30,70)
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
# Development Newsfocus over time -----------------------------------------
|
||
|
|
|
||
|
|
|
||
|
|
# Entwicklung der Surprising Focuses über die Jahre
|
||
|
|
cc <- ggplot(cl_supfoc_turn_mon, aes(month,highs))
|
||
|
|
cc <- cc + geom_histogram(fill="steelblue", stat="identity")
|
||
|
|
cc <- cc + stat_smooth(size=1,colour="red",method="loess", se=FALSE)
|
||
|
|
cc <- cc + ggtitle("Zeitliche Entwicklung von plötzlichen Medienfokussen") + xlab("Einzelne Monate") + ylab("Plötzliche Medienfokusse")
|
||
|
|
cc
|
||
|
|
|
||
|
|
|
||
|
|
# Beispiel1: Jährliche Durchschnittsanzahl 2000-2014 der Nachrichten über Syrien
|
||
|
|
yearspan <- 2000:2014
|
||
|
|
avergdf <- getAverages(df = cl_stats, codecol = "code", code = "SY", yearspan = yearspan)
|
||
|
|
|
||
|
|
averg <- ggplot(data = avergdf, aes(x = year, y=averg))
|
||
|
|
averg + geom_line() + ggtitle("Durchschnittliche Nachrichten pro Jahr über Syrien") + xlab("Jahre") + ylab("Durchschnittliche Nachrichten")
|
||
|
|
|
||
|
|
# Beispiel2: Jährliche Durchschnittsanzahl 2000-2014 der Nachrichten über Israel
|
||
|
|
yearspan <- 2000:2014
|
||
|
|
avergdf <- getAverages(df = cl_stats, codecol = "code", code = "IL", yearspan = yearspan)
|
||
|
|
|
||
|
|
averg <- ggplot(data = avergdf, aes(x = year, y=averg))
|
||
|
|
averg + geom_line() + ggtitle("Durchschnittliche Nachrichten pro Jahr über Israel") + xlab("Jahre") + ylab("Durchschnittliche Nachrichten")
|
||
|
|
|
||
|
|
|
||
|
|
|