Error message: unexpected symbol

Hey @samuel_morrow61,

Welcome to RStudio Community :partying_face::partying_face::partying_face::partying_face::partying_face::partying_face::partying_face::partying_face::partying_face:

I reformatted the function for you. Copy and paste it as it is in your script file:

ddscale <- function(control, treatment){
  n <- length(control) 
  control.scaled <- (control - mean(control[1:(n-1)])) / (sd(control[1:(n-1)]))
  treatment.hyp <- (control.scaled * (sd(treatment[1:(n-1)]) / sd(control.scaled[1:(n-1)])) + (mean(treatment[1:(n-1)]) - mean(control.scaled[1:(n-1)])))
  treatment.hyp
}

Hope this helps.

5 Likes