R 如何理解data.table中()的含义

R 如何理解data.table中()的含义,r,data.table,R,Data.table,我被data.table中的()弄糊涂了。很难在谷歌上搜索。那么,有人能详细解释一下,()在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 = m

我被data.table中的()弄糊涂了。很难在谷歌上搜索。那么,有人能详细解释一下,()在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`

它类似于用
列表包装(
这是一种简写形式。也许可以尝试一下和其他介绍文本幻灯片?有很多,而且很多都很好。都是昨天的(!!)。@akrun,谢谢你的回答,我添加了一些代码进行澄清,你能看一下吗?它类似于用
列表包装(
这是简写的。也许可以试试和其他介绍文本幻灯片?有很多,而且很多都很好。都是昨天的幻灯片(!!)。@akrun,谢谢你的回答,我添加了一些代码进行澄清,你能看一下吗?