Reputation: 1209
Why does below return output as data frame with 0 columns and 1 row
, I have no idea what it means either.
The code ran is
iris %>% summarise(across(everything(),nrow))
Note that both of the below returns an output as expected
iris %>% summarise(across(everything(),length))
iris %>% summarise(across(everything(),mean))
Ideal Output received
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
150 150 150 150 150
Upvotes: 0
Views: 150
Reputation: 388982
nrow
is used on dataframes, across
does not pass data as dataframe it passes it as vector on which nrow
does not work. For example,
nrow(1:10)
#NULL
You can use functions like length
, NROW
which works on vector to use in across
.
Upvotes: 7