Several frequency lines on the same graph, where y is the symbol value

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's a working idea of ​​what I have so far. Here is what I still have ... Thanks again for your help!

( , , , ggplot, , , - / ):

AJS = read.csv(data) #read in file
Type = AJS[,17] #select and name "Type" column from csv
Year = AJS[,13] #select and name "Year" column from csv
Year = substr(Year,9,12) #get rid of junk from year column
Year = as.Date(Year, "%Y") #convert the year character to a date
Year = format(Year, "%Y") #get rid of the dummy month and day
Type = as.data.frame(Type) #create data frame
yt <- cbind(Year,Type) #bind the year and type together
library(ggplot2) 

trial <- ggplot(yt, aes(Year,..count.., group= Type)) + #plot the data followed by aes(x-  axis, y-axis, group the lines)
geom_density(alpha = 0.25, aes(fill=Type)) +
opts(axis.text.x = theme_text(angle = 90, hjust = 0)) + #adjust the x axis ticks to horizontal
opts(title = expression("Trends in the Use of Visualizations in The American Journal of Sociology")) + #Add title
scale_y_continuous('Appearances (10 or more)') #change Y-axis label
trial
+5
1

dataframe :

df1 <- data.frame(date = as.Date(10*365*rbeta(100, .5, .1)),group="a")
 df2 <- data.frame(date = as.Date(10*365*rbeta(50, .1, .5)),group="b")
 df3 <- data.frame(date = as.Date(10*365*rbeta(25, 3,3)),group="c")
 dfrm <- rbind(df1,df2,df3)

, (stat_density) , :

m <- ggplot(dfrm, aes(x=date), group=group)
m+ geom_histogram(aes(y=..density..)) + geom_density(fill=NA, colour="black")

, hte-, @Hadley Wickham, :

m+ geom_density(aes(fill=group), colour="black")

enter image description here

+1

All Articles