# I wanted to briefly revisit a previous post in order to update the graphics.
# The code used in the previous post has also become more useful since the database of guns deaths has tripled since the original post (yay!).
# If you would like to generate your own graph, make sure to use the r code attached to the original post rather than the original post.
Hey Francis. I really liked your post. I have always wondered if it was possible to produce animated graphs in R, and now I see there is a way.ReplyDelete
I just wanted to comment on your use of for-loops when generating the cumulative sum. There is already an R function that does this called cumsum. You could implement it by replacing :
for (i in 1:ndays) gun.deaths$day[gun.deaths$dates==names(deaths.tab)[i]] = i
cum.deaths <- cumsum(deaths.tab)
This would definitely simplify the look of your code, as well as the execution since you wouldn't be using as many for-loops.
Just thought I would throw that out there.
Thanks again for the post!
Honestly, I still feel very new to R and all tips and suggestions help.