Running examples in 'Greg-Ex.R' failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: plotHR
> ### Title: Plot a spline in a Cox regression model
> ### Aliases: plotHR
> 
> ### ** Examples
> 
> library(survival)
> library(rms)
Loading required package: Hmisc
Loading required package: lattice
Loading required package: Formula
Loading required package: ggplot2

Attaching package: 'Hmisc'

The following objects are masked from 'package:base':

    format.pval, units

Loading required package: SparseM

Attaching package: 'SparseM'

The following object is masked from 'package:base':

    backsolve

> 
> # Get data for example
> n <- 1000
> set.seed(731)
> 
> age <- round(50 + 12*rnorm(n), 1)
> label(age) <- "Age"
> 
> sex <- factor(sample(c('Male','Female'), n, 
+     rep=TRUE, prob=c(.6, .4)))
> cens <- 15*runif(n)
> 
> smoking <- factor(sample(c('Yes','No'), n, 
+     rep=TRUE, prob=c(.2, .75)))
> 
> h <- .02*exp(.02*(age-50)+.1*((age-50)/10)^3+.8*(sex=='Female')+2*(smoking=='Yes'))
> dt <- -log(runif(n))/h
> label(dt) <- 'Follow-up Time'
> 
> e <- ifelse(dt <= cens,1,0)
> dt <- pmin(dt, cens)
> units(dt) <- "Year"
> 
> # Add missing data to smoking
> smoking[sample(1:n, round(n*0.05))] <- NA
> 
> # Create a data frame since plotHR will otherwise
> # have a hard time getting the names of the variables
> ds <- data.frame(
+   dt = dt,
+   e = e,
+   age=age, 
+   smoking=smoking,
+   sex=sex)
> 
> library(splines)
> Srv <- Surv(dt,e)
> fit.coxph <- coxph(Srv ~ bs(age, 3) + sex + smoking, data=ds)
> 
> org_par <- par(xaxs="i", ask=TRUE)
> plotHR(fit.coxph, term="age", plot.bty="o", xlim=c(30, 70), xlab="Age")
> 
> dd <- datadist(ds)
> options(datadist='dd')
> fit.cph <- cph(Srv ~ rcs(age,4) + sex + smoking, data=ds, x=TRUE, y=TRUE)
> 
> plotHR(fit.cph, term=1, plot.bty="l", xlim=c(30, 70), xlab="Age")
Error in gendata(list(coefficients = c(age = 0.120429883510454, `age'` = -0.251467218118721,  : 
  factor(s) not in design: Srv
Calls: plotHR ... prPhEstimate -> contrast -> contrast.rms -> do.call -> gendata
Execution halted