What do you want to save?
Add Code snippet
New code examples in category R
-
-
Erve1879 2021-09-03 05:13:03
r create a vector
# Basic syntax: c(11, 23, 42) # Vector of numerics c(TRUE, FALSE, TRUE) # Vector of booleans/logicals c("aa", "bb", "cc") # Vector of strings # Note, in R, list and vectors (aka atomic vectors) are both # one-dimensional ob... Add solution -
Adam Uraynar 2021-09-02 23:19:03
how to round all numeric column types in r
round_df <- function(x, digits) { # round all numeric variables # x: data frame # digits: number of digits to round numeric_columns <- sapply(x, mode) == 'numeric' x[numeric_columns] <- round(x[numeric_columns], digits) ... Add solution -
-
Peter Alhen S.C. 2021-08-31 22:48:02
r dataframe column factor
mtcars #look at this built in data set str(mtcars) #allows you to see the classes of the variables (all numeric) #one approach it to index with the $ sign and the as.factor function mtcars$am <- as.factor(mtcars$am) #another approach mtcars[, 'cyl'] ... Add solution
Best helpers
Anita Izumi
+5
CuriousMind
+5
Piotr Irving
+5
Amadan
+5
Zied Rebhi
+5
Jamesnicolas
+5
Joel C
+5
Emi-le
+5
Jamesr
+5
Mutyo
+5