Does this help?
library(rpart)
#> Warning: package 'rpart' was built under R version 3.5.3
library(rpart.plot) #rep(c(2, 1, 0.4, 0.2), 24)
#> Warning: package 'rpart.plot' was built under R version 3.5.3
set.seed(3465)
#Make data with lambda of 1 and 10,
#A+C and B+D have lambda = 1, B+C and A+D have lambda = 10
df <- data.frame(Time = rep(1, 800), Cnt = c(rpois(200, 1), rpois(200, 10),
rpois(200, 10), rpois(200, 1)),
Attr1 = rep(c("A", "B"), each = 400),
Attr2 = c(rep(c("C", "D"), each = 200), rep(c("C", "D"), each = 200)))
#Fit Cnt only
tree1 <- rpart(Cnt ~ Attr1 + Attr2, data = df, method = "poisson")
rpart.plot(tree1)
##Fit Time and Cnt
tree2 <- rpart(as.matrix(df[, c("Time", "Cnt")]) ~ df[["Attr1"]] + df[["Attr2"]],
method = "poisson")
rpart.plot(tree2)
#double time value
df$Time <- 2
##Fit only Cnt
tree3 <- rpart(Cnt ~ Attr1 + Attr2, data = df, method = "poisson")
rpart.plot(tree3)
##Fit Time and Cnt
tree4 <- rpart(as.matrix(df[, c("Time", "Cnt")]) ~ df[["Attr1"]] + df[["Attr2"]],
method = "poisson")
rpart.plot(tree4, extra = 1)
Created on 2019-06-01 by the reprex package (v0.2.1)