library(twitteR) n <- 27 feed <- userTimeline("BeijingAir", n = n) sfeed <- lapply(feed, function(x) strsplit(x$getText(), "; ", fixed = TRUE)) times <- vector("list", length = n) pm25 <- numeric(n) times <- sapply(sfeed, function(x) { paste(x[[1]][1:2], collapse = " ") }) times <- strptime(times, "%m-%d-%Y %H:%M") pm25 <- sapply(sfeed, function(x) { x <- x[[1]] if(length(grep("^Past", x[3])) > 0) return(NA) as.numeric(x[4]) }) u <- !is.na(pm25) times <- times[u] pm25 <- pm25[u] png(file = "beijing24.png", width = 700, height = 480) par(mar = c(2, 4.5, 2, 1) + .1) plot(times, pm25, main = expression(PM[2.5] * " in Beijing"), xlab = "", ylab = expression(PM[2.5] * " (" * mu * g/m^3 * ")"), pch = 19, type = "b") dev.off()