Posts tagged “programming”
Update: WebFaction released today a one-click installed for node.js, obviating Step 2 below. Leaving it in here for posterity.
Shiny “makes it super simple for R users like you to turn analyses into interactive web applications that anyone can use.” It’s a powerful tool with a relatively simple syntax. It’s great for local apps — but I wanted to set up a web-based app that others could access and that wasn’t beholden to Shiny and RStudio’s excellent beta server platform.
I host this site and a few others at WebFaction — an awesome service with little to no downtime, fast servers, and relatively flexible restrictions. Getting Shiny up and running on WebFaction required a little work.
Step 1: SSH into WebFaction. Follow the instructions on their website for your specific server(s).
Step 2: Make a source directory. Download and install node.js.
mkdir src cd src wget 'http://nodejs.org/dist/v0.10.20/node-v0.10.20.tar.gz' tar -xzf node-v0.10.20.tar.gz cd node-v0.10.20 python2.7 configure --prefix=$HOME make PYTHON=python2.7 make PYTHON=python2.7 install export NODE_PATH="$HOME/lib/node_modules:$NODE_PATH" echo 'export NODE_PATH="$HOME/lib/node_modules:$NODE_PATH"' >> $HOME/.bashrc
Step 3: Download and install R.
#install R wget 'http://cran.us.r-project.org/src/base/R-3/R-3.0.2.tar.gz' tar -xzf R-3.0.2.tar.gz cd R-3.0.2 ./configure --prefix $HOME make make install
Step 4: Make a temp/tmp/temporary director.
cd $HOME mkdir tmp chmod 777 tmp TMPDIR=$HOME/tmp export TMPDIR
Step 5: Download Shiny from source and install using NPM.
git clone https://github.com/rstudio/shiny-server.git npm install -g shiny-server/
installing from NPM directly did not work — Shiny would not launch. I believe this is because you’re not allowed root access on WebFaction shared accounts.
Step 6: Launch R and install whatever packages you need.
install.packages('ggplot2') install.packages('data.table') devtools::install_github("ShinyDash", "trestletech") devtools::install_github("shiny-incubator", "rstudio")
Step 7: Want plots to work? In your Shiny app’s global.R file, set
options(bitmapType = 'cairo')
Next up: a cron job to keep a Shiny instance running or to restart it if it goes down… and putting Shiny behind some light authentication to prevent pre-release apps from general consumption.
We’ve gathered hour-by-hour observations from tens of thousands of ground stations world-wide, in some places going back a hundred years. We expose it as a sort of “time machine” that lets you explore the past weather at any given location. We’ve also used the data to develop statistical forecasts for any day in the future. For example, say you have an outdoor family reunion in 6 months: with the time machine, you can see what the likely temperature and precipitation will be at the exact day and hour.
Their API sounds good, too, though I haven’t taken the plunge on that yet.
Now that we’ve developed a general-purpose weather API, we’re trying to compete with the other weather APIs available around the Internet. We’ve found those APIs to be difficult and clunky to use, so we’ve tried to make our API as streamlined as possible: you can sign up for a developer account without needing a credit card, and start making requests right away—you can worry about payment information when your app is ready. Additionally, we’ve lowered our prices so that we’re competitive with the other data providers out there.