I have a data set that has a column for a factor (in the example case, cut). It is currently set up like this:
library(ggplot2) # access to diamonds dataset
library(data.table)
data <- data.table(diamonds)[,list(mean_carat=mean(carat)), by=c('cut', 'color')]
I am trying to change all entries named "Fair" to "Good" because in my data set, the two entries are actually the same thing but notated differently. The syntax that I have been trying to use is:
data[which(cut = "Fair"), cut := "Good"]
and the output is
>Error: unexpected symbol in "data[which(cut = "Fair"), cut := "Good"]"
Can anyone tell me where I am going wrong?