Search
 
SCRIPT & CODE EXAMPLE
 

R

Pass argument to group_by

mytable <- function( x, group ) {
  x %>% 
    group_by( .data[[group]] ) %>% 
    summarise( n = n() )
}

group_string <- 'Species'

mytable( iris, group_string )

`summarise()` ungrouping output (override with `.groups` argument)
# A tibble: 3 x 2
  Species        n
  <fct>      <int>
1 setosa        50
2 versicolor    50
3 virginica     50
Comment

Pass argument to group_by (2)

mytable <- function(x, group) {
  x %>% 
    group_by({{group}}) %>% 
    summarise(n = n())
}
mytable(iris, Species)
Comment

PREVIOUS NEXT
Code Example
R :: R view storage size of variable 
R :: grep string that ends with R 
R :: select number of row dataframe r 
R :: r - if value in a df is between two number then add 1 
Rust :: rust lang sleep 
Rust :: rust create folder 
Rust :: how to clear the console rust 
Rust :: how to create a string of n characters rust 
Rust :: rust nesting loops 
Rust :: linking with `link.exe` failed: exit code: 1189 
Rust :: encode base64 rust 
Rust :: rust multiline comment 
Rust :: rust test std out 
Rust :: armanriazi•rust•error 
Rust :: armanriazi•rust•smartpointer•box 
Rust :: rust modulus 
Rust :: rust enter number from keyboard / stdin 
Rust :: armanriazi•rust•static 
Rust :: rust absolute path 
Rust :: rust•armanriazi•borrowchecker•ownership 
Rust :: armanriazi•rust•thread•rayon•join•workstealing 
Rust :: rust array literal 
Lua :: get all players roblox 
Lua :: luau how to make a kill brick 
Lua :: my second long scripting 
Lua :: dictionnary lua 
Lua :: lua json decode 
Lua :: lua tables 
Lua :: roblox lua get game place id 
Lua :: how to format a number into hh:mm:ss in lua 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =