From 5666a6a3c41135d1dddb31c53cb6b2f2270658be Mon Sep 17 00:00:00 2001 From: James Hollway Date: Fri, 23 Aug 2024 20:22:31 +0200 Subject: [PATCH] Urgency score now calculated and reported when sim_urgency() passed an urgency value too --- R/sim_urgency.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/R/sim_urgency.R b/R/sim_urgency.R index 9e8ef25..368af9f 100644 --- a/R/sim_urgency.R +++ b/R/sim_urgency.R @@ -37,11 +37,16 @@ sim_urgency <- function(urgency, combins <- merge(combins, time, by.x = "Var3", by.y = "word") combins <- combins[,c("Var1","Var2","Var3","Rescaled.x","Rescaled.y","Rescaled")] combins$combo <- as.numeric(combins$Rescaled.x) * combins$Rescaled.y * as.numeric(combins$Rescaled) - formul <- combins[which.min.diff(abs(urgency), combins$combo),c("Var1","Var2","Var3")] + selectd <- which.min.diff(abs(urgency), combins$combo) + formul <- combins[selectd,c("Var1","Var2","Var3")] if(urgency < 0) intcom <- c(formul[1:2], sample(c("not","never"),1)) else intcom <- formul[1:2] out <- paste(pronoun, paste(intcom, collapse = " "), "do this", formul[3]) + cat("Urgency score: ", + combins[selectd,"Rescaled.x"] * combins[selectd,"Rescaled.y"] * combins[selectd,"Rescaled"], + "\n", sep = "") } else { + if(!missing(commitment)){ commit <- comm$word[which.min.diff(abs(commitment), comm$Rescaled)] if(commitment<0) commit <- paste(commit, sample(c("not","never"),1))