小编use*_*794的帖子

Use of {} within data.table's j

I have been studying a datacamp course called "Data Analysis in R, the data.table Way".

练习的指导如下,

  • 不使用==选择b组.
  • 选择b和c组.
  • 使用mult选择b和c组的第一行.
  • 使用= .EACHI和.SD选择b和c组的第一行和最后一行.
  • 在返回组中的第一行和最后一行之前,扩展上一个命令以打印出该组.

布局如下,

# This is your data.table `DT`. The keys are set to `A` and `B`
DT <- data.table(A=letters[c(2,1,2,3,1,2,3)], B=c(5,4,1,9,8,8,6), C=6:12)
setkey(DT,A,B)
# Select the `b` group
# `b` and `c` groups
# The first row of the `b` and `c` group
# `by=.EACHI` and `.SD` 
# Print out all the data in the two groups before you return …
Run Code Online (Sandbox Code Playgroud)

r data.table

2
推荐指数
1
解决办法
654
查看次数

标签 统计

data.table ×1

r ×1