data("sTRACE",package="timereg")
sTRACE$age2 <- sTRACE$age^2
sTRACE$age3 <- sTRACE$age^3
mm <- dcut(sTRACE,~age+wmi)
head(mm)
mm <- dcut(sTRACE,catage4+wmi4~age+wmi)
head(mm)
mm <- dcut(sTRACE,~age+wmi,breaks=c(2,4))
head(mm)
mm <- dcut(sTRACE,c("age","wmi"))
head(mm)
mm <- dcut(sTRACE,~.)
head(mm)
mm <- dcut(sTRACE,c("age","wmi"),breaks=c(2,4))
head(mm)
gx <- dcut(sTRACE$age)
head(gx)
## Removes all cuts variables with these names wildcards
mm1 <- drm(mm,c("*.2","*.4"))
head(mm1)
## wildcards, for age, age2, age4 and wmi
head(dcut(mm,c("a*","?m*")))
## with direct asignment
drm(mm) <- c("*.2","*.4")
head(mm)
dcut(mm) <- c("age","*m*")
dcut(mm) <- ageg1+wmig1~age+wmi
head(mm)
############################
## renaming
############################
head(mm)
drename(mm, ~Age+Wmi) <- c("wmi","age")
head(mm)
mm1 <- mm
## all names to lower
drename(mm1) <- ~.
head(mm1)
## A* to lower
mm2 <- drename(mm,c("A*","W*"))
head(mm2)
drename(mm) <- "A*"
head(mm)
dd <- data.frame(A_1=1:2,B_1=1:2)
funn <- function(x) gsub("_",".",x)
drename(dd) <- ~.
drename(dd,fun=funn) <- ~.
names(dd)
Run the code above in your browser using DataLab