I am trying to create a frequency graph of the number of occurrences of a graph type by year. I played with ggplot2 for a while, but I think it’s above my head (I’m just starting with R)
I attached a diagram of how I would like the result to look. One of the other problems that I am facing is that there are many years when graph types are not displayed. Is there any way to exclude the type of chart if it is not displayed this year?
eg. in 1940 there is no "sociogram", I do not want to have a bunch of lines at 0 ...
year <- c("1940","1940","1940","1940","1940","1940","1940","1940","1940","1940","1940","1941","1941","1941","1941","1941","1941","1941","1941","1941","1941","1941","1941","1941","1941")
type <- c("Line","Column", "Stacked Column", "Scatter with line", "Scatter with line", "Scatter with line", "Scatter with line", "Map with distribution","Line","Line","Line","Bar","Bar","Stacked bar","Column","Column","Sociogram","Sociogram","Column","Column","Column","Line","Line","Line","Line")
ytmatrix <- cbind(as.Date(as.character(year), "%Y", type))
Please let me know if something doesn't make sense. StackOverflow is fast becoming one of my favorite sites!
Thanks, John
Here is what I still have ... Thanks again for your help!
( , , , ggplot, , , - / ):
AJS = read.csv(data)
Type = AJS[,17]
Year = AJS[,13]
Year = substr(Year,9,12)
Year = as.Date(Year, "%Y")
Year = format(Year, "%Y")
Type = as.data.frame(Type)
yt <- cbind(Year,Type)
library(ggplot2)
trial <- ggplot(yt, aes(Year,..count.., group= Type)) +
geom_density(alpha = 0.25, aes(fill=Type)) +
opts(axis.text.x = theme_text(angle = 90, hjust = 0)) +
opts(title = expression("Trends in the Use of Visualizations in The American Journal of Sociology")) +
scale_y_continuous('Appearances (10 or more)')
trial