Commit ab3269c5 authored by Weisi Chen's avatar Weisi Chen
Browse files

added sliding window of 12 month

parent 3fa120e1
......@@ -13,44 +13,49 @@ stash <- function(file_rdmp,file_pub,file_record,file_workspace){
names(workspace_df)[length(names(workspace_df))] <- "date_object_created"
#print(substr(rdmp_df[1,]$date_object_created, 2, 11))
rdmp_df$date_object_created = as.Date(substr(rdmp_df$date_object_created, 2, 11))
dataPublication_df$date_object_created = as.Date(substr(dataPublication_df$date_object_created, 2, 11))
dataRecord_df$date_object_created = as.Date(substr(dataRecord_df$date_object_created, 2, 11))
workspace_df$date_object_created = as.Date(substr(workspace_df$date_object_created, 2, 11))
rdmp_df$date_object_created = as.Date(substr(rdmp_df$date_object_created, 1, 11))
dataPublication_df$date_object_created = as.Date(substr(dataPublication_df$date_object_created, 1, 11))
dataRecord_df$date_object_created = as.Date(substr(dataRecord_df$date_object_created, 1, 11))
workspace_df$date_object_created = as.Date(substr(workspace_df$date_object_created, 1, 11))
rdmp_per_month = rdmp_df %>% mutate(month = format(date_object_created, "%m"), year = format(date_object_created, "%Y")) %>%
group_by(month, year) %>%
rdmp_per_month = rdmp_df %>% mutate(month = format(date_object_created, "%m"), year = format(date_object_created, "%Y"), yearmon = paste(year,"-",month,sep=""), group = 1) %>%
group_by(yearmon, group) %>%
tally %>%
group_by(year) %>%
mutate(Total_RDMP = cumsum(n))
dataPub_per_month = dataPublication_df %>% mutate(month = format(date_object_created, "%m"), year = format(date_object_created, "%Y")) %>%
group_by(month, year) %>%
group_by(group) %>%
mutate(Total_RDMP = cumsum(n)) %>%
top_n(12)
dataPub_per_month = dataPublication_df %>% mutate(month = format(date_object_created, "%m"), year = format(date_object_created, "%Y"), yearmon = paste(year,"-",month,sep=""), group = 1) %>%
group_by(yearmon, group) %>%
tally() %>%
group_by(year) %>%
mutate(Total_DataPublication = cumsum(n))
dataRec_per_month = dataRecord_df %>% mutate(month = format(date_object_created, "%m"), year = format(date_object_created, "%Y")) %>%
group_by(month, year) %>%
group_by(group) %>%
mutate(Total_DataPublication = cumsum(n)) %>%
top_n(12)
dataRec_per_month = dataRecord_df %>% mutate(month = format(date_object_created, "%m"), year = format(date_object_created, "%Y"), yearmon = paste(year,"-",month,sep=""), group = 1) %>%
group_by(yearmon, group) %>%
tally() %>%
group_by(year) %>%
mutate(Total_DataRecord = cumsum(n))
workspace_per_month = workspace_df %>% mutate(month = format(date_object_created, "%m"), year = format(date_object_created, "%Y")) %>%
group_by(month, year) %>%
group_by(group) %>%
mutate(Total_DataRecord = cumsum(n)) %>%
top_n(12)
workspace_per_month = workspace_df %>% mutate(month = format(date_object_created, "%m"), year = format(date_object_created, "%Y"), yearmon = paste(year,"-",month,sep=""), group = 1) %>%
group_by(yearmon, group) %>%
tally() %>%
group_by(year) %>%
mutate(Total_Workspace = cumsum(n))
group_by(group) %>%
mutate(Total_Workspace = cumsum(n)) %>%
top_n(12)
output1 <- "rdmp.png"
png(filename=output1)
ggplot(data=rdmp_per_month, aes(x=month, y=Total_RDMP, fill=Total_RDMP)) +
ggplot(data=rdmp_per_month, aes(x=yearmon, y=Total_RDMP, fill=Total_RDMP)) +
geom_bar(stat="identity", position=position_dodge()) +
coord_cartesian(ylim = c(200, max(rdmp_per_month$Total_RDMP))) +
theme(legend.title = element_blank()) +
theme(legend.position = "none")
theme(legend.position = "none") +
geom_text(aes(label=Total_RDMP), vjust=-0.25)
ggsave(output1)
output2 <- "dataPublication.png"
png(filename=output2)
ggplot(data=dataPub_per_month, aes(x=month, y=Total_DataPublication, fill=Total_DataPublication)) +
ggplot(data=dataPub_per_month, aes(x=yearmon, y=Total_DataPublication, fill=Total_DataPublication)) +
geom_bar(stat="identity", position=position_dodge()) +
theme(legend.title = element_blank()) +
theme(legend.position = "none")
......@@ -58,7 +63,7 @@ stash <- function(file_rdmp,file_pub,file_record,file_workspace){
output3 <- "dataRecord.png"
png(filename=output3)
ggplot(data=dataRec_per_month, aes(x=month, y=Total_DataRecord, fill=Total_DataRecord)) +
ggplot(data=dataRec_per_month, aes(x=yearmon, y=Total_DataRecord, fill=Total_DataRecord)) +
geom_bar(stat="identity", position=position_dodge()) +
theme(legend.title = element_blank()) +
theme(legend.position = "none")
......@@ -66,7 +71,7 @@ stash <- function(file_rdmp,file_pub,file_record,file_workspace){
output4 <- "workspace.png"
png(filename=output4)
ggplot(data=workspace_per_month, aes(x=month, y=Total_Workspace, fill=Total_Workspace)) +
ggplot(data=workspace_per_month, aes(x=yearmon, y=Total_Workspace, fill=Total_Workspace)) +
geom_bar(stat="identity", position=position_dodge()) +
theme(legend.title = element_blank()) +
theme(legend.position = "none")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment