dividing the values of data.table1 by data.table2 in R - r

I have created two fictional data.tables which summarise the cost and count of the items that contributed to the cost. I would like to calculate the average item cost = cost/count.
How can i divide the values of the two data.tables ?
combi_sum <- dcast(merge(mtcarsTOTAL[,.(cost, gear)], iris[, .N, .(carb, gear, gender, age)], by = "gear"),
gender + age ~ carb, value.var = "cost", fun.aggregate = sum, fill = 0)
structure(list(gender = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), age = c(1L, 2L,
3L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 11L, 12L, 13L, 14L), `1` = c(978, 978, 0, 0, 1074, 0, 0,
0, 2642, 2642, 0, 0, 0, 0, 3620, 0, 978, 2642, 0, 0, 978, 0,
0, 978, 2052, 0, 0, 0, 0, 1074, 978, 0, 0, 0, 3620, 0), `2` = c(0,
0, 0, 978, 0, 0, 0, 2052, 0, 2642, 978, 0, 0, 0, 0, 0, 0, 0,
1074, 2642, 0, 0, 0, 0, 0, 0, 0, 1074, 0, 978, 0, 2642, 0, 0,
978, 2642), `3` = c(0, 0, 0, 0, 0, 978, 2642, 0, 2642, 0, 0,
2642, 978, 0, 978, 2642, 0, 0, 0, 0, 1074, 3620, 2642, 0, 0,
0, 978, 0, 2642, 0, 0, 2642, 0, 2642, 0, 0), `4` = c(0, 0, 1074,
0, 0, 0, 978, 0, 0, 0, 1074, 1074, 0, 2052, 0, 0, 0, 0, 0, 1074,
0, 2642, 1074, 978, 978, 2642, 0, 0, 2642, 0, 2052, 0, 2642,
1074, 0, 0)), row.names = c(NA, -36L), class = c("data.table",
"data.frame"), .internal.selfref = <pointer: 0x7fb24d802ee0>, sorted = c("gender",
"age"))
combi_length <- dcast(merge(mtcarsTOTAL[,.(cost, gear)], iris[, .N, .(carb, gear, gender, age)], by = "gear"),
gender + age ~ carb, value.var = "cost", fun.aggregate = length, fill = 0)
structure(list(gender = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), age = c(1L, 2L,
3L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 11L, 12L, 13L, 14L), `1` = c(1L, 1L, 0L, 0L, 1L, 0L, 0L,
0L, 1L, 1L, 0L, 0L, 0L, 0L, 2L, 0L, 1L, 1L, 0L, 0L, 1L, 0L, 0L,
1L, 2L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 2L, 0L), `2` = c(0L,
0L, 0L, 1L, 0L, 0L, 0L, 2L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 1L, 0L,
0L, 1L, 1L), `3` = c(0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 1L, 0L,
0L, 1L, 1L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 2L, 1L, 0L, 0L, 0L,
1L, 0L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 0L), `4` = c(0L, 0L, 1L,
0L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 2L, 0L, 0L, 0L, 0L, 0L,
1L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 0L, 2L, 0L, 1L, 1L, 0L,
0L)), row.names = c(NA, -36L), class = c("data.table", "data.frame"
), .internal.selfref = <pointer: 0x7fb24d802ee0>, sorted = c("gender",
"age"))

Here is another option:
combi_sum[combi_length, as.character(1L:4L) := {
m <- unlist(mget(paste0("x.", 1L:4L))) / unlist(mget(paste0("i.", 1L:4L)))
as.data.table(matrix(replace(m, is.nan(m), 0), nrow=.N))
}]
data:
library(data.table)
combi_sum <-
structure(list(gender = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), age = c(1L, 2L,
3L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 11L, 12L, 13L, 14L), `1` = c(978, 978, 0, 0, 1074, 0, 0,
0, 2642, 2642, 0, 0, 0, 0, 3620, 0, 978, 2642, 0, 0, 978, 0,
0, 978, 2052, 0, 0, 0, 0, 1074, 978, 0, 0, 0, 3620, 0), `2` = c(0,
0, 0, 978, 0, 0, 0, 2052, 0, 2642, 978, 0, 0, 0, 0, 0, 0, 0,
1074, 2642, 0, 0, 0, 0, 0, 0, 0, 1074, 0, 978, 0, 2642, 0, 0,
978, 2642), `3` = c(0, 0, 0, 0, 0, 978, 2642, 0, 2642, 0, 0,
2642, 978, 0, 978, 2642, 0, 0, 0, 0, 1074, 3620, 2642, 0, 0,
0, 978, 0, 2642, 0, 0, 2642, 0, 2642, 0, 0), `4` = c(0, 0, 1074,
0, 0, 0, 978, 0, 0, 0, 1074, 1074, 0, 2052, 0, 0, 0, 0, 0, 1074,
0, 2642, 1074, 978, 978, 2642, 0, 0, 2642, 0, 2052, 0, 2642,
1074, 0, 0)), row.names = c(NA, -36L), class = c("data.table",
"data.frame"))
setDT(combi_sum, key=c("gender", "age"))
combi_length <- structure(list(gender = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), age = c(1L, 2L,
3L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 11L, 12L, 13L, 14L), `1` = c(1L, 1L, 0L, 0L, 1L, 0L, 0L,
0L, 1L, 1L, 0L, 0L, 0L, 0L, 2L, 0L, 1L, 1L, 0L, 0L, 1L, 0L, 0L,
1L, 2L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 2L, 0L), `2` = c(0L,
0L, 0L, 1L, 0L, 0L, 0L, 2L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 1L, 0L,
0L, 1L, 1L), `3` = c(0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 1L, 0L,
0L, 1L, 1L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 2L, 1L, 0L, 0L, 0L,
1L, 0L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 0L), `4` = c(0L, 0L, 1L,
0L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 2L, 0L, 0L, 0L, 0L, 0L,
1L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 0L, 2L, 0L, 1L, 1L, 0L,
0L)), row.names = c(NA, -36L), class = c("data.table", "data.frame"
))
setDT(combi_length, key=c("gender", "age"))

Maybe I am misunderstanding, but to divide values of one data.frame by another in R - you literally just divide them. I've created an example dataset to show you:
t1 <- data.frame(A1=c(10,2,4,1,4), B1=c(5,1,8,9,4), C1=c(12,10,10,5,1))
t2 <- data.frame(A2=c(8,2,5,10,1), B2=c(5,6,8,9,1), C2=c(6,5,15,10,12))
To divide t2/t1, you just do that:
t2/t1
Giving you:
A2 B2 C2
1 0.80 1.00 0.5
2 1.00 6.00 0.5
3 1.25 1.00 1.5
4 10.00 1.00 2.0
5 0.25 0.25 12.0
Basically, this can be understood as t1[x,y]/t2[x,y], giving you the answer dataset as t3[x,y]. Make sense? Is that what you were asking?

Related

DLNM: Error: coef/vcov not consistent with basis matrix. See help(crosspred)

I am using distributed lag non-linear models . I ran a glm model with a cross-basis matrix from the DLNM package. When I tried to get the predictions, I got this error:
Error in crosspred(cbpm1, Tp1, by = 1, bylag = 1, at = speimin:speimax) :
coef/vcov not consistent with basis matrix. See help(crosspred).
This happened when I tried lag 1,2, and 3, but there was no error when I tried lag 0, 4, and 5. I read about a similar question from this link. But still, I cannot figure it out with my own code. Your help is really meaningful for me. Thanks.
The code is:
Dis <- ss$dis1
vkt <- equalknots(ss$T,nk=2)
lkt = logknots(1,nk=2)
vkpm <- equalknots(ss$spei3,nk=2)
lkpm <- logknots(1,nk=2)
speimin <- min(ss$spei3, na.rm = TRUE)
speimax <- max(ss$spei3, na.rm = TRUE)
cbt1 = crossbasis(ss$T, lag=1, argvar=list(fun="bs",degree=2,knots=vkt), arglag=list(knots=lkt))
cbpm1 <- crossbasis(ss$spei3, lag=1, argvar=list(fun="bs",degree=2,knots=vkpm), arglag=list(knots=lkpm))
Tp1 <- glm(Dis ~ cbt1 + cbpm1 + ns(RH,3)+ns(timeseries,2*5),
family=poisson(link=log),ss)
at=speimin:speimax
predsltp1 <- crosspred(cbpm1,Tp1,by=1,bylag=1,at=speimin:speimax)
Here is the used library:
library(splines);library(class);library(stats);library(mda)
library(akima);library(gam);library(mgcv);library(foreign);library(som)
library(dlnm) #equalknots logknots crossbasis
library(splines) #ns
library(magrittr)
Here is the reproducible sample of my dataset:
a<-structure(list(job = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "all", class = "factor"),
age3 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L), .Label = "00_05", class = "factor"),
sexA = structure(c(1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L,
2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L,
2L, 1L, 2L, 2L, 1L), .Label = c("F", "M"), class = "factor"),
All = c(65L, 53L, 92L, 68L, 81L, 103L, 144L, 92L, 44L, 40L,
54L, 19L, 55L, 61L, 72L, 89L, 77L, 68L, 71L, 27L, 15L, 18L,
39L, 52L, 52L, 58L, 27L, 44L, 32L, 37L), dis1 = c(6L, 0L,
9L, 0L, 0L, 0L, 9L, 0L, 3L, 6L, 3L, 0L, 0L, 3L, 6L, 0L, 9L,
3L, 0L, 3L, 6L, 0L, 0L, 0L, 0L, 0L, 3L, 0L, 0L, 0L), dis2 = c(3L,
6L, 0L, 0L, 0L, 0L, 0L, 3L, 0L, 0L, 0L, 3L, 0L, 0L, 6L, 6L,
0L, 0L, 0L, 3L, 3L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
T = c(20.39032258, 20.39032258, 19.78387097, 19.78387097,
19.64193548, 19.64193548, 18.78709677, 18.78709677, 19.17419355,
19.17419355, 20.46774194, 21.63870968, 21.85806452, 21.85806452,
19.73448276, 19.73448276, 20.55357143, 20.55357143, 19.925,
29.12580645, 29.12580645, 29.39354839, 29.39354839, 28.96129032,
28.96129032, 27.36666667, 27.40333333, 27.40333333, 27.82333333,
27.82333333), RH = c(70.09677419, 70.09677419, 70.03225806,
70.03225806, 70.35483871, 70.35483871, 72.32258065, 72.32258065,
69.80645161, 69.80645161, 74.58064516, 77.58064516, 71.32258065,
71.32258065, 75.82758621, 75.82758621, 62.28571429, 62.28571429,
72.60714286, 77.61290323, 77.61290323, 75.06451613, 75.06451613,
75.61290323, 75.61290323, 76.03333333, 76.23333333, 76.23333333,
75.03333333, 75.03333333), PP = c(11.5, 11.5, 44.5, 44.5,
25.9, 25.9, 14, 14, 5, 5, 35.7, 34.1, 30.8, 30.8, 44.4, 44.4,
15.6, 15.6, 40.7, 184, 184, 137.1, 137.1, 377, 377, 110.5,
129.8, 129.8, 292, 292), spei3 = c(0.447495072, 0.447495072,
1.537295165, 1.537295165, 1.285067571, 1.285067571, 0.441010834,
0.441010834, 1.505630159, 1.505630159, 1.725831329, 1.075029338,
-1.227673724, -1.227673724, 0.329690702, 0.329690702, 0.724314874,
0.724314874, 1.228544608, 0.60782059, 0.60782059, 0.191804009,
0.191804009, 1.752145476, 1.752145476, 1.94554333, 1.139058482,
1.139058482, -0.554472376, -0.554472376), timeseries = 1:30), class = "data.frame", row.names = c(NA,
-30L))

How can I apply restrictions and limited accessibility to inputs based on values from other inputs in Shiny?

I am completely new to shiny, and I am trying to create a quite simple app as part of learning it.
Questions:
(1) how can I apply a restriction on the sliderInput("n.sygdom" ...)? The intention is that the user receives an error if one chooses a value greater than the one set in sliderInput("n.fjernet" ...)?
(2) how can I make the radioButtons("ecs" ...) and radioButtons("contra.pos" ...) accessible only if sliderInput("n.sygdom" ...) ≥ 1? Preferable, if sliderInput("n.sygdom" ...)==0, then the radioButtons should be "removed" from the shinyapp
The shinyapp works by calculating a nomogram-score, which can be used to predict overall survival. It contains four components:
(1) n.fjernet is the number of lymph nodes removed on the cervical neck
(2) n.sygdom is the number of lymph nodes with evidence of cancer metastises. Therefore, n.sygdom cannot exceed the number of n.fjernet. If the user tries to choose n.sygdom greater than n.fjernet, the shinyapp should return: Error: Number of positive lymph nodes cannot exceed the lymph nodal yield (written in red)
(3) ecs is extracapsular spread (of metastises, i.e. the metastises penetrating one or more of the lymph nodes) in n.sygdom. Therefore, this option can only be available if n.sygdom ≥ 1
(4) contra.pos is whether the spread (of metastises) includes the uni- or contralateral side of the neck. Therefore, this option is only be available if n.sygdom ≥ 1.
The app function estimates the nomogram-score based on values stored in nom - which is attached below. If n.sygdom equals 0, and therefore unable access to ecs and contra.pos, then ecs and contra.pos should generate/add 0 to the calc_score printed in output$out.score <- renderText(calc_score()), i.e. exclusion from the nomogram.
My script
library(shiny)
library(survminer)
ui <- fluidPage(
titlePanel("Survival Curve"),
sidebarLayout(
sidebarPanel(
sliderInput("n.fjernet", "Lymph Nodal Yield", min = 2, max = 150, value = 30),
sliderInput("n.sygdom", "Number of positive lymph nodes", min = 0, max = 40, value = 0),
radioButtons("ecs", "Extracapsular extension", c("No","Yes")),
radioButtons("contra.pos", "Neck involvement", c("Contra.","Ipsi.")),
verbatimTextOutput("out.score"),
verbatimTextOutput("out.score.group")
),
mainPanel(
plotOutput("surv_plot")
)
)
)
server <- function(input, output, session) {
calc_score <- reactive({
round(nom$ecs$points[nom$ecs$ecs==input$ecs] +
nom$contra.pos$points[nom$contra.pos$contra.pos==input$contra.pos] +
nom$n.fjernet$points[nom$n.fjernet$n.fjernet==input$n.fjernet] +
nom$n.sygdom$points[nom$n.sygdom$n.sygdom==input$n.sygdom],digits=1)
})
calc_score_group <- function(score) {
cut(score, c(0,35.9,55.2,70.0,83.3,Inf), include.lowest = TRUE, labels = c("1","2","3","4","5"))
}
fit_data <- reactive({
p %>% filter(score.group == as.numeric(calc_score_group(calc_score())))
})
fit_model <- reactive({
survfit(Surv(os.neck, mors) ~ 1, data = fit_data())
})
output$out.score <- renderText(calc_score())
output$out.score.group <- renderText(calc_score_group(calc_score()))
output$surv_plot <- renderPlot({
ggsurvplot(
fit_model(),
data = fit_data(),
risk.table = TRUE,
pval = F,
pval.coord = c(0, 0.25),
conf.int = T,
size=1,
xlim = c(0,60),
conf.int.alpha=c(0.2),
break.x.by = 6,
xlab="Time in months",
ylab="Probability of overall survival",
ggtheme = theme,
surv.median.line = "v",
ylim=c(0,1),
palette="#2C77BF",
tables.theme=theme,
legend.title=paste("Score group", calc_score_group(calc_score())),
surv.scale="percent",
tables.col="strata",
risk.table.col = "strata",
risk.table.y.text = FALSE,
tables.y.text = FALSE)
})
}
shinyApp(ui, server)
My data (now with p$score.group)
p <- structure(list(contra.pos = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L,
2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L,
1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L,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c("No", "Yes"), class = "factor"), n.fjernet = c(22L,
61L, 50L, 47L, 30L, 60L, 82L, 60L, 33L, 67L, 35L, 56L, 15L,
37L, 44L, 124L, 41L, 30L, 31L, 35L, 36L, 28L, 39L, 54L, 25L,
27L, 69L, 53L, 24L, 33L, 52L, 77L, 51L, 7L, 22L, 53L, 26L,
58L, 28L, 83L, 39L, 15L, 37L, 27L, 9L, 17L, 32L, 26L, 44L,
52L, 22L, 62L, 53L, 68L, 52L, 38L, 50L, 21L, 41L, 74L, 15L,
26L, 36L, 37L, 34L, 22L, 31L, 53L, 13L, 44L, 43L, 51L, 20L,
21L, 63L, 40L, 25L, 17L, 43L, 47L, 35L, 21L, 4L, 23L, 35L,
50L, 69L, 24L, 38L, 45L, 37L, 35L, 25L, 19L, 43L, 19L, 33L,
38L, 50L, 21L, 40L, 100L, 45L, 53L, 41L, 7L, 75L, 48L, 20L,
11L, 72L, 37L, 34L, 70L, 20L, 47L, 44L, 45L, 48L, 23L, 27L,
24L, 39L, 9L, 34L, 22L, 89L, 40L, 35L, 34L, 61L, 28L, 27L,
62L, 47L, 13L, 20L, 9L, 27L, 38L, 44L, 15L, 33L, 65L, 31L,
49L, 53L, 15L, 26L, 17L, 24L, 20L, 25L, 12L, 34L, 22L, 27L,
14L, 27L, 31L, 26L, 15L, 16L, 30L, 19L, 51L, 12L, 33L, 68L,
26L, 20L, 34L, 31L, 7L, 76L, 7L, 24L, 36L, 22L, 27L, 35L,
64L, 18L, 38L, 10L, 27L, 26L, 47L, 15L, 30L, 30L, 21L, 31L,
14L, 14L, 22L, 28L, 13L, 17L, 16L, 7L, 11L, 37L, 55L, 13L,
26L, 17L, 12L, 44L, 58L, 20L, 28L, 7L, 24L, 10L, 42L, 39L,
14L, 31L, 49L), n.sygdom = c(1L, 2L, 1L, 3L, 1L, 0L, 3L,
0L, 2L, 1L, 4L, 4L, 1L, 0L, 2L, 2L, 1L, 0L, 0L, 4L, 0L, 0L,
1L, 1L, 0L, 1L, 4L, 3L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, 1L,
0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 0L, 1L, 0L, 1L,
0L, 0L, 1L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L,
0L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 1L, 0L, 1L, 0L, 0L, 1L, 1L,
1L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 1L, 1L, 0L, 0L, 0L, 0L,
0L, 1L, 0L, 1L, 1L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 1L,
0L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 1L, 1L, 0L, 0L, 0L,
0L, 0L, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 0L,
0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 1L,
0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 1L,
1L, 0L, 0L, 1L, 0L, 1L), os.neck = c(9.63, 7.03, 9.17, 10.48,
7.69, 15.18, 13.5, 16.33, 15.31, 12.09, 12.35, 22.28, 15.77,
14.39, 10.02, 14.52, 8.44, 23.82, 5.95, 3.78, 19.32, 20.14,
15.51, 19.78, 12.98, 32.92, 9.76, 5.65, 30.75, 2.79, 33.58,
27.53, 27.63, 14.62, 29.17, 25.4, 18.43, 5.29, 30.75, 28.48,
14.69, 13.14, 6.6, 26.81, 40.74, 11.63, 13.31, 10.41, 9.56,
17.51, 35.78, 35.75, 37.62, 33.25, 36.96, 34.56, 40.05, 41.26,
24.34, 37.49, 40.94, 24.11, 39.33, 11.24, 39.1, 19.75, 38.93,
39.36, 36.34, 48, 29.17, 47.93, 3.68, 24.21, 46.36, 49.12,
50.96, 14.16, 54.01, 19.88, 50.86, 1.87, 54.24, 13.93, 11.6,
10.05, 23.1, 62.78, 12.58, 39, 59.83, 6.77, 60.39, 18.46,
61.77, 58.41, 49.45, 64.26, 2.4, 26.51, 58.94, 69.91, 64.66,
55.56, 46.55, 29.63, 55.66, 19.68, 7.62, 2.73, 17.77, 10.12,
9.95, 74.22, 57.3, 58.94, 27.01, 34.23, 78.82, 27.2, 83.02,
76.68, 58.15, 22.18, 14.49, 3.91, 25.92, 74.64, 66.83, 70.74,
38.08, 7.69, 74.55, 49.94, 11.1, 88.54, 6.44, 79.54, 80.82,
70.83, 12.91, 81.25, 17.38, 29.96, 94.72, 73.53, 72.54, 1.35,
89.69, 62.85, 7.62, 93.27, 5.09, 51.25, 62, 55.33, 44.62,
56.94, 94.55, 88.61, 32.46, 11.04, 16.53, 100.04, 24.74,
24.54, 5.75, 59.83, 59.83, 77.77, 92.78, 49.58, 91.2, 1.18,
18.92, 6.34, 32.46, 72.41, 105.82, 1.84, 12.78, 57.56, 59.14,
104.08, 15.54, 117.75, 4.27, 67.61, 19.78, 112.49, 53.59,
107.01, 47.57, 9.46, 53.59, 46.46, 57.33, 18.76, 82.04, 13.67,
67.45, 28.98, 21.19, 121.4, 91.07, 50.83, 121.72, 123.04,
6.31, 123.5, 58.68, 9.56, 34.1, 90.48, 71.1, 11.33, 65.35,
54.21, 34.99, 62.06), score = c(47.16, 47.55, 39.27, 72.23,
44.91, 25.74, 62.36, 25.74, 55.44, 34.48, 82.32, 76.4, 60.64,
32.22, 52.34, 36.13, 41.81, 34.2, 33.91, 65.66, 32.51, 34.76,
42.37, 38.14, 35.61, 45.75, 61.23, 59.04, 46.6, 33.35, 84.05,
26.5, 38.99, 62.89, 47.16, 38.42, 35.32, 37.01, 56.85, 29.96,
31.66, 60.52, 42.93, 35.04, 62.21, 37.86, 64.96, 35.32, 40.96,
38.71, 47.16, 58.77, 27.71, 54.81, 50.09, 42.65, 28.56, 36.73,
31.1, 43.88, 38.43, 78.15, 32.51, 32.22, 33.07, 47.16, 44.63,
27.71, 38.99, 40.96, 68.56, 28.28, 37.02, 58.83, 58.48, 42.09,
46.32, 37.86, 30.53, 60.73, 55, 77.47, 41.53, 36.17, 32.79,
71.38, 56.79, 57.98, 76.32, 29.97, 63.55, 123.86, 35.61,
59.39, 41.24, 37.3, 33.35, 37.5, 39.27, 58.83, 53.47, 52.02,
35.52, 27.71, 31.1, 51.39, 21.51, 83.34, 37.02, 39.55, 50.79,
91.42, 33.07, 63.65, 70.61, 51.62, 52.34, 29.97, 29.12, 36.17,
35.04, 85.42, 31.66, 40.12, 55.28, 90.67, 51.15, 53.47, 43.5,
55.16, 47.67, 34.76, 35.04, 35.89, 98.47, 38.99, 59.23, 40.12,
57.25, 31.94, 52.46, 49.14, 33.35, 92.46, 33.91, 50.93, 49.8,
38.43, 57.42, 37.86, 35.89, 47.73, 57.82, 39.27, 33.07, 36.45,
57.13, 70.03, 57.25, 71.95, 35.32, 60.64, 38.14, 71.76, 91.52,
61.15, 39.27, 33.35, 56.36, 35.32, 47.73, 43.78, 33.91, 62.77,
75.44, 51.39, 78.71, 78.39, 47.16, 45.75, 55, 24.61, 37.58,
42.65, 62.05, 35.04, 35.32, 51.62, 38.43, 34.2, 34.2, 42.29,
33.91, 49.42, 60.8, 36.45, 56.97, 61.2, 37.86, 38.14, 40.68,
61.77, 54.43, 27.15, 49.7, 46.04, 60.07, 39.27, 130.25, 59.89,
37.02, 40.32, 40.68, 69.48, 39.84, 73.64, 53.87, 60.92, 71.95,
51.05), score.group = structure(c(2L, 2L, 2L, 4L, 2L, 1L,
3L, 1L, 3L, 1L, 4L, 4L, 3L, 1L, 2L, 2L, 2L, 1L, 1L, 3L, 1L,
1L, 2L, 2L, 1L, 2L, 3L, 3L, 2L, 1L, 5L, 1L, 2L, 3L, 2L, 2L,
1L, 2L, 3L, 1L, 1L, 3L, 2L, 1L, 3L, 2L, 3L, 1L, 2L, 2L, 2L,
3L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 4L, 1L, 1L, 1L, 2L,
2L, 1L, 2L, 2L, 3L, 1L, 2L, 3L, 3L, 2L, 2L, 2L, 1L, 3L, 2L,
4L, 2L, 2L, 1L, 4L, 3L, 3L, 4L, 1L, 3L, 5L, 1L, 3L, 2L, 2L,
1L, 2L, 2L, 3L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 5L, 2L, 2L, 2L,
5L, 1L, 3L, 4L, 2L, 2L, 1L, 1L, 2L, 1L, 5L, 1L, 2L, 3L, 5L,
2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 5L, 2L, 3L, 2L, 3L, 1L, 2L,
2L, 1L, 5L, 1L, 2L, 2L, 2L, 3L, 2L, 1L, 2L, 3L, 2L, 1L, 2L,
3L, 4L, 3L, 4L, 1L, 3L, 2L, 4L, 5L, 3L, 2L, 1L, 3L, 1L, 2L,
2L, 1L, 3L, 4L, 2L, 4L, 4L, 2L, 2L, 2L, 1L, 2L, 2L, 3L, 1L,
1L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 3L, 2L, 3L, 3L, 2L, 2L, 2L,
3L, 2L, 1L, 2L, 2L, 3L, 2L, 5L, 3L, 2L, 2L, 2L, 3L, 2L, 4L,
2L, 3L, 4L, 2L), .Label = c("1", "2", "3", "4", "5"), class = "factor")), row.names = c(NA,
220L), class = "data.frame")
And
# plot(nom) for nomogram
nom <- structure(list(n.fjernet = structure(list(n.fjernet = c(2, 3,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
127, 128, 129, 130, 131, 132, 133), Xbeta = c(`1` = -0.0114560716414661,
`2` = -0.0171841074621991, `3` = -0.0229121432829322, `4` = -0.0286401791036652,
`5` = -0.0343682149243983, `6` = -0.0400962507451313, `7` = -0.0458242865658644,
`8` = -0.0515523223865974, `9` = -0.0572803582073305, `10` = -0.0630083940280635,
`11` = -0.0687364298487966, `12` = -0.0744644656695296, `13` = -0.0801925014902627,
`14` = -0.0859205373109957, `15` = -0.0916485731317288, `16` = -0.0973766089524618,
`17` = -0.103104644773195, `18` = -0.108832680593928, `19` = -0.114560716414661,
`20` = -0.120288752235394, `21` = -0.126016788056127, `22` = -0.13174482387686,
`23` = -0.137472859697593, `24` = -0.143200895518326, `25` = -0.148928931339059,
`26` = -0.154656967159792, `27` = -0.160385002980525, `28` = -0.166113038801258,
`29` = -0.171841074621991, `30` = -0.177569110442725, `31` = -0.183297146263458,
`32` = -0.189025182084191, `33` = -0.194753217904924, `34` = -0.200481253725657,
`35` = -0.20620928954639, `36` = -0.211937325367123, `37` = -0.217665361187856,
`38` = -0.223393397008589, `39` = -0.229121432829322, `40` = -0.234849468650055,
`41` = -0.240577504470788, `42` = -0.246305540291521, `43` = -0.252033576112254,
`44` = -0.257761611932987, `45` = -0.26348964775372, `46` = -0.269217683574453,
`47` = -0.274945719395186, `48` = -0.280673755215919, `49` = -0.286401791036652,
`50` = -0.292129826857386, `51` = -0.297857862678119, `52` = -0.303585898498852,
`53` = -0.309313934319585, `54` = -0.315041970140318, `55` = -0.320770005961051,
`56` = -0.326498041781784, `57` = -0.332226077602517, `58` = -0.33795411342325,
`59` = -0.343682149243983, `60` = -0.349410185064716, `61` = -0.355138220885449,
`62` = -0.360866256706182, `63` = -0.366594292526915, `64` = -0.372322328347648,
`65` = -0.378050364168381, `66` = -0.383778399989114, `67` = -0.389506435809847,
`68` = -0.39523447163058, `69` = -0.400962507451313, `70` = -0.406690543272047,
`71` = -0.41241857909278, `72` = -0.418146614913513, `73` = -0.423874650734246,
`74` = -0.429602686554979, `75` = -0.435330722375712, `76` = -0.441058758196445,
`77` = -0.446786794017178, `78` = -0.452514829837911, `79` = -0.458242865658644,
`80` = -0.463970901479377, `81` = -0.46969893730011, `82` = -0.475426973120843,
`83` = -0.481155008941576, `84` = -0.486883044762309, `85` = -0.492611080583042,
`86` = -0.498339116403775, `87` = -0.504067152224508, `88` = -0.509795188045241,
`89` = -0.515523223865974, `90` = -0.521251259686707, `91` = -0.526979295507441,
`92` = -0.532707331328174, `93` = -0.538435367148907, `94` = -0.54416340296964,
`95` = -0.549891438790373, `96` = -0.555619474611106, `97` = -0.561347510431839,
`98` = -0.567075546252572, `99` = -0.572803582073305, `100` = -0.578531617894038,
`101` = -0.584259653714771, `102` = -0.589987689535504, `103` = -0.595715725356237,
`104` = -0.60144376117697, `105` = -0.607171796997703, `106` = -0.612899832818436,
`107` = -0.618627868639169, `108` = -0.624355904459902, `109` = -0.630083940280635,
`110` = -0.635811976101369, `111` = -0.641540011922102, `112` = -0.647268047742835,
`113` = -0.652996083563568, `114` = -0.658724119384301, `115` = -0.664452155205034,
`116` = -0.670180191025767, `117` = -0.6759082268465, `118` = -0.681636262667233,
`119` = -0.687364298487966, `120` = -0.693092334308699, `121` = -0.698820370129432,
`122` = -0.704548405950165, `123` = -0.710276441770898, `124` = -0.716004477591631,
`125` = -0.721732513412364, `126` = -0.727460549233097, `127` = -0.73318858505383,
`128` = -0.738916620874563, `129` = -0.744644656695296, `130` = -0.750372692516029,
`131` = -0.756100728336763, `132` = -0.761828764157496), points = c(`1` = 27.84103949255,
`2` = 27.6285124735229, `3` = 27.4159854544958, `4` = 27.2034584354687,
`5` = 26.9909314164416, `6` = 26.7784043974145, `7` = 26.5658773783874,
`8` = 26.3533503593603, `9` = 26.1408233403332, `10` = 25.9282963213061,
`11` = 25.715769302279, `12` = 25.5032422832519, `13` = 25.2907152642248,
`14` = 25.0781882451977, `15` = 24.8656612261706, `16` = 24.6531342071435,
`17` = 24.4406071881164, `18` = 24.2280801690893, `19` = 24.0155531500622,
`20` = 23.8030261310351, `21` = 23.590499112008, `22` = 23.3779720929809,
`23` = 23.1654450739538, `24` = 22.9529180549267, `25` = 22.7403910358996,
`26` = 22.5278640168725, `27` = 22.3153369978454, `28` = 22.1028099788183,
`29` = 21.8902829597912, `30` = 21.6777559407641, `31` = 21.465228921737,
`32` = 21.2527019027099, `33` = 21.0401748836828, `34` = 20.8276478646557,
`35` = 20.6151208456286, `36` = 20.4025938266015, `37` = 20.1900668075744,
`38` = 19.9775397885473, `39` = 19.7650127695202, `40` = 19.5524857504931,
`41` = 19.339958731466, `42` = 19.1274317124389, `43` = 18.9149046934118,
`44` = 18.7023776743847, `45` = 18.4898506553576, `46` = 18.2773236363305,
`47` = 18.0647966173034, `48` = 17.8522695982763, `49` = 17.6397425792492,
`50` = 17.4272155602221, `51` = 17.214688541195, `52` = 17.0021615221679,
`53` = 16.7896345031408, `54` = 16.5771074841137, `55` = 16.3645804650866,
`56` = 16.1520534460595, `57` = 15.9395264270324, `58` = 15.7269994080053,
`59` = 15.5144723889782, `60` = 15.3019453699511, `61` = 15.089418350924,
`62` = 14.8768913318969, `63` = 14.6643643128698, `64` = 14.4518372938427,
`65` = 14.2393102748156, `66` = 14.0267832557885, `67` = 13.8142562367614,
`68` = 13.6017292177343, `69` = 13.3892021987072, `70` = 13.1766751796801,
`71` = 12.964148160653, `72` = 12.7516211416259, `73` = 12.5390941225988,
`74` = 12.3265671035717, `75` = 12.1140400845446, `76` = 11.9015130655175,
`77` = 11.6889860464904, `78` = 11.4764590274633, `79` = 11.2639320084362,
`80` = 11.0514049894091, `81` = 10.838877970382, `82` = 10.6263509513549,
`83` = 10.4138239323278, `84` = 10.2012969133007, `85` = 9.98876989427365,
`86` = 9.77624287524655, `87` = 9.56371585621945, `88` = 9.35118883719235,
`89` = 9.13866181816525, `90` = 8.92613479913816, `91` = 8.71360778011105,
`92` = 8.50108076108396, `93` = 8.28855374205686, `94` = 8.07602672302976,
`95` = 7.86349970400266, `96` = 7.65097268497556, `97` = 7.43844566594846,
`98` = 7.22591864692136, `99` = 7.01339162789426, `100` = 6.80086460886717,
`101` = 6.58833758984007, `102` = 6.37581057081297, `103` = 6.16328355178587,
`104` = 5.95075653275877, `105` = 5.73822951373167, `106` = 5.52570249470457,
`107` = 5.31317547567747, `108` = 5.10064845665037, `109` = 4.88812143762328,
`110` = 4.67559441859617, `111` = 4.46306739956908, `112` = 4.25054038054198,
`113` = 4.03801336151488, `114` = 3.82548634248778, `115` = 3.61295932346068,
`116` = 3.40043230443358, `117` = 3.18790528540648, `118` = 2.97537826637939,
`119` = 2.76285124735228, `120` = 2.55032422832519, `121` = 2.33779720929809,
`122` = 2.12527019027099, `123` = 1.91274317124389, `124` = 1.70021615221679,
`125` = 1.48768913318969, `126` = 1.27516211416259, `127` = 1.06263509513549,
`128` = 0.850108076108397, `129` = 0.637581057081296, `130` = 0.425054038054198,
`131` = 0.212527019027097, `132` = 0)), info = list(nfun = 3L,
predictor = "n.fjernet", effect.name = "n.fjernet", type = "main")),
n.sygdom = structure(list(n.sygdom = c(0, 1, 2, 3, 4, 5,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40), Xbeta = c(`133` = 0, `134` = 0.32236136668714,
`135` = 0.648650531337351, `136` = 0.909274081797897, `137` = 1.09719119915252,
`138` = 1.2269431700224, `139` = 1.31307128102872, `140` = 1.37011681879267,
`141` = 1.41262106993544, `142` = 1.452701773308, `143` = 1.49278247668057,
`144` = 1.53286318005315, `145` = 1.57294388342572, `146` = 1.61302458679829,
`147` = 1.65310529017085, `148` = 1.69318599354344, `149` = 1.733266696916,
`150` = 1.77334740028855, `151` = 1.81342810366113, `152` = 1.8535088070337,
`153` = 1.89358951040629, `154` = 1.93367021377884, `155` = 1.97375091715141,
`156` = 2.01383162052397, `157` = 2.05391232389658, `158` = 2.09399302726916,
`159` = 2.13407373064171, `160` = 2.17415443401433, `161` = 2.21423513738691,
`162` = 2.25431584075947, `163` = 2.29439654413205, `164` = 2.33447724750454,
`165` = 2.37455795087723, `166` = 2.41463865424957, `167` = 2.45471935762221,
`168` = 2.49480006099482, `169` = 2.53488076436739, `170` = 2.57496146774009,
`171` = 2.61504217111266, `172` = 2.65512287448523, `173` = 2.69520357785787
), points = c(`133` = 0, `134` = 11.9605572408505, `135` = 24.0668473679043,
`136` = 33.7367495824038, `137` = 40.7090287415156, `138` = 45.5232094563172,
`139` = 48.7188163378863, `140` = 50.8353739973004, `141` = 52.412407045637,
`142` = 53.8995193254604, `143` = 55.3866316052841, `144` = 56.8737438851078,
`145` = 58.3608561649314, `146` = 59.8479684447552, `147` = 61.3350807245785,
`148` = 62.8221930044026, `149` = 64.309305284226, `150` = 65.7964175640487,
`151` = 67.283529843873, `152` = 68.7706421236966, `153` = 70.257754403521,
`154` = 71.7448666833438, `155` = 73.2319789631674, `156` = 74.7190912429907,
`157` = 76.2062035228159, `158` = 77.6933158026398, `159` = 79.1804280824625,
`160` = 80.6675403622881, `161` = 82.1546526421122, `162` = 83.6417649219352,
`163` = 85.1288772017594, `164` = 86.6159894815798, `165` = 88.103101761408,
`166` = 89.5902140412232, `167` = 91.0773263210494, `168` = 92.5644386008743,
`169` = 94.0515508806979, `170` = 95.5386631605266, `171` = 97.0257754403502,
`172` = 98.5128877201739, `173` = 100)), info = list(nfun = 3L,
predictor = "n.sygdom", effect.name = "n.sygdom", type = "main")),
ecs = structure(list(ecs = c("No", "Yes"), Xbeta = c(`174` = 0,
`175` = 0.352802098746005), points = c(`174` = 0, `175` = 13.0899981598574
)), info = list(nfun = 3L, predictor = "ecs", effect.name = "ecs",
type = "main")), contra.pos = structure(list(contra.pos = c("Ipsi.",
"Contra."), Xbeta = c(`176` = 0, `177` = -0.149053853083395
), points = c(`176` = 5.53033745977221, `177` = 0)), info = list(
nfun = 3L, predictor = "contra.pos", effect.name = "contra.pos",
type = "main")), total.points = list(x = c(0, 10, 20,
30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140)), lp = list(
x = c(8.59901355289166, 27.1504878870641, 45.7019622212365,
64.253436555409, 82.8049108895814, 101.356385223754,
119.907859557926, 138.459333892099), x.real = c(-1, -0.5,
0, 0.5, 1, 1.5, 2, 2.5)), `Probability of 1 year survival` = list(
x = c(132.923978485611, 122.154519662532, 112.023605643525,
101.668496222993, 90.3441422980089, 77.0166169199793,
59.6149679036176, 31.771904926561), x.real = c(0.2, 0.3,
0.4, 0.5, 0.6, 0.7, 0.8, 0.9), fat = c("0.2", "0.3",
"0.4", "0.5", "0.6", "0.7", "0.8", "0.9"), which = c(FALSE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE
)), `Probability of 3 years survival` = list(x = c(111.455658509363,
98.1672795067317, 87.3978451509886, 77.2669361851509, 66.9118109221416,
55.5874579746061, 42.2599719337723, 24.8583283615229), x.real = c(0.1,
0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8), fat = c("0.1", "0.2",
"0.3", "0.4", "0.5", "0.6", "0.7", "0.8"), which = c(FALSE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE)),
`Probability of 5 years survival` = list(x = c(96.3366217164868,
83.0483098712202, 72.2788509036931, 62.1479468853665, 51.7928216700398,
40.468478298201, 27.1409533137375, 9.73931852863156), x.real = c(0.1,
0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8), fat = c("0.1", "0.2",
"0.3", "0.4", "0.5", "0.6", "0.7", "0.8"), which = c(FALSE,
TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE))), info = list(
fun = list(function (x)
surv(12, x), function (x)
surv(36, x), function (x)
surv(60, x)), lp = TRUE, lp.at = c(-1, -0.5, 0, 0.5, 1, 1.5,
2, 2.5), discrete = c(n.fjernet = FALSE, n.sygdom = FALSE,
ecs = TRUE, contra.pos = TRUE, studie = TRUE), funlabel = c("Probability of 1 year survival",
"Probability of 3 years survival", "Probability of 5 years survival"
), fun.at = NULL, fun.lp.at = NULL, Abbrev = list(), minlength = 4,
conf.int = FALSE, R = structure(c(-0.761828764157496, -0.0114560716414661,
0, 2.69520357785787, 0, 0.352802098746005, -0.149053853083395,
0), .Dim = c(2L, 4L), .Dimnames = list(NULL, c("n.fjernet",
"n.sygdom", "ecs", "contra.pos"))), sc = 37.1029486683449,
maxscale = 100, Intercept = -1.23176092093802, nint = 10,
space.used = c(main = 4, ia = 0)), class = "nomogram")
your first problem can be solved with an updateSliderInput call where you update the max value to be equal the selected value from the slider above.
The second problem can besolved with an conditionalPanel here I needed to change the naming of the n.sygdom slider to n_sygdom because the java script couldn't handle to dot notation. I would recommend you to the same for all you variables whenever you are working with shiny.
Below is working example
ui <- fluidPage(
titlePanel("Survival Curve"),
sidebarLayout(
sidebarPanel(
sliderInput("n.fjernet", "Lymph Nodal Yield", min = 2, max = 150, value = 40),
sliderInput("n_sygdom", "Number of positive lymph nodes", min = 0, max = 40, value = 0),
conditionalPanel(
condition = "input.n_sygdom >= 1",
radioButtons("ecs", "Extracapsular extension", c("No","Yes")),
radioButtons("contra.pos", "Neck involvement", c("Contra.","Ipsi.")
)
),
verbatimTextOutput("out.score"),
verbatimTextOutput("out.score.group")
),
mainPanel(
plotOutput("surv_plot")
)
)
)
server <- function(input, output, session) {
calc_score <- reactive({
round(nom$ecs$points[nom$ecs$ecs==input$ecs] +
nom$contra.pos$points[nom$contra.pos$contra.pos==input$contra.pos] +
nom$n.fjernet$points[nom$n.fjernet$n.fjernet==input$n.fjernet] +
nom$n_sygdom$points[nom$n_sygdom$n_sygdom==input$n_sygdom],digits=1)
})
observe(
updateSliderInput(
session = session,
inputId = "n_sygdom",
max = min(40, input$n.fjernet),
value = min(input$n.fjernet, input$n_sygdom)
)
)
calc_score_group <- function(score) {
cut(score, c(0,35.9,55.2,70.0,83.3,Inf), include.lowest = TRUE, labels = c("1","2","3","4","5"))
}
fit_data <- reactive({
p %>% filter(score.group == as.numeric(calc_score_group(calc_score())))
})
fit_model <- reactive({
survfit(Surv(os.neck, mors) ~ 1, data = fit_data())
})
output$out.score <- renderText(calc_score())
output$out.score.group <- renderText(calc_score_group(calc_score()))
output$surv_plot <- renderPlot({
ggsurvplot(
fit_model(),
data = fit_data(),
risk.table = TRUE,
pval = F,
pval.coord = c(0, 0.25),
conf.int = T,
size=1,
xlim = c(0,60),
conf.int.alpha=c(0.2),
break.x.by = 6,
xlab="Time in months",
ylab="Probability of overall survival",
ggtheme = theme,
surv.median.line = "v",
ylim=c(0,1),
palette="#2C77BF",
tables.theme=theme,
legend.title=paste("Score group", calc_score_group(calc_score())),
surv.scale="percent",
tables.col="strata",
risk.table.col = "strata",
risk.table.y.text = FALSE,
tables.y.text = FALSE)
})
}
please not that I changed the naming also in the data set as well
Hope this helps!!

Analyzing covariation of variables over time in R

I am using Rstudio to analyze data. And - why else would I post this - I'm getting stuck!
The data is a time-series of the evolution of a community and their characteristics over time. For example, the n_members (the size) can increase over time.
Each combination of the variables 'randomseed' and 'lhsExperimentNumber' is 1 observation. In total, there are 80,000 observations. Each observation has a time-series going from 1 (month) to 204 (months). This time is characterized in the variable X.run.number
What I want:
See covariation of dependent and independent variables over time.
For example: I would like to see how the n_members (size) evolves over time, under different circumstances (exit_window, for example). I normally use dplyr and ggplot2, and I'd like to make some captivating images in ggplot.
My problem:
- I'm just a beginner in R so it's a little tricky for me to see the correct strategy here
- It would be sort of easier if I would just have 1 observation that evolves over time, but now I have 80,000 observations, which each independently evolve over time. So I don't really know how to work the data to make sensible graphs.
How would you guys tackle this? Maybe you can help me out with some tips (that would be so great!)
I used dput to reproduce the first 10 observations of my dataset:
library(ggplot2)
library(dplyr)
coop_dat <- structure(list(X.run.number. = c(2L, 3L, 4L, 1L, 2L, 3L, 4L,
1L, 3L, 3L), rewire_prop = c(0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1), prior_trust_std = c(0.1, 0.1, 0.1, 0.1, 0.1,
0.1, 0.1, 0.1, 0.1, 0.1), max_trust = c(2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L), maxCR_trust = c(0.2, 0.2, 0.2, 0.2, 0.2, 0.2,
0.2, 0.2, 0.2, 0.2), Ostrom. = structure(c(2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L), .Label = c("false", "true"), class = "factor"),
social_network = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L), .Label = "\"small-world\"", class = "factor"),
external_ROI_influence = structure(c(2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L), .Label = c("false", "true"), class = "factor"),
randomseed = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), lhsExperimentNumber = c(1L,
2L, 3L, 0L, 1L, 2L, 3L, 0L, 2L, 2L), X.step. = c(0L, 0L,
0L, 0L, 1L, 1L, 1L, 1L, 2L, 3L), size_start_cooperative = c(12L,
4L, 20L, 17L, 12L, 4L, 20L, 17L, 4L, 4L), degree_prior = c(7L,
21L, 40L, 15L, 7L, 21L, 40L, 15L, 21L, 21L), degree_coop = c(17L,
47L, 20L, 31L, 17L, 47L, 20L, 31L, 47L, 47L), prior_trust_average = c(0.40574414878618,
0.631650829650462, 0.369752783104777, 0.585182260912843,
0.40574414878618, 0.631650829650462, 0.369752783104777, 0.585182260912843,
0.631650829650462, 0.631650829650462), number_of_meetings = c(10L,
5L, 2L, 2L, 10L, 5L, 2L, 2L, 5L, 5L), n_interactions = c(20L,
3L, 9L, 19L, 20L, 3L, 9L, 19L, 3L, 3L), exit_window = c(5L,
1L, 3L, 4L, 5L, 1L, 3L, 4L, 1L, 1L), info_peer_behavior = c(0.396114811487496,
0.627111892865505, 0.148686024846975, 0.281594149058219,
0.396114811487496, 0.627111892865505, 0.148686024846975,
0.281594149058219, 0.627111892865505, 0.627111892865505),
memory = c(8L, 11L, 20L, 1L, 8L, 11L, 20L, 1L, 11L, 11L),
n_shares_total_sum = c(0L, 0L, 0L, 0L, 21L, 13L, 32L, 31L,
13L, 13L), n_shares_total_mean = c(0, 0, 0, 0, 1.75, 3.25,
1.6, 1.82352941176471, 3.25, 3.25), members_at_meeting = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 0L), trust_coop_total = c(0,
0, 0, 0, 0.0457418505048186, 0.0563109517340759, 0.0349050771003757,
0.0587220121136852, 0.0563109517340759, 0.0563109517340759
), rep_total = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ROI = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), current_strategy = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), price = c(0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L), REfocus = c(0, 0, 0, 0, 0, 0,
0, 0, 0, 0), endpoint = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L), HG_membertypes = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
n_members = c(0L, 0L, 0L, 0L, 12L, 4L, 20L, 17L, 4L, 4L),
n_ids = c(0L, 0L, 0L, 0L, 12L, 4L, 20L, 17L, 4L, 4L), n_prods = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), n_cons = c(0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L), n_members_exit = c(0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L)), .Names = c("X.run.number.",
"rewire_prop", "prior_trust_std", "max_trust", "maxCR_trust",
"Ostrom.", "social_network", "external_ROI_influence", "randomseed",
"lhsExperimentNumber", "X.step.", "size_start_cooperative", "degree_prior",
"degree_coop", "prior_trust_average", "number_of_meetings", "n_interactions",
"exit_window", "info_peer_behavior", "memory", "n_shares_total_sum",
"n_shares_total_mean", "members_at_meeting", "trust_coop_total",
"rep_total", "ROI", "current_strategy", "price", "REfocus", "endpoint",
"HG_membertypes", "n_members", "n_ids", "n_prods", "n_cons",
"n_members_exit"), row.names = c(NA, 10L), class = "data.frame")
EDIT:
Right now I have this simple ggplot code:
ggplot(dat) +
geom_line(aes(x=month, y=trust_coop_total))
This produces this graph:
You can see that this is not really a line graph. It's more a graph with a bunch of vertical lines. What I would like is to decipher trends for each individual sample. Each sample is, as mentioned above, a combination of lhsExperimentnumber and X.run.number. There are so many samples that a line graph would be overwhelming, but it might be nice in combination with the alpha=1/10 command of geom_jitter. However, geom_jitter ignores the trend in the sample itself.
What should I do to get a good trend graph?

How to create score variable for predicted value from Logistic regression

I looked for previous posts and found this answer to a similar question from Aug '15. The code is:
logit <- glm(y~x1+x2+x3,family="binomial")
predict(logit)
pred <- predict(logit,newdata=data) #gives you b0 + b1x1 + b2x2 + b3x3
probs <- exp(pred)/(1+exp(pred)) #gives you probability that y=1 for each observation
What I don't understand is how I get the newdata=data part of the code.
How do I specify the data in the newdata part of the code?
How do I assign these predicted values to a variable?
Sample data
structure(list(CustomerID = 1:400, binary_depvar = c(1L, NA,
1L, NA, 1L, NA, NA, NA, 0L, NA, 0L, NA, 0L, NA, 1L, 1L, 1L, NA,
NA, NA, NA, 1L, NA, NA, 1L, NA, NA, NA, NA, 1L, 1L, NA, 0L, 1L,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0L, 1L, NA, 0L, NA,
NA, 1L, NA, NA, 1L, NA, 1L, 1L, 0L, 1L, 0L, 0L, 0L, NA, NA, NA,
1L, NA, 0L, NA, NA, NA, 0L, 1L, NA, 0L, 0L, NA, 1L, NA, 1L, NA,
NA, 1L, 1L, 1L, NA, NA, NA, 1L, 0L, NA, NA, 0L, NA, NA, NA, NA,
0L, 1L, NA, NA, NA, NA, 0L, 0L, NA, NA, NA, 0L, 1L, NA, 0L, NA,
NA, 1L, NA, 0L, NA, 1L, NA, NA, 1L, NA, NA, 1L, 1L, 0L, NA, NA,
NA, 1L, 1L, NA, NA, NA, 1L, NA, 1L, NA, NA, NA, NA, 1L, NA, NA,
NA, 1L, NA, NA, 0L, 1L, 1L, 1L, NA, 0L, NA, NA, NA, NA, 1L, NA,
0L, 0L, NA, 0L, 0L, NA, NA, 0L, 1L, 1L, 0L, 1L, 1L, NA, NA, NA,
NA, NA, NA, NA, NA, 1L, 1L, 0L, 1L, NA, NA, 0L, NA, NA, NA, 1L,
NA, NA, NA, NA, NA, NA, 0L, 1L, 0L, 0L, 0L, 1L, 1L, NA, 0L, NA,
NA, 1L, 1L, 0L, 0L, 0L, NA, 0L, 0L, 1L, NA, 0L, NA, 0L, 1L, NA,
0L, 1L, 1L, 1L, 1L, NA, 0L, NA, NA, NA, NA, NA, NA, NA, NA, NA,
0L, 1L, NA, 0L, 0L, NA, 1L, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, 1L, 1L, 0L, NA, 1L, 0L, NA, 1L, NA, NA, 1L, 1L, 1L,
NA, 0L, 1L, 1L, 1L, 1L, NA, 0L, 0L, 1L, NA, NA, 1L, 1L, 0L, 1L,
NA, NA, NA, 0L, 1L, 1L, 1L, 0L, 0L, NA, 1L, 1L, NA, NA, NA, NA,
NA, NA, 0L, NA, 1L, 0L, 1L, NA, 1L, 0L, 0L, 1L, NA, NA, 1L, 1L,
1L, NA, 0L, 1L, 1L, NA, NA, 1L, NA, 0L, NA, NA, 1L, NA, NA, NA,
NA, 1L, NA, 0L, NA, 0L, NA, 0L, 1L, 1L, NA, 0L, 1L, NA, NA, 1L,
1L, 1L, NA, 1L, 0L, NA, NA, 0L, 0L, NA, NA, NA, 1L, 1L, NA, NA,
0L, 1L, NA, NA, 1L, 0L, 1L, NA, NA, NA, NA, NA, 1L, 1L, 0L, 0L,
NA, NA, NA, NA, 1L, NA, 1L, 0L, 1L, NA, NA, NA, 0L, 0L), binary_A = c(0L,
0L, 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 13L, 17L, 27L, 11L, 53L, 7L, 25L, 20L,
6L, 6L, 7L, 7L, 41L, 7L, 7L, 62L, 12L, 4L, 53L, 13L, 53L,
37L, 5L, 4L, 1L, 57L, 1L, 2L, 37L, 17L, 39L, 53L, 17L, 38L,
22L, 62L, 12L, 5L, 1L, 6L, 1L, 1L, 4L, 1L, 53L, 37L, 5L,
4L, 4L, 4L, 27L, 17L, 22L, 4L, 7L, 6L, 52L, 2L, 46L, 20L,
11L, 48L, 53L, 19L, 13L, 19L, 57L, 27L, 1L, 33L, 17L, 7L,
53L, 37L, 37L, 36L, 1L, 37L, 17L, 47L, 55L, 33L, 11L, 34L,
13L, 1L, 57L, 17L, 53L, 27L, 48L, 41L, 7L, 11L, 7L, 62L,
17L, 4L, 1L, 19L, 27L, 27L, 37L, 13L, 5L, 41L, 62L, 27L,
38L, 48L, 11L, 27L, 46L, 13L, 37L, 17L, 3L, 7L, 4L, 1L, 10L,
1L, 2L, 5L, 37L, 34L, 6L, 2L, 4L, 33L, 2L, 47L, 7L, 3L, 4L,
1L, 6L, 13L, 13L, 31L, 13L, 24L, 1L, 7L, 7L, 4L, 55L, 11L,
4L, 19L, 4L, 1L, 37L, 27L, 17L, 13L, 4L, 13L, 19L, 26L, 62L,
5L, 24L, 38L, 27L, 2L, 8L, 19L, 4L, 38L, 1L, 13L, 4L, 4L,
17L, 54L, 4L, 17L, 17L, 2L, 11L, 13L, 17L, 4L, 6L, 8L, 9L,
38L, 40L, 17L, 70L, 11L, 50L, 14L, 7L, 8L, 7L, 17L, 17L,
62L, 1L, 4L, 17L, 4L, 4L, 6L, 38L, 17L, 4L, 53L, 59L, 13L,
7L, 17L, 4L, 7L, 13L, 7L, 38L, 24L, 20L, 17L, 4L, 4L, 13L,
7L, 7L, 4L, 19L, 7L, 7L, 38L, 62L, 4L, 17L, 17L, 19L, 36L,
17L, 47L, 13L, 13L, 2L, 36L, 26L, 25L, 1L, 2L, 4L, 4L, 27L,
27L, 19L, 41L, 53L, 11L,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 0, 0, 3.5, 4.39, 13.19, 13.01,
6.9, 4.79, 7.23, 14.28, 15.67, 8.76, 3.86, 4.58, 6.51, 18.31,
3.92, 7.79, 6.94, 6.94, 8.76, 4.83, 10.54, 0, 0, 5.62, 0,
1.06, 4.13, 6.52, 4.17, 6.89, 4.25, 3.51, 6.4, 4.83, 5.01,
4.69, 3.54, 4.67, 9.5, 1.75, 0, 16.63, 2.6, 1.43, 3.59, 10.26,
6.15, 0, 5.81, 0, 7.28, 0, 8.91, 7.33, 4.89, 2.7, 13.14,
92.59, 11.03, 7.75, 5.49, 3.31, 7.82, 5.57, 0, 10.03, 7.35,
6.36, 8.94, 7.35, 0, 6.85, 3.85, 4.19, 4.48, 7.43, 10.47,
5.11, 9.42, 3.42, 4.74, 0.89, 6.12, 6.46, 11.31, 0, 4.19,
4.76, 5.86, 8.23, 17.76, 7.69, 18.39, 10.72, 12.73, 7.08,
9.44, 4.14, 26.5, 3.72, 9.47, 12.66, 29.22, 7.64, 3.9, 13.01,
3.53, 10.75, 8.26, 4.8, 14.54, 3.7, 14.15, 8.47, 7.33, 3.78,
5.78, 8.88, 0, 19.19, 16.91, 6.57, 6.36, 7.6, 6.52, 5.55,
9.05, 7.3, 2.81, 5.09, 5.25, 8.22, 7.31, 8.73, 5.27, 4.85,
2.31, 15.63, 0, 8.22, 9.19, 7.05, 6.47, 5.53, 0, 5.03, 0,
0, 6.77, 12.47, 5.71, 0, 6.55, 11.59, 25.13, 1.8, 7.35, 4.66,
7.56, 4.08, 2.98, 6.7, 8.91, 3.3, 5.85, 5.74, 8.73, 13.9,
9.97, 4.27, 10.56, 35.68, 6.56, 5.85, 35.95, 6.24, 1.95,
6.63, 4.23, 4.1, 4.03, 24.37, 4.68, 12.24, 2.41, 0, 3.47,
11.93, 4.15, 6.6, 8.17, 4.65, 4.09, 0, 1.44, 10.95, 0, 7.94,
4.38, 4.18, 1.93, 5.67, 9.42, 0, 13.1, 2.72, 7.25, 2, 5.27,
3.35, 2.12, 9.26, 7.11, 35.44, 2.06, 4.77, 4.24, 12.55, 8.71,
4.38, 5.42, 3.14, 2.7, 10.94, 0, 6.8, 2.47, 14.33, 4.6, 14.06,
5.82, 0, 14.25, 10.57, 9.29, 10.65, 5.58, 4.85, 2.33, 4.03,
6.41, 24.69, 7.61, 2.82, 6.78, 0, 0, 1.51, 0, 6.9, 3.97,
7.7, 0, 3.17, 8.43, 5.52, 5.68, 10.05, 15.86, 1.73, 4.1,
1.38, 5.35, 6.07, 5.68, 10.33, 10.42, 9.44, 0, 0, 7.21, 4.78,
0, 6.26, 7.39, 18.2, 3.44, 5.22, 3.41, 4.73, 10.21, 16.28,
8.51, 12.14, 4.94, 14.65, 3.23, 0, 4.2, 3.13, 4, 10.47, 2.81,
8.22, 0, 3.44, 0, 13.32, 6.93, 0, 3.3, 9.18, 6.71, 8.35,
0, 8.32, 5.43, 12.38, 5.15, 5.74, 0, 2.75, 10.21, 1.58, 8.86,
13.95, 7.1, 11.47, 11.72, 7.09, 0, 2.92, 7.55, 6.58, 14.32,
21.71, 4.01, 1.81, 2.39), percentB = c(43.97, 59.38, 43.37,
46.67, 13.04, 65.31, 43.82, 28.73, 32.44, 25.18, 34.82, 38.13,
19.15, 43.89, 100, 29.47, 43.16, 29.19, 37.42, 29.36, 47.94,
42.58, 18.11, 49.25, 40.12, 36.99, 39.65, 37.06, 48.05, 33.33,
43.79, 41.32, 41.1, 33.91, 25.45, 41.82, 45.68, 40.54, 37.92,
41.08, 34.3, 32.72, 46.55, 48.28, 39.66, 45.79, 42.67, 35.38,
48, 35.3, 45.96, 44.21, 36.27, 43.53, 45, 39.82, 22.19, 29.79,
70, 51.2, 53.52, 36.62, 22.75, 16.53, 46.78, 40.96, 53.79,
19.44, 28.05, 61.04, 42.86, 57.29, 32.62, 42.19, 34.15, 36.31,
41.66, 46.28, 33.92, 31.95, 40, 20.63, 45.59, 29.08, 24.84,
45.41, 39.32, 47.63, 33.85, 24.15, 43.13, 21.05, 12.5, 12.5,
42.67, 0, 63.06, 30.23, 46.15, 39.64, 41.34, 38.05, 38.82,
43.42, 52.62, 34.43, 54.7, 26.82, 36.86, 52.41, 43.85, 60.71,
33.33, 48.48, 47.56, 44.35, 39.47, 50, 57.32, 35.78, 41.67,
36.9, 5.26, 36.52, 44.6, 35.29, 47.31, 38.29, 0, 45.89, 45.83,
40.8, 47.42, 46.03, 31.22, 14.29, 36.08, 31.9, 23.04, 24.71,
42.52, 50, 29.71, 34.34, 43.46, 46.86, 51.31, 45.45, 42.34,
40, 27.54, 38.1, 42.5, 36.51, 35.26, 30.52, 54.05, 56, 28.3,
44.44, 33.03, 42.6, 36.01, 41.35, 34.07, 23.91, 41.32, 43.68,
44.44, 36.47, 46.33, 26.25, 23.33, 43.81, 52.12, 53.94, 8.45,
34.56, 43.2, 29.19, 38.1, 36.3, 53.57, 21.32, 17.11, 38.03,
42.95, 27.22, 41.67, 28.57, 47.37, 30.35, 42.65, 40, 45.25,
41.83, 38.55, 34.99, 30.34, 62.98, 32.14, 42.11, 45.65, 45.14,
40.41, 46.61, 15.47, 48.48, 37.01, 82.86, 42.96, 28.23, 34.36,
44.44, 33.22, 77.78, 41.79, 22.86, 42.59, 27.18, 46.81, 50.94,
38.75, 33.11, 25.73, 0, 52.11, 36.36, 34.89, 35.81, 37.84,
35.93, 43.75, 38.28, 20.68, 33.33, 34.38, 30.27, 8.33, 34.44,
15.16, 28.36, 25, 41.12, 39.76, 33.33, 31.65, 35.32, 39.81,
37.53, 52.73, 29.24, 26.12, 43.21, 29.29, 51.08, 32.14, 28.02,
29.41, 53.47, 27.27, 47.06, 20, 54.42, 12.5, 49.18, 36.85,
23.23, 38.55, 52.93, 39.24, 34.21, 26.73, 40.76, 26.09, 28.57,
50.67, 34.54, 39.07, 30.13, 39.77, 48.85, 46.15, 33.47, 56.52,
37.93, 32.35, 36.04, 45.29, 51.4, 40.51, 37.56, 42.61, 32.9,
41.07, 22.86, 37.86, 35.21, 37.35, 53.69, 31.5, 49.79, 29.55,
47.69, 29.09, 48.27, 41.15, 32.54, 31.95, 37.7, 53.6, 33.33,
20.41, 16.44, 45.65, 41.06, 33.33, 35.98, 36.77, 64.52, 39.26,
32.84, 40.96, 36.23, 44.71, 27.13, 39.65, 30.51, 43.96, 36.36,
35.71, 45.12, 40.27, 36.09, 40.41, 32.83, 28.19, 30.13, 21.51,
15, 28.57, 52.14, 22.66, 40.28, 35.24, 49.43, 25.54, 36.11,
41.62, 38.57, 32.06, 42.7, 29.61, 35.95, 32.78, 23.79, 31.71,
41.92, 2.94, 52.45, 47.82, 44.73, 45.32, 40.85, 51.83, 30.77,
31.24, 22.22, 11.74, 43.11, 42.86, 29.84, 47.89, 27.11, 34.91,
23.4, 38.36, 38.81, 36.31, 45.63, 41.51, 45.83, 36.5, 41.28,
37.28, 28.09, 51.72, 28.96, 34.5, 25.92, 41.56, 48.15, 50.1,
63.28, 49.39, 25, 55.1, 43.3, 8.08, 18.52), percentC = c(0.4,
4.69, 9.18, 0, 0, 6.12, 1.12, 0.67, 0.73, 3.08, 13.77, 0.43,
0, 2.26, 0, 0.97, 0.71, 0.62, 0.33, 0, 8.67, 3.57, 0, 3.14,
2.69, 0, 0.39, 0.94, 2.34, 10.42, 11.85, 3.4, 0, 2.3, 1.82,
2, 1.13, 0, 20.84, 1.29, 0.56, 0.89, 0.24, 3.45, 20.11, 3.18,
0.52, 35.35, 3.45, 1.53, 0.51, 9.5, 0.19, 2.52, 0, 0.3, 0.3,
0, 0, 10.47, 7.75, 0.33, 0, 0.45, 0.11, 1.2, 1.23, 8.33,
0, 23.38, 0, 0.75, 1.55, 1.56, 0.41, 0.83, 1.11, 2.66, 0,
0, 4.8, 0, 7.7, 0.49, 0.62, 4.03, 0.2, 0.38, 1.56, 0.52,
3.57, 0, 0, 0, 0, 0, 0.9, 0, 2.2, 2.16, 0.62, 1.33, 0.36,
1.84, 4.33, 0.55, 16.87, 0, 2.4, 9.65, 0, 0, 0.69, 6.06,
0.81, 1.66, 0, 2, 2.44, 0.83, 12.5, 1.47, 0, 0.34, 1.88,
0.59, 2.34, 1.46, 0, 1.43, 2.08, 1.35, 4.57, 3.17, 0.37,
0, 0.63, 0.31, 0.81, 0, 0.36, 0, 2.96, 0.54, 0.64, 4.02,
1.39, 2.02, 4.5, 0, 1.45, 1.07, 1.25, 0.74, 0.25, 2.28, 2.7,
4, 0.94, 0, 1.59, 0.59, 15.46, 6.02, 6.31, 0, 0, 0.99, 0.65,
2.35, 10.45, 1.67, 0, 0, 6.26, 1.52, 0.7, 0, 2.34, 1.16,
3.17, 2.42, 9.52, 0, 3.95, 1.43, 11.74, 0, 0, 0, 5.26, 13.33,
2.05, 2.29, 0.23, 0.58, 7.49, 5.64, 0.29, 0.88, 0.29, 0,
3.26, 25.4, 15.17, 1.73, 0.55, 0, 2.01, 0, 0.31, 1.88, 0.61,
2.96, 0.68, 0, 0.71, 0, 0, 4.01, 0, 4, 2.5, 0, 3.4, 12.5,
1.1, 4.24, 3.88, 2.43, 10.81, 0.85, 0, 4.31, 2.92, 0, 3.91,
0.43, 0, 0.75, 0.26, 0.84, 0, 0, 8.12, 0, 0.4, 1.37, 3.74,
0.87, 2.42, 0.26, 0, 1.54, 0.4, 4.98, 0, 0.6, 0, 1.81, 0,
0, 0, 1.13, 0, 0, 0.65, 2.02, 6.75, 9.14, 2.53, 25.54, 0.04,
7.82, 0, 7.14, 5.33, 3.65, 5.3, 1.95, 0.8, 0.71, 0, 20.15,
0, 0, 1.24, 3.9, 9.34, 4.2, 0, 9.58, 1.32, 0.92, 0.77, 0,
0.73, 1.41, 8.43, 2.29, 5.61, 6.83, 2.27, 5.09, 0, 5.31,
0.52, 1.83, 0.54, 2.19, 5.63, 0, 0, 35.62, 0, 4.35, 0, 0.53,
0.32, 0, 1.7, 1.49, 0.1, 0, 0.33, 0.33, 3.05, 5.08, 0, 0,
2.38, 1.83, 10.74, 1.38, 0.38, 0.33, 0.34, 3.33, 5.4, 11.43,
57.14, 3.45, 0, 16.67, 23.5, 0.76, 1.45, 0, 1.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0, 0, 0, 0, 0,
0, 1, 1, 0, 0.79, 1, 0, 1, 0, 0.95, 0, 0, 0, 1, 0, 1, 0,
0, 0, 0.13, 0, 0.93, 0, 0, 0, 0, 0.05, 1, 0, 0.93, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0.78,
0.25, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.67, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0.99, 0, 0, 0, 0, 1, 0, 0, 0.8, 0,
0, 0, 0, 0, 0.8, 0, 0, 0, 0, 0, 0.24, 0, 0, 1, 0, 0, 0.45,
0, 0, 1, 1, 0, 0.44, 0, 0, 0, 0, 0, 0, 0.4, 0, 0, 0, 1, 0,
0.57, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0.49, 0, 0, 1, 0, 0, 0,
0.92, 0, 0.73, 0, 0, 0, 0, 0.9, 0, 0, 0, 1, 0, 1, 0.96, 0,
0, 0, 0, 0)), .Names = c("CustomerID", "binary_depvar", "binary_A",
"binary_B", "binary_C", "categ_A", "categ_B", "binary_D", "categ_C",
"categ_D", "categ_E", "binary_E", "percentA", "percentB", "percentC",
"percentD"), class = "data.frame", row.names = c(NA, -400L))

