From 49650ab9948e5a1af6eb61c2fcf527d315de7caf Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 20 May 2024 14:24:50 +0200 Subject: [PATCH] update readme --- README.Rmd | 2 +- README.md | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/README.Rmd b/README.Rmd index 7610c5924..544079a26 100644 --- a/README.Rmd +++ b/README.Rmd @@ -170,7 +170,7 @@ long_data <- data_to_long(wide_data, rows_to = "Row_ID") # Save row number data_to_wide(long_data, names_from = "name", values_from = "value", - id_cols = "Row_ID" + by = "Row_ID" ) ``` diff --git a/README.md b/README.md index 411ad4c72..ba33c6086 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,9 @@ columns, can be achieved using `extract_column_names()` or # find column names matching a pattern extract_column_names(iris, starts_with("Sepal")) #> [1] "Sepal.Length" "Sepal.Width" +``` + +``` r # return data columns matching a pattern data_select(iris, starts_with("Sepal")) |> head() @@ -155,6 +158,9 @@ It is also possible to extract one or more variables: # single variable data_extract(mtcars, "gear") #> [1] 4 4 4 3 3 3 3 4 4 4 4 3 3 3 3 3 3 4 4 4 3 3 3 3 3 4 5 5 5 5 5 4 +``` + +``` r # more variables head(data_extract(iris, ends_with("Width"))) @@ -215,11 +221,17 @@ x #> 1 1 a 5 1 #> 2 2 b 6 2 #> 3 3 c 7 3 +``` + +``` r y #> c d e id #> 1 6 f 100 2 #> 2 7 g 101 3 #> 3 8 h 102 4 +``` + +``` r data_merge(x, y, join = "full") #> a b c id d e @@ -227,32 +239,50 @@ data_merge(x, y, join = "full") #> 1 2 b 6 2 f 100 #> 2 3 c 7 3 g 101 #> 4 NA 8 4 h 102 +``` + +``` r data_merge(x, y, join = "left") #> a b c id d e #> 3 1 a 5 1 NA #> 1 2 b 6 2 f 100 #> 2 3 c 7 3 g 101 +``` + +``` r data_merge(x, y, join = "right") #> a b c id d e #> 1 2 b 6 2 f 100 #> 2 3 c 7 3 g 101 #> 3 NA 8 4 h 102 +``` + +``` r data_merge(x, y, join = "semi", by = "c") #> a b c id #> 2 2 b 6 2 #> 3 3 c 7 3 +``` + +``` r data_merge(x, y, join = "anti", by = "c") #> a b c id #> 1 1 a 5 1 +``` + +``` r data_merge(x, y, join = "inner") #> a b c id d e #> 1 2 b 6 2 f 100 #> 2 3 c 7 3 g 101 +``` + +``` r data_merge(x, y, join = "bind") #> a b c id d e @@ -291,7 +321,7 @@ long_data <- data_to_long(wide_data, rows_to = "Row_ID") # Save row number data_to_wide(long_data, names_from = "name", values_from = "value", - id_cols = "Row_ID" + by = "Row_ID" ) #> Row_ID X1 X2 X3 X4 X5 #> 1 1 -0.08281164 -1.12490028 -0.70632036 -0.7027895 0.07633326 @@ -323,13 +353,22 @@ tmp #> 3 3 3 NA 3 #> 4 NA NA NA NA #> 5 5 5 NA 5 +``` + +``` r # indices of empty columns or rows empty_columns(tmp) #> c #> 3 +``` + +``` r empty_rows(tmp) #> [1] 4 +``` + +``` r # remove empty columns or rows remove_empty_columns(tmp) @@ -339,12 +378,18 @@ remove_empty_columns(tmp) #> 3 3 3 3 #> 4 NA NA NA #> 5 5 5 5 +``` + +``` r remove_empty_rows(tmp) #> a b c d #> 1 1 1 NA 1 #> 2 2 NA NA NA #> 3 3 3 NA 3 #> 5 5 5 NA 5 +``` + +``` r # remove empty columns and rows remove_empty(tmp) @@ -365,6 +410,9 @@ table(x) #> x #> 1 2 3 4 5 6 7 8 9 10 #> 2 3 5 3 7 5 5 2 11 7 +``` + +``` r # cut into 3 groups, based on distribution (quantiles) table(categorize(x, split = "quantile", n_groups = 3)) @@ -398,6 +446,9 @@ summary(swiss) #> Mean : 41.144 Mean :19.94 #> 3rd Qu.: 93.125 3rd Qu.:21.70 #> Max. :100.000 Max. :26.60 +``` + +``` r # after summary(standardize(swiss)) @@ -436,6 +487,9 @@ anscombe #> 9 12 12 12 8 10.84 9.13 8.15 5.56 #> 10 7 7 7 8 4.82 7.26 6.42 7.91 #> 11 5 5 5 8 5.68 4.74 5.73 6.89 +``` + +``` r # after winsorize(anscombe) @@ -487,6 +541,9 @@ head(trees) #> 4 10.5 72 16.4 #> 5 10.7 81 18.8 #> 6 10.8 83 19.7 +``` + +``` r # after head(ranktransform(trees)) @@ -519,6 +576,9 @@ x #> Mazda RX4 21.0 6 160 110 #> Mazda RX4 Wag 21.0 6 160 110 #> Datsun 710 22.8 4 108 93 +``` + +``` r data_rotate(x) #> Mazda RX4 Mazda RX4 Wag Datsun 710