import IPython
print 'ipython version is %s'% IPython.release.version
print 'rmagic is >= 0.13, I believe'

%load_ext rmagic

%%R
# you are now dropped down in R;
# which version of R am I using, BTW?
print(R.version)

%%R
# my notebook is wider than the default 80 chars, so set it here:
options(width=300)
# get the survival package if you do not have it:
if (! length(which(.packages(all.available=TRUE) %in% "survival"))) {
    install.packages("survival",repos="http://cran.cnr.berkeley.edu/")
}
library(survival)

%%R
hmohiv<-read.table("http://www.ats.ucla.edu/stat/r/examples/asa/hmohiv.csv", sep=",", header = TRUE)
attach(hmohiv)
print(head(hmohiv))

%%R -w 800 -h 600
# figures work fine, but you may want to set the height and width with the -w and -h flags as above
psymbol<-censor+1
table(psymbol)
plot(age, time, pch=(psymbol))
legend(40, 60, c("Censor=1", "Censor=0"), pch=(psymbol))

%%R
# this is all still cribbed from the UCLA page
test <- survreg( Surv(time, censor) ~ age, dist="exponential")
# note again, you have to explicitly echo
print(summary(test))

%Rpull hmohiv

# for a raw pull, the column information is lost?
hmohiv

%Rpull -d hmohiv

# now it is pulled as something else, but what I am not sure
hmohiv

?Rpull