R: Recoding multiple dummy variables into a single variable and replacing the corresponding dummy value with the variable name

I have a dataset with 14 mutually exclusive categories of call type all coded as dummy variables. Here is a small sample:
dput(df)
structure(list(MON1_12 = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L), WEEK1_53 = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), AGENT_ID = structure(c(3L,
4L, 7L, 8L, 1L, 6L, 5L, 9L, 2L, 10L), .Label = c("A129", "A360",
"A407", "B891", "D197", "L145", "L722", "O518", "T443", "W764"
), class = "factor"), CallsHandled = c(1L, 4L, 2L, 14L, 1L, 2L,
5L, 1L, 1L, 3L), CONTENT = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L), CLAIMS = c(1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
CREDIT_CARD = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
DEDUCT_BILL = c(0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L),
HCREFORM = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)), .Names = c("MON1_12",
"WEEK1_53", "AGENT_ID", "CallsHandled", "CONTENT", "CLAIMS",
"CREDIT_CARD", "DEDUCT_BILL", "HCREFORM"), class = "data.frame", row.names = c(NA,
-10L))
I want to combine each of the dummy variables into a single new variable called "QUEUE" that replaces the value of "1" with the name of the dummy variable its corresponding dummy variable. Here is an example of what this would look like:
dput(df2)
structure(list(MON1_12 = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L), WEEK1_53 = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), AGENT_ID = structure(c(3L,
4L, 7L, 8L, 1L, 6L, 5L, 9L, 2L, 10L), .Label = c("A129", "A360",
"A407", "B891", "D197", "L145", "L722", "O518", "T443", "W764"
), class = "factor"), CallsHandled = c(1L, 4L, 2L, 14L, 1L, 2L,
5L, 1L, 1L, 3L), QUEUE = structure(c(1L, 4L, 2L, 4L, 1L, 3L,
3L, 5L, 5L, 4L), .Label = c("CLAIMS", "CONTENT", "CREDIT_CARD",
"DEDUCT_BILL", "HCREFORM"), class = "factor")), .Names = c("MON1_12",
"WEEK1_53", "AGENT_ID", "CallsHandled", "QUEUE"), class = "data.frame", row.names = c(NA,
-10L))
Edit in response to having question marked down: This is what I had tried this afternoon on recommendation with a slightly different sample dataframe:
df$Queue <- as.factor(df$CONTENT + df$CLAIMS*2 + df$CREDIT_CARD*3 + df$DEDUCT_BILL*4 + df$HCREFORM*5)
levels(df$Queue) <- c("CONTENT", "CLAIMS", "CREDIT_CARD","DEDUCT_BILL","HCREFORM")
View(df)
But I received a column of NA's in the Queue column. So, I recreated another sample dataset here. This dataframe is adequately representative of what I'll receive in reality, except I'll have about 40 variables and 2 million rows. When I run what I tried above on "df" above I get the following incorrect result:
dput(df)
structure(list(MON1_12 = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L), WEEK1_53 = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), AGENT_ID = structure(c(3L,
4L, 7L, 8L, 1L, 6L, 5L, 9L, 2L, 10L), .Label = c("A129", "A360",
"A407", "B891", "D197", "L145", "L722", "O518", "T443", "W764"
), class = "factor"), CallsHandled = c(1L, 4L, 2L, 14L, 1L, 2L,
5L, 1L, 1L, 3L), CONTENT = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L), CLAIMS = c(1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
CREDIT_CARD = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
DEDUCT_BILL = c(0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L),
HCREFORM = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), Queue = structure(c(2L,
1L, 1L, 3L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("CONTENT",
"CLAIMS", "CREDIT_CARD", "DEDUCT_BILL", "HCREFORM"), class = "factor")), .Names = c("MON1_12",
"WEEK1_53", "AGENT_ID", "CallsHandled", "CONTENT", "CLAIMS",
"CREDIT_CARD", "DEDUCT_BILL", "HCREFORM", "Queue"), row.names = c(NA,
-10L), class = "data.frame")
I also tried:
df3 <- cbind(df[1:4], QUEUE = apply(df[5:9], 1, function(N) names(N)[as.logical(N)]))
but received the following error: "Error in data.frame("CLAIMS", character(0), character(0), "DEDUCT_BILL", :
arguments imply differing number of rows: 1, 0:
You could use max.col to get the column index that have a value of '1' in each row for columns 5 to 9. (The 'df' example is not correct as most of the rows were all 0s. The corrected one is below).
df$QUEUE <- names(df)[-c(1:4)][max.col(df[-c(1:4)])]
Or you can do
df$QUEUE <- names(df)[-(1:4)][(as.matrix(df[-(1:4)]) %*%
seq_along(df[-(1:4)]))[,1]]
Update
Based on the edit dataset 'df', some rows are all '0's for the columns 5:9, and in the expected result, it is showed that 'QUEUE' as 'CONTENT'. In that case, we can first modify the 'CONTENT' column to change the values where rows are all 0's and then apply either of the code above
df$CONTENT[!rowSums(df[5:9])] <- 1
df$QUEUE1 <- names(df)[5:9][max.col(df[5:9])]
df$QUEUE1
#[1] "CLAIMS" "CONTENT" "CONTENT" "DEDUCT_BILL" "CONTENT"
#[6] "CONTENT" "CONTENT" "CONTENT" "CONTENT" "CONTENT"
data
df <- structure(list(MON1_12 = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L), WEEK1_53 = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L),
AGENT_ID = structure(c(3L,
4L, 7L, 8L, 1L, 6L, 5L, 9L, 2L, 10L), .Label = c("A129", "A360",
"A407", "B891", "D197", "L145", "L722", "O518", "T443", "W764"
), class = "factor"), CallsHandled = c(1L, 4L, 2L, 14L, 1L, 2L,
5L, 1L, 1L, 3L), CONTENT = c(0, 0, 1, 0, 0, 0, 0, 0, 0, 0), CLAIMS = c(1,
0, 0, 0, 1, 0, 0, 0, 0, 0), CREDIT_CARD = c(0, 0, 0, 0, 0, 1,
1, 0, 0, 0), DEDUCT_BILL = c(0, 1, 0, 1, 0, 0, 0, 0, 0, 1),
HCREFORM = c(0,
0, 0, 0, 0, 0, 0, 1, 1, 0)), .Names = c("MON1_12", "WEEK1_53",
"AGENT_ID", "CallsHandled", "CONTENT", "CLAIMS", "CREDIT_CARD",
"DEDUCT_BILL", "HCREFORM"), row.names = c(NA, -10L), class = "data.frame")
This should produce the desired result:
df2 <- cbind(df[1:4], QUEUE = apply(df[5:9], 1, function(N) names(N)[as.logical(N)]))
provided that only one and exactly one of the dummy variables is 1 in any of the rows (which is not true in your original sample of df).
Explanation: df[1:4] selects the columns one through four to be preserved in the output. It is then column bound to QUEUE using cbind function. QUEUE is obtained by iterating through the dummy variables (columns five through nine), row-wise over the data set df and selecting the column-name that contains the value one.

Resources