How to get events per month barplot in R

# generate some random data

dat = data.frame(timestamp = Sys.time() + sort(round(runif(1000, (24*3600), (2*365*24*3600)))))

# create new columns to identify the month and year
dat$month = strftime(dat$time, “%b”)
dat$year = strftime(dat$time, “%Y”)

# count the timestamps per month for each year
library(plyr)
timestamps_month = count(dat, vars = c(“month”,”year”))

# create the plot graph
library(ggplot2)
ggplot(data = timestamps_month) + geom_bar(aes(x = month, y = freq, fill = year), stat=”identity”, position = “dodge”)

 

Here is the result:

Rplot

 

How to remove (almost) everything from the work environment

rm(list=ls())

This command will clear the variables and the loaded libraries. Almost.

If we run ?rm we get the following info:

## remove (almost) everything in the working environment.
## You will get no warning, so don't do this unless you are really sure.
rm(list = ls())

 

 

R 3.2.0 is here

Upgraded to R 3.2.0 today.

From the prompt i used:

install.packages(“installr”);

library(installr)

updateR()