Error messages with SD by Year and Conference

13 views Asked by At

I posted this previously and thought that solved my problem, but I received an error message that stops the calculation.

Again, I am new to R coding, so still trying to figure out the details.

Any help is greatly appreciated.

Data example: enter image description here

library("data.table")
library("tidyverse")

# Read in Data file (please see example above) #

W_pct <- (cbal$Wins/(cbal$Wins + cbal$Losses))

cbal$W_pct <- sprintf(W_pct, fmt = '%.3f')

setDT(cbal)

cbal[,.(mean = mean(cbal$W_pct), sd = sd(cbal$W_pct)), keyby = c(cbal$Year,cbal$Conference)]

enter image description here

Error in `eval(bysub, x, parent.frame()) : object '2005' not found`

The error looks like it doesn't recognize the Year. So I tried as.numeric() and as.factor(), but received the same error.

I only have loaded Tidyverse and data.table. Am I missing a library that is preventing it from reading the Year? Or does Year need to be formatted differently so that R reads it at a group?

0

There are 0 answers