总结一下,nrow 不返回任何内容

Vai*_*ngh 0 r dplyr tidyverse

为什么下面将输出返回为data frame with 0 columns and 1 row,我也不知道这意味着什么。

运行的代码是

iris %>% summarise(across(everything(),nrow)) 
Run Code Online (Sandbox Code Playgroud)

请注意,以下两个都按预期返回输出

iris %>% summarise(across(everything(),length))
iris %>% summarise(across(everything(),mean))
Run Code Online (Sandbox Code Playgroud)

收到的理想输出

Sepal.Length Sepal.Width Petal.Length Petal.Width Species
     150         150          150         150     150
Run Code Online (Sandbox Code Playgroud)

Ron*_*hah 7

nrow用于数据帧,across不将数据作为数据帧传递,而是将其作为nrow不起作用的向量传递。例如,

nrow(1:10)
#NULL
Run Code Online (Sandbox Code Playgroud)

您可以使用类似 的函数lengthNROW它适用于要在across.