I don’t know why but every time I just write function in R and I get
standardGeneric(“function”)
my mind somehow breaks down and I forget about getMethod(). If you’re like me, just remember this link.
I don’t know why but every time I just write function in R and I get
standardGeneric(“function”)
my mind somehow breaks down and I forget about getMethod(). If you’re like me, just remember this link.
spmR – a SPM port for use in R
So I have been working on porting some functions from FSL into R, and noticed someone has done this for SPM.
Recently, @simplystats recently released the healthvis package http://t.co/mW0yZEs8wy. As such, I finally got up my courage to take a shot at adapting the iris scatterplot matrix brushing example, which is essentially R’s matplot function, in healthvis. I also am “apart” of the group that’s doing this, so I thought it was necessary to show people that it’s possible
Step 1) Read http://healthvis.org/develop/ completely and follow it step by step. I had an old version of Python (2.6) (and a new one, 2.7, installed in a custom directory), so that was somewhat fun. I installed Python fresh again, and also put a symbolic link to python2.7 in /usr/bin (as this was where Google App Engine was looking). For windows users, this isn’t a problem, but Unix – symbolic link means alias/shortcut, (sudo ln -s /Library/Frameworks/Python.framework/Versions/2.7/bin/python /usr/bin/python2.7). Also I believe you have to source the AllClasses.R, healthvisMethods.R IN ORDER otherwise you may get an error.
Step 2) Find your favorite d3 graphic. The d3 gallery has a bunch of examples: https://github.com/mbostock/d3/wiki/Gallery
Step 3) Passing data into d3. Disclaimer, I don’t know much about d3.
So d3.csv (and I think d3.json) passes each row of a “dataset” as a specific element of an array, with the column names as the names of the objects within the element. If that’s confusing, think of a dataset with 3 columns (x, y, z) and 100 rows. When d3 reads that data in, from what I can tell, it has an array of 100 elements, where each element has 3 components, one labeled x, one y, one z, with the values. Also – it seems as though numerics are all passed as strings (at least in my example with d3.js.
Now to do this in R, (see https://gist.github.com/muschellij2/5310615 for code to copy)
this.json = d3Params.json;
this.json = JSON.parse(this.json);
Now, this.json is in the same format as the data you would get from d3.csv. Now wherever you see “data” you put “this.json”. You should be ready to go when you want. Example of output below:
How many times do you hear “That model looks good, but what happens if you add/take out this variable”? I’ve heard it one too many times and I finally have tools to combat this problem.
Introducing my first “out there” Shiny App:
https://github.com/muschellij2/Shiny_model
The app allows you to toggle on/off a set of predictors, and select from a list of outcomes, and presents the GLM of that (hopefully with correct interpretation of estimates). If you want more families, it shouldn’t be hard. It also shows you the generalized added variable plot from `car` package, so you can look at your heart’s desire for non-linearity in your predictors.
Steps to use (in terminal)
git clone https://github.com/muschellij2/Shiny_model.git
(or just download server.R ui.R)
setwd(“DIRECTORY those files are in”)
require(shiny)
runApp()
That’s it! I have loaded up some mock data set in there that mimicked what I was working on, so make sure you don’t think I added real data. Let me know if you like it (I’m not adding more features at this time – just a work in progress). If you want to learn more, check out http://www.rstudio.com/shiny/ and their great tutorials.
Here’s my github repo for embedding RGL in Slidify (and therefore markdown). See it at #ENAR2013.