Я смущен. () В data.table. это трудно для поиска. () в Google. Так может кто-нибудь объяснить подробно, для чего используется. () В R data.table, пожалуйста? Спасибо!
Я хотел бы показать код для лучшего понимания:
df = data.table(col1 = c(1:20), col2 = seq(1, 100, by = 5), col3 = c(replicate(10, "A"), replicate(10, "B")))
df %>% group_by(col3) %>% summarise(mean = mean(col2)) %>% View() `This is what I want in data.table`
df %>% .[, .(mean = mean(col2)), by = col3] %>% View()`# this code is what I want, but it can only run with .(), as I have only one column(col2) in j, my question is why we need .() here?`
df %>% .[, mean := mean(col2), by = col3] %>% View() `this is not what I want as it creates duplicated rows`