Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed May 20, 2024
1 parent a4b1e7c commit 49650ab
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
```

Expand Down
62 changes: 61 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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")))
Expand Down Expand Up @@ -215,44 +221,68 @@ 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
#> 3 1 a 5 1 <NA> NA
#> 1 2 b 6 2 f 100
#> 2 3 c 7 3 g 101
#> 4 NA <NA> 8 4 h 102
```

``` r

data_merge(x, y, join = "left")
#> a b c id d e
#> 3 1 a 5 1 <NA> 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 <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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 49650ab

Please sign in to comment.