Having fun with Ramnath Vaidyanathan's new package rblocks!
# Requirements | |
#sudo apt-get install libcurl4-gnutls-dev # for RCurl on linux | |
#install.packages('RCurl') | |
#install.packages('RJSONIO') | |
library('RCurl') | |
library('RJSONIO') | |
query <- function(querystring) { | |
h = basicTextGatherer() |
Many years ago, I was introduced to R by Cam Webb . At the time, his website contained a list of common data manipulations (original here). This list dated from Cam's early experience with R, and contained the R-help mailing list responses to a series of data manipulations. For a long time, I kept this file as a handy reference. I printed it out. I recommended it to friends.
Now I have been using R for years, and the state of the art has advanced considerably. Particulary, Hadley Wickham's reshape2
and dplyr
packages have transformed the way most useRs manipulate their data. I decided that it would be interesting to revisit my favourite resource and try my hand at solving these problems with tools from these two packages.
library(reshape2)
library(dplyr)
Apparently, there is a simple problem called Fizz buzz which is sometimes used to identify competent programmers. A good opportunity to practice some dplyr
and magrittr
tricks.
library(dplyr)
library(magrittr)
library(knitr)
1:100 %>%
data.frame %>%
Is there an easy way to convert a named list into a dataframe, preserving the elements of the list in a "list-column"?
library(dplyr)
library(magrittr)
## make a random matrix
rand_mat <- function() {
Is there an easy way to convert a named list into a dataframe, preserving the elements of the list in a "list-column"?
library(dplyr)
library(magrittr)
## make a random matrix
rand_mat <- function() {
Nrow <- sample(2:15,1)
Ncol <- sample(2:15,1)
The attached code file provides an easy basic interface to the Wolfram Alpha API. Inspired by the wolframalpha module available for Python.
source("wa_lib.R")