Search
 
SCRIPT & CODE EXAMPLE
 

R

round multiple columns in r

# load dplyr
library(dplyr)

# Round at first decimal with a mixed df
mydf %>% mutate(across(where(is.numeric), round, 1))

# The two solutions above do the same
mydf %>% mutate(across(where(is.numeric), ~round(., 1)))
mydf %>% mutate_if(is.numeric, round, 1)
Comment

PREVIOUS NEXT
Code Example
R :: columns of a datafram in r 
R :: remove rownumbers r 
R :: find length of a list or vector in r 
R :: R get specific character from string 
R :: rep in r 
R :: r variables 
R :: how to use ifelse in r 
R :: r type of object 
R :: random r 
R :: replace any NA in a data frame in r 
R :: how many pairwise combinations 
R :: make gif r 
R :: change labels in legend R 
R :: r rename column based on variable 
R :: R Basic Syntax 
R :: ggplot2 reverse order of scale_brewer color 
R :: R view memory size of variables 
R :: how to group rages in r 
R :: print string without quotes and escape sequence r 
R :: hypergeometric distribution on r 
R :: next element in a loop if error in r 
R :: r count dataframe 
Rust :: how to clear the console rust 
Rust :: rust lang print in hex 
Rust :: convert number to string rust 
Rust :: rust iterate vector backwards 
Rust :: rust function 
Rust :: packet sniffing with rust 
Rust :: armanriazi•rust•type•wrapper•vs•clone 
Rust :: armanriazi•rust•concept•dst•or•unsizedtype 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =