diff --git a/docs/CODE_OF_CONDUCT.html b/docs/CODE_OF_CONDUCT.html index eafd79d1..532d9198 100644 --- a/docs/CODE_OF_CONDUCT.html +++ b/docs/CODE_OF_CONDUCT.html @@ -61,7 +61,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/CONTRIBUTING.html b/docs/CONTRIBUTING.html index 55feb32b..0c00fcce 100644 --- a/docs/CONTRIBUTING.html +++ b/docs/CONTRIBUTING.html @@ -61,7 +61,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 24153910..1b8960c8 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -61,7 +61,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/articles/design_philosophy.html b/docs/articles/design_philosophy.html index 67358235..0c2dd7e1 100644 --- a/docs/articles/design_philosophy.html +++ b/docs/articles/design_philosophy.html @@ -30,7 +30,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 @@ -86,7 +86,7 @@

The Design Philosophy of Functions in sjmisc

Daniel Lüdecke

-

2018-08-31

+

2018-09-13

Source: vignettes/design_philosophy.Rmd diff --git a/docs/articles/exploringdatasets.html b/docs/articles/exploringdatasets.html index 93e3abf8..6e7762af 100644 --- a/docs/articles/exploringdatasets.html +++ b/docs/articles/exploringdatasets.html @@ -30,7 +30,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 @@ -86,7 +86,7 @@

Exploring Data Sets

Daniel Lüdecke

-

2018-08-31

+

2018-09-13

Source: vignettes/exploringdatasets.Rmd diff --git a/docs/articles/index.html b/docs/articles/index.html index 44416de2..2a452376 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -61,7 +61,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/authors.html b/docs/authors.html index b99eaae4..60a2d928 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -61,7 +61,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/index.html b/docs/index.html index 1be719f5..9c7e76f1 100644 --- a/docs/index.html +++ b/docs/index.html @@ -34,7 +34,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/news/index.html b/docs/news/index.html index d0edd2b5..849068b2 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -61,7 +61,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 @@ -121,7 +121,7 @@

Changelog

-sjmisc 2.7.5 Unreleased +sjmisc 2.7.5 2018-09-13

@@ -142,6 +142,8 @@

move_columns() to move one or more columns to another position in a data frame.
  • is_num_chr() to check whether a character vector has only numeric strings.
  • +
  • +seq_col() and seq_row() as convenient wrapper to create a regular sequence for column or row numbers.
  • diff --git a/docs/paper.html b/docs/paper.html index 6bc761fb..529d0ce9 100644 --- a/docs/paper.html +++ b/docs/paper.html @@ -61,7 +61,7 @@ sjmisc - 2.7.4.9000 + 2.7.5
    diff --git a/docs/reference/add_columns.html b/docs/reference/add_columns.html index 96840f9c..c7be9f9e 100644 --- a/docs/reference/add_columns.html +++ b/docs/reference/add_columns.html @@ -73,7 +73,7 @@ sjmisc - 2.7.4.9000 + 2.7.5
    diff --git a/docs/reference/add_rows.html b/docs/reference/add_rows.html index e09ac0d4..3196a7b1 100644 --- a/docs/reference/add_rows.html +++ b/docs/reference/add_rows.html @@ -63,7 +63,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/add_variables.html b/docs/reference/add_variables.html index eeba48bd..85814c59 100644 --- a/docs/reference/add_variables.html +++ b/docs/reference/add_variables.html @@ -67,7 +67,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 @@ -157,12 +157,13 @@

    Arg .after, .before -

    Numerical index of row or column, after or before which +

    Numerical index of row or column, after or infront of what the new variable or case should be added. If .after = -1, variables -or cases are added before other columns/rows; if .after = Inf, +or cases are added at the beginning; if .after = Inf, variables and cases are added at the end. In case of add_variables(), .after and .before may also be a character name indicating -the column in data, after/before ... should be inserted.

    +the column in data, after or infront of what ... should be +inserted.

    @@ -170,6 +171,12 @@

    Value

    data, including the new variables or cases from ....

    +

    Note

    + +

    For add_case(), if variable does not exist, a new variable is + created and existing cases for this new variable get the value NA. + See 'Examples'.

    +

    Examples

    d <- data.frame( @@ -188,6 +195,12 @@

    Examp #> 1 1 a 10 #> 2 2 b 20 #> 3 3 c 30

    +# adding a new case for a new variable +add_case(d, e = "new case")
    #> a b c e +#> 1 1 a 10 <NA> +#> 2 2 b 20 <NA> +#> 3 3 c 30 <NA> +#> 4 NA <NA> NA new case
    add_variables(d, new = 5)
    #> a b c new #> 1 1 a 10 5 #> 2 2 b 20 5 @@ -203,6 +216,8 @@

    Contents

  • Arguments
  • Value
  • + +
  • Note
  • Examples
  • diff --git a/docs/reference/all_na.html b/docs/reference/all_na.html index e62e5b00..ef73be2e 100644 --- a/docs/reference/all_na.html +++ b/docs/reference/all_na.html @@ -63,7 +63,7 @@ sjmisc - 2.7.4.9000 + 2.7.5
    diff --git a/docs/reference/big_mark.html b/docs/reference/big_mark.html index aa02e65d..1f461428 100644 --- a/docs/reference/big_mark.html +++ b/docs/reference/big_mark.html @@ -65,7 +65,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/count_na.html b/docs/reference/count_na.html index 8dd00a36..f22de8be 100644 --- a/docs/reference/count_na.html +++ b/docs/reference/count_na.html @@ -64,7 +64,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/de_mean.html b/docs/reference/de_mean.html index 01bf129e..5bc6c94d 100644 --- a/docs/reference/de_mean.html +++ b/docs/reference/de_mean.html @@ -65,7 +65,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 @@ -175,7 +175,7 @@

    Value

    Details

    de_mean() is intended to create group- and de-meaned variables - for complex random-effect-within-between model (see Bell et al. 2018), + for complex random-effect-within-between models (see Bell et al. 2018), where group-effects (random effects) and fixed effects correlate (see Bafumi and Gelman 2006)). This violation of the so called Gauss-Markov-assumption can happen, for instance, when analysing panel diff --git a/docs/reference/descr.html b/docs/reference/descr.html index 0f60e5ae..fdd0d4d6 100644 --- a/docs/reference/descr.html +++ b/docs/reference/descr.html @@ -64,7 +64,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/dicho.html b/docs/reference/dicho.html index 8d13d287..4274b26f 100644 --- a/docs/reference/dicho.html +++ b/docs/reference/dicho.html @@ -67,7 +67,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/efc.html b/docs/reference/efc.html index 54e64276..fe75b81b 100644 --- a/docs/reference/efc.html +++ b/docs/reference/efc.html @@ -63,7 +63,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/empty_cols.html b/docs/reference/empty_cols.html index c32a091c..cb4075df 100644 --- a/docs/reference/empty_cols.html +++ b/docs/reference/empty_cols.html @@ -66,7 +66,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/find_var.html b/docs/reference/find_var.html index a7e8d842..1efc9889 100644 --- a/docs/reference/find_var.html +++ b/docs/reference/find_var.html @@ -65,7 +65,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/flat_table.html b/docs/reference/flat_table.html index ff9722bf..d5e673ee 100644 --- a/docs/reference/flat_table.html +++ b/docs/reference/flat_table.html @@ -64,7 +64,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/frq.html b/docs/reference/frq.html index 405e46b1..29e2c2e0 100644 --- a/docs/reference/frq.html +++ b/docs/reference/frq.html @@ -63,7 +63,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 @@ -226,48 +226,10 @@

    See a

    Examples

    -
    library(haven) -# create labelled integer -x <- labelled( - c(1, 2, 1, 3, 4, 1), - c(Male = 1, Female = 2, Refused = 3, "N/A" = 4) -) -frq(x)
    #> -#> # x <numeric> -#> # total N=6 valid N=6 mean=2.00 sd=1.26 -#> -#> val label frq raw.prc valid.prc cum.prc -#> 1 Male 3 50.00 50.00 50.00 -#> 2 Female 1 16.67 16.67 66.67 -#> 3 Refused 1 16.67 16.67 83.33 -#> 4 N/A 1 16.67 16.67 100.00 -#> NA NA 0 0.00 NA NA -#> -#>
    -x <- labelled( - c(1:3, tagged_na("a", "c", "z"), 4:1, 2:3), - c("Agreement" = 1, "Disagreement" = 4, "First" = tagged_na("c"), - "Refused" = tagged_na("a"), "Not home" = tagged_na("z")) -) -frq(x)
    #> -#> # x <numeric> -#> # total N=12 valid N=9 mean=2.33 sd=1.00 -#> -#> val label frq raw.prc valid.prc cum.prc -#> 1 Agreement 2 16.67 22.22 22.22 -#> 2 2 3 25.00 33.33 55.56 -#> 3 3 3 25.00 33.33 88.89 -#> 4 Disagreement 1 8.33 11.11 100.00 -#> NA NA 3 25.00 NA NA -#> -#>
    -# in a pipe +
    # simple vector data(efc) -library(dplyr) -efc %>% - select(e42dep, e15relat, c172code) %>% - frq()
    #> -#> # elder's dependency (e42dep) <numeric> +frq(efc$e42dep)
    #> +#> # elder's dependency (x) <numeric> #> # total N=908 valid N=901 mean=2.94 sd=0.94 #> #> val label frq raw.prc valid.prc cum.prc @@ -277,36 +239,9 @@

    Examp #> 4 severely dependent 304 33.48 33.74 100.00 #> NA NA 7 0.77 NA NA #> -#> -#> # relationship to elder (e15relat) <numeric> -#> # total N=908 valid N=901 mean=2.85 sd=2.08 -#> -#> val label frq raw.prc valid.prc cum.prc -#> 1 spouse/partner 171 18.83 18.98 18.98 -#> 2 child 473 52.09 52.50 71.48 -#> 3 sibling 29 3.19 3.22 74.69 -#> 4 daughter or son -in-law 85 9.36 9.43 84.13 -#> 5 ancle/aunt 23 2.53 2.55 86.68 -#> 6 nephew/niece 22 2.42 2.44 89.12 -#> 7 cousin 6 0.66 0.67 89.79 -#> 8 other, specify 92 10.13 10.21 100.00 -#> NA NA 7 0.77 NA NA -#> -#> -#> # carer's level of education (c172code) <numeric> -#> # total N=908 valid N=842 mean=1.97 sd=0.63 -#> -#> val label frq raw.prc valid.prc cum.prc -#> 1 low level of education 180 19.82 21.38 21.38 -#> 2 intermediate level of education 506 55.73 60.10 81.47 -#> 3 high level of education 156 17.18 18.53 100.00 -#> NA NA 66 7.27 NA NA -#> #>

    -# or: -# frq(efc, e42dep, e15relat, c172code) - # with grouped data frames, in a pipe +library(dplyr) efc %>% group_by(e16sex, c172code) %>% frq(e16sex, c172code, e42dep)
    #> @@ -546,102 +481,23 @@

    Examp #> <NA> 0 0.00 NA NA #> #>

    -# group variables with large range -frq(efc, c160age)
    #> -#> # carer' age (c160age) <numeric> -#> # total N=908 valid N=901 mean=53.46 sd=13.35 -#> -#> val frq raw.prc valid.prc cum.prc -#> 18 1 0.11 0.11 0.11 -#> 19 2 0.22 0.22 0.33 -#> 20 2 0.22 0.22 0.55 -#> 21 1 0.11 0.11 0.67 -#> 22 2 0.22 0.22 0.89 -#> 23 4 0.44 0.44 1.33 -#> 24 3 0.33 0.33 1.66 -#> 25 5 0.55 0.55 2.22 -#> 26 3 0.33 0.33 2.55 -#> 27 4 0.44 0.44 3.00 -#> 28 4 0.44 0.44 3.44 -#> 29 8 0.88 0.89 4.33 -#> 30 9 0.99 1.00 5.33 -#> 31 9 0.99 1.00 6.33 -#> 32 5 0.55 0.55 6.88 -#> 33 10 1.10 1.11 7.99 -#> 34 9 0.99 1.00 8.99 -#> 35 17 1.87 1.89 10.88 -#> 36 6 0.66 0.67 11.54 -#> 37 7 0.77 0.78 12.32 -#> 38 13 1.43 1.44 13.76 -#> 39 12 1.32 1.33 15.09 -#> 40 13 1.43 1.44 16.54 -#> 41 15 1.65 1.66 18.20 -#> 42 21 2.31 2.33 20.53 -#> 43 24 2.64 2.66 23.20 -#> 44 25 2.75 2.77 25.97 -#> 45 14 1.54 1.55 27.52 -#> 46 22 2.42 2.44 29.97 -#> 47 27 2.97 3.00 32.96 -#> 48 26 2.86 2.89 35.85 -#> 49 32 3.52 3.55 39.40 -#> 50 19 2.09 2.11 41.51 -#> 51 15 1.65 1.66 43.17 -#> 52 22 2.42 2.44 45.62 -#> 53 27 2.97 3.00 48.61 -#> 54 28 3.08 3.11 51.72 -#> 55 24 2.64 2.66 54.38 -#> 56 27 2.97 3.00 57.38 -#> 57 21 2.31 2.33 59.71 -#> 58 26 2.86 2.89 62.60 -#> 59 20 2.20 2.22 64.82 -#> 60 28 3.08 3.11 67.92 -#> 61 19 2.09 2.11 70.03 -#> 62 28 3.08 3.11 73.14 -#> 63 25 2.75 2.77 75.92 -#> 64 25 2.75 2.77 78.69 -#> 65 26 2.86 2.89 81.58 -#> 66 18 1.98 2.00 83.57 -#> 67 17 1.87 1.89 85.46 -#> 68 14 1.54 1.55 87.01 -#> 69 18 1.98 2.00 89.01 -#> 70 15 1.65 1.66 90.68 -#> 71 4 0.44 0.44 91.12 -#> 72 11 1.21 1.22 92.34 -#> 73 7 0.77 0.78 93.12 -#> 74 7 0.77 0.78 93.90 -#> 75 12 1.32 1.33 95.23 -#> 76 10 1.10 1.11 96.34 -#> 77 7 0.77 0.78 97.11 -#> 78 5 0.55 0.55 97.67 -#> 79 5 0.55 0.55 98.22 -#> 80 5 0.55 0.55 98.78 -#> 81 3 0.33 0.33 99.11 -#> 82 1 0.11 0.11 99.22 -#> 83 4 0.44 0.44 99.67 -#> 85 1 0.11 0.11 99.78 -#> 87 1 0.11 0.11 99.89 -#> 89 1 0.11 0.11 100.00 -#> <NA> 7 0.77 NA NA -#> -#>
    frq(efc, c160age, auto.grp = 5)
    #> +# group variables with large range and with weights +efc$weights <- abs(rnorm(n = nrow(efc), mean = 1, sd = .5)) +frq(efc, c160age, auto.grp = 5, weights = weights)
    #> #> # carer' age (c160age) <numeric> -#> # total N=908 valid N=901 mean=53.46 sd=13.35 +#> # total N=920 valid N=920 mean=53.85 sd=13.09 #> #> val label frq raw.prc valid.prc cum.prc -#> 1 18-32 62 6.83 6.88 6.88 -#> 2 33-47 235 25.88 26.08 32.96 -#> 3 48-62 362 39.87 40.18 73.14 -#> 4 63-77 216 23.79 23.97 97.11 -#> 5 78-92 26 2.86 2.89 100.00 -#> NA NA 7 0.77 NA NA +#> 1 18-32 56 6.09 6.09 6.09 +#> 2 33-47 234 25.43 25.43 31.52 +#> 3 48-62 380 41.30 41.30 72.83 +#> 4 63-77 223 24.24 24.24 97.07 +#> 5 78-92 27 2.93 2.93 100.00 +#> NA NA 0 0.00 NA NA #> #>
    -# and with weights -efc$weights <- abs(rnorm(n = nrow(efc), mean = 1, sd = .5)) -frq(efc, c160age, auto.grp = 5, weights = weights)
    #> Warning: is.na() applied to non-(list or vector) of type 'closure'
    #> Error in w != "NULL": comparison (2) is possible only for atomic and list types
    -# group string values -
    # NOT RUN { -dummy <- efc %>% dplyr::select(3) +# group string values +dummy <- efc[1:50, 3, drop = FALSE] dummy$words <- sample( c("Hello", "Helo", "Hole", "Apple", "Ape", "New", "Old", "System", "Systemic"), @@ -649,9 +505,53 @@

    Examp replace = TRUE ) -frq(dummy) -frq(dummy, grp.strings = 2) -# }
    +frq(dummy)
    #> +#> # e16sex <numeric> +#> # total N=50 valid N=50 mean=1.56 sd=0.50 +#> +#> val frq raw.prc valid.prc cum.prc +#> 1 22 44 44 44 +#> 2 28 56 56 100 +#> <NA> 0 0 NA NA +#> +#> +#> # words <character> +#> # total N=50 valid N=50 mean=5.54 sd=2.63 +#> +#> val frq raw.prc valid.prc cum.prc +#> Ape 3 6 6 6 +#> Apple 4 8 8 14 +#> Hello 7 14 14 28 +#> Helo 8 16 16 44 +#> Hole 2 4 4 48 +#> New 4 8 8 56 +#> Old 5 10 10 66 +#> System 9 18 18 84 +#> Systemic 8 16 16 100 +#> <NA> 0 0 NA NA +#> +#>
    frq(dummy, grp.strings = 2)
    #> +#> # e16sex <numeric> +#> # total N=50 valid N=50 mean=1.56 sd=0.50 +#> +#> val frq raw.prc valid.prc cum.prc +#> 1 22 44 44 44 +#> 2 28 56 56 100 +#> <NA> 0 0 NA NA +#> +#> +#> # words <categorical> +#> # total N=50 valid N=50 mean=3.16 sd=1.54 +#> +#> val frq raw.prc valid.prc cum.prc +#> Ape, Apple 7 14 14 14 +#> Hello, Helo, Hole 17 34 34 48 +#> New 4 8 8 56 +#> Old 5 10 10 66 +#> System, Systemic 17 34 34 100 +#> <NA> 0 0 NA NA +#> +#>

    diff --git a/docs/reference/group_str.html b/docs/reference/group_str.html index fe54a2f0..cf9af7ee 100644 --- a/docs/reference/group_str.html +++ b/docs/reference/group_str.html @@ -66,7 +66,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 @@ -135,8 +135,7 @@

    Group near elements of string vectors

    group_str(strings, maxdist = 2, method = "lv", strict = FALSE,
    -  trim.whitespace = TRUE, remove.empty = TRUE,
    -  showProgressBar = FALSE)
    + trim.whitespace = TRUE, remove.empty = TRUE, verbose = FALSE)

    Arguments

    @@ -170,7 +169,7 @@

    Arg character vector strings.

    - + diff --git a/docs/reference/group_var-1.png b/docs/reference/group_var-1.png index 37b9d0b4..dba97612 100644 Binary files a/docs/reference/group_var-1.png and b/docs/reference/group_var-1.png differ diff --git a/docs/reference/group_var-2.png b/docs/reference/group_var-2.png index fb457016..ef52ed5d 100644 Binary files a/docs/reference/group_var-2.png and b/docs/reference/group_var-2.png differ diff --git a/docs/reference/group_var.html b/docs/reference/group_var.html index dc97a2fc..7bd42fd0 100644 --- a/docs/reference/group_var.html +++ b/docs/reference/group_var.html @@ -69,7 +69,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 @@ -280,9 +280,8 @@

    Examp hist(age)
    hist(age.grp)
    age.grpvar <- group_labels(age, size = 10) table(age.grp)
    #> age.grp -#> 1 2 3 4 5 6 7 8 9 10 11 -#> 1 3 6 10 16 18 21 13 8 3 1
    print(age.grpvar)
    #> [1] "10-19" "20-29" "30-39" "40-49" "50-59" "60-69" "70-79" -#> [8] "80-89" "90-99" "100-109" "110-119"
    +#> 1 2 3 4 5 6 7 8 +#> 2 9 10 18 21 21 11 8
    print(age.grpvar)
    #> [1] "20-29" "30-39" "40-49" "50-59" "60-69" "70-79" "80-89" "90-99"
    # histogram with EUROFAMCARE sample dataset # variable not grouped library(sjlabelled) @@ -1209,7 +1208,7 @@

    Examp # create vector with values from 50 to 80 dummy <- round(runif(200, 50, 80)) # labels with grouping starting at lower bound -group_labels(dummy)

    #> [1] "50-54" "55-59" "60-64" "65-69" "70-74" "75-79"
    # labels with grouping startint at upper bound +group_labels(dummy)
    #> [1] "50-54" "55-59" "60-64" "65-69" "70-74" "75-79" "80-84"
    # labels with grouping startint at upper bound group_labels(dummy, right.interval = TRUE)
    #> [1] "46-50" "51-55" "56-60" "61-65" "66-70" "71-75" "76-80"
    # works also with gouped data frames mtcars %>% diff --git a/docs/reference/has_na.html b/docs/reference/has_na.html index 16e0048d..8875afee 100644 --- a/docs/reference/has_na.html +++ b/docs/reference/has_na.html @@ -64,7 +64,7 @@ sjmisc - 2.7.4.9000 + 2.7.5
    diff --git a/docs/reference/index.html b/docs/reference/index.html index 52f68e55..2ea735e3 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -61,7 +61,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 @@ -351,6 +351,12 @@

    seq_col() seq_row()

    + +

    + + diff --git a/docs/reference/is_crossed.html b/docs/reference/is_crossed.html index 325b3a0a..f80ffa8f 100644 --- a/docs/reference/is_crossed.html +++ b/docs/reference/is_crossed.html @@ -68,7 +68,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/is_empty.html b/docs/reference/is_empty.html index fce4995d..d662cb74 100644 --- a/docs/reference/is_empty.html +++ b/docs/reference/is_empty.html @@ -64,7 +64,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/is_even.html b/docs/reference/is_even.html index 0d1a38b1..5ce1c000 100644 --- a/docs/reference/is_even.html +++ b/docs/reference/is_even.html @@ -64,7 +64,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/is_float.html b/docs/reference/is_float.html index a556f947..2135b157 100644 --- a/docs/reference/is_float.html +++ b/docs/reference/is_float.html @@ -66,7 +66,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/is_num_fac.html b/docs/reference/is_num_fac.html index 3a3d658c..8a835251 100644 --- a/docs/reference/is_num_fac.html +++ b/docs/reference/is_num_fac.html @@ -65,7 +65,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/merge_imputations-1.png b/docs/reference/merge_imputations-1.png index 40cacced..ccc828b8 100644 Binary files a/docs/reference/merge_imputations-1.png and b/docs/reference/merge_imputations-1.png differ diff --git a/docs/reference/merge_imputations.html b/docs/reference/merge_imputations.html index 37055a51..f9c91600 100644 --- a/docs/reference/merge_imputations.html +++ b/docs/reference/merge_imputations.html @@ -65,7 +65,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 @@ -250,57 +250,57 @@

    Examp #> 5 5 bmi hyp chl
    # return data frame with imputed variables merge_imputations(nhanes, imp)
    #> bmi hyp chl -#> 1 24.94 1 147 +#> 1 25.40 1 194 #> 2 22.70 1 187 -#> 3 28.98 1 187 -#> 4 24.50 2 205 +#> 3 28.50 1 187 +#> 4 24.46 2 234 #> 5 20.40 1 113 -#> 6 24.56 1 184 +#> 6 22.52 2 184 #> 7 22.50 1 118 #> 8 30.10 1 187 #> 9 22.00 1 238 -#> 10 26.22 2 182 -#> 11 31.00 1 196 -#> 12 25.20 1 201 +#> 10 25.48 1 194 +#> 11 25.46 1 151 +#> 12 25.68 1 199 #> 13 21.70 1 206 #> 14 28.70 2 204 -#> 15 29.60 1 199 -#> 16 30.74 1 206 +#> 15 29.60 1 180 +#> 16 26.44 1 175 #> 17 27.20 2 284 #> 18 26.30 2 199 #> 19 35.30 1 218 #> 20 25.50 2 200 -#> 21 27.28 1 172 +#> 21 28.88 1 198 #> 22 33.20 1 229 #> 23 27.50 1 131 -#> 24 24.90 1 211 +#> 24 24.90 1 218 #> 25 27.40 1 186
    # append imputed variables to original data frame merge_imputations(nhanes, imp, nhanes)
    #> age bmi hyp chl bmi_imp hyp_imp chl_imp -#> 1 1 NA NA NA 24.94 1 147 +#> 1 1 NA NA NA 25.40 1 194 #> 2 2 22.7 1 187 22.70 1 187 -#> 3 1 NA 1 187 28.98 1 187 -#> 4 3 NA NA NA 24.50 2 205 +#> 3 1 NA 1 187 28.50 1 187 +#> 4 3 NA NA NA 24.46 2 234 #> 5 1 20.4 1 113 20.40 1 113 -#> 6 3 NA NA 184 24.56 1 184 +#> 6 3 NA NA 184 22.52 2 184 #> 7 1 22.5 1 118 22.50 1 118 #> 8 1 30.1 1 187 30.10 1 187 #> 9 2 22.0 1 238 22.00 1 238 -#> 10 2 NA NA NA 26.22 2 182 -#> 11 1 NA NA NA 31.00 1 196 -#> 12 2 NA NA NA 25.20 1 201 +#> 10 2 NA NA NA 25.48 1 194 +#> 11 1 NA NA NA 25.46 1 151 +#> 12 2 NA NA NA 25.68 1 199 #> 13 3 21.7 1 206 21.70 1 206 #> 14 2 28.7 2 204 28.70 2 204 -#> 15 1 29.6 1 NA 29.60 1 199 -#> 16 1 NA NA NA 30.74 1 206 +#> 15 1 29.6 1 NA 29.60 1 180 +#> 16 1 NA NA NA 26.44 1 175 #> 17 3 27.2 2 284 27.20 2 284 #> 18 2 26.3 2 199 26.30 2 199 #> 19 1 35.3 1 218 35.30 1 218 #> 20 3 25.5 2 NA 25.50 2 200 -#> 21 1 NA NA NA 27.28 1 172 +#> 21 1 NA NA NA 28.88 1 198 #> 22 1 33.2 1 229 33.20 1 229 #> 23 1 27.5 1 131 27.50 1 131 -#> 24 3 24.9 1 NA 24.90 1 211 +#> 24 3 24.9 1 NA 24.90 1 218 #> 25 2 27.4 1 186 27.40 1 186
    # show summary of quality of merging imputations merge_imputations(nhanes, imp, summary = "dens", filter = c("chl", "hyp"))
    diff --git a/docs/reference/move_columns.html b/docs/reference/move_columns.html index a365b97a..91ead39f 100644 --- a/docs/reference/move_columns.html +++ b/docs/reference/move_columns.html @@ -64,7 +64,7 @@ sjmisc - 2.7.4.9000 + 2.7.5
    diff --git a/docs/reference/numeric_to_factor.html b/docs/reference/numeric_to_factor.html index b038e1ea..596c032f 100644 --- a/docs/reference/numeric_to_factor.html +++ b/docs/reference/numeric_to_factor.html @@ -64,7 +64,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/rec.html b/docs/reference/rec.html index 2e55cd01..75a55d7d 100644 --- a/docs/reference/rec.html +++ b/docs/reference/rec.html @@ -67,7 +67,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/rec_pattern.html b/docs/reference/rec_pattern.html index b83562e3..fefe651d 100644 --- a/docs/reference/rec_pattern.html +++ b/docs/reference/rec_pattern.html @@ -65,7 +65,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/recode_to.html b/docs/reference/recode_to.html index 774b6f15..65b5c57a 100644 --- a/docs/reference/recode_to.html +++ b/docs/reference/recode_to.html @@ -69,7 +69,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 @@ -223,18 +223,18 @@

    See a

    Examples

    # recode 1-4 to 0-3 dummy <- sample(1:4, 10, replace = TRUE) -recode_to(dummy)
    #> [1] 1 1 2 3 1 1 1 3 1 0
    +recode_to(dummy)
    #> [1] 3 3 0 1 0 3 2 3 0 3
    # recode 3-6 to 0-3 # note that numeric type is returned dummy <- as.factor(3:6) recode_to(dummy)
    #> [1] 0 1 2 3
    # lowest value starting with 1 dummy <- sample(11:15, 10, replace = TRUE) -recode_to(dummy, lowest = 1)
    #> [1] 1 3 2 5 1 5 1 1 3 4
    +recode_to(dummy, lowest = 1)
    #> [1] 4 4 3 3 2 1 2 3 3 3
    # lowest value starting with 1, highest with 3 # all others set to NA dummy <- sample(11:15, 10, replace = TRUE) -recode_to(dummy, lowest = 1, highest = 3)
    #> [1] 1 1 NA 3 1 2 1 1 3 3
    +recode_to(dummy, lowest = 1, highest = 3)
    #> [1] NA NA NA NA NA 3 3 1 2 NA
    # recode multiple variables at once data(efc) recode_to(efc, c82cop1, c83cop2, c84cop3, append = FALSE)
    #> c82cop1_r0 c83cop2_r0 c84cop3_r0 diff --git a/docs/reference/reexports.html b/docs/reference/reexports.html index c66c5329..19a421bc 100644 --- a/docs/reference/reexports.html +++ b/docs/reference/reexports.html @@ -67,7 +67,7 @@ sjmisc - 2.7.4.9000 + 2.7.5
    diff --git a/docs/reference/ref_lvl.html b/docs/reference/ref_lvl.html index 283ca81d..8c666237 100644 --- a/docs/reference/ref_lvl.html +++ b/docs/reference/ref_lvl.html @@ -63,7 +63,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/remove_var.html b/docs/reference/remove_var.html index 6fae2691..0a92762e 100644 --- a/docs/reference/remove_var.html +++ b/docs/reference/remove_var.html @@ -65,7 +65,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/replace_na.html b/docs/reference/replace_na.html index 3b693169..61c0a15a 100644 --- a/docs/reference/replace_na.html +++ b/docs/reference/replace_na.html @@ -64,7 +64,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/rotate_df.html b/docs/reference/rotate_df.html index f316113f..091c47cd 100644 --- a/docs/reference/rotate_df.html +++ b/docs/reference/rotate_df.html @@ -64,7 +64,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/round_num.html b/docs/reference/round_num.html index dc4e0210..20c78822 100644 --- a/docs/reference/round_num.html +++ b/docs/reference/round_num.html @@ -65,7 +65,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/row_count.html b/docs/reference/row_count.html index bbfc37a5..3b36e440 100644 --- a/docs/reference/row_count.html +++ b/docs/reference/row_count.html @@ -72,7 +72,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/row_sums.html b/docs/reference/row_sums.html index 163d3a67..82cee34c 100644 --- a/docs/reference/row_sums.html +++ b/docs/reference/row_sums.html @@ -66,7 +66,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/seq_col.html b/docs/reference/seq_col.html new file mode 100644 index 00000000..a7f49b78 --- /dev/null +++ b/docs/reference/seq_col.html @@ -0,0 +1,193 @@ + + + + + + + + +Sequence generation for column or row counts of data frames — seq_col • sjmisc + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    seq_col(x) is a convenient wrapper for seq_len(ncol(x)), + while seq_row(x) is a convenient wrapper for seq_len(nrow(x)).

    + +
    + +
    seq_col(x)
    +
    +seq_row(x)
    + +

    Arguments

    +
    showProgressBarverbose

    Logical; if TRUE, the progress bar is displayed when computing the distance matrix. Default in FALSE, hence the bar is hidden.

    Sequence generation for column or row counts of data frames

    set_na() set_na_if()

    + + + + + +
    x

    A data frame.

    + +

    Value

    + +

    A numeric sequence from 1 to number of columns or rows.

    + + +

    Examples

    +
    data(iris) +seq_col(iris)
    #> [1] 1 2 3 4 5
    seq_row(iris)
    #> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 +#> [19] 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 +#> [37] 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 +#> [55] 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 +#> [73] 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 +#> [91] 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 +#> [109] 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 +#> [127] 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 +#> [145] 145 146 147 148 149 150
    +
    + + + + + + + + + + + + diff --git a/docs/reference/set_na.html b/docs/reference/set_na.html index 90c9e20c..72f85a51 100644 --- a/docs/reference/set_na.html +++ b/docs/reference/set_na.html @@ -66,7 +66,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 @@ -236,31 +236,31 @@

    Examp # show value distribution table(dummy)
    #> dummy #> 1 2 3 4 5 6 7 8 -#> 14 8 7 11 16 19 17 8
    # set value 1 and 8 as missings +#> 15 12 12 13 12 10 15 11
    # set value 1 and 8 as missings dummy <- set_na(dummy, na = c(1, 8)) # show value distribution, including missings table(dummy, useNA = "always")
    #> dummy #> 2 3 4 5 6 7 <NA> -#> 8 7 11 16 19 17 22
    +#> 12 12 13 12 10 15 26
    # add named vector as further missing value -set_na(dummy, na = c("Refused" = 5), as.tag = TRUE)
    #> [1] 6 7 6 6 4 4 7 NA NA 6 2 NA 2 4 NA NA 2 4 7 NA NA NA 3 2 NA -#> [26] NA 6 2 6 NA NA 3 6 NA NA 7 NA 3 6 NA NA 6 NA 7 NA 4 2 7 6 7 -#> [51] NA 7 6 6 NA NA 2 2 3 NA NA 4 7 7 7 7 6 4 NA NA 4 6 NA 3 7 -#> [76] NA 7 4 NA NA NA 4 NA 6 4 NA 3 NA 3 7 6 NA 6 NA 7 NA 6 7 6 NA +set_na(dummy, na = c("Refused" = 5), as.tag = TRUE)
    #> [1] NA 3 7 NA 7 4 NA NA NA 4 NA 6 4 NA 3 NA 3 7 6 NA 6 NA 7 NA 6 +#> [26] 7 6 NA 7 4 2 3 NA NA NA 6 7 NA 2 NA 4 NA 4 NA 2 NA 3 7 7 7 +#> [51] NA 4 6 NA 2 2 2 4 6 NA NA 7 3 6 2 NA 3 2 3 2 3 2 NA 4 NA +#> [76] NA NA 7 7 3 4 NA 7 4 NA NA 6 NA 7 NA NA NA 4 2 2 4 3 3 NA NA #> attr(,"labels") #> Refused #> NA
    # see different missing types library(haven) library(sjlabelled) -print_tagged_na(set_na(dummy, na = c("Refused" = 5), as.tag = TRUE))
    #> [1] 6 7 6 6 4 4 7 NA(5) NA(5) 6 2 NA(5) -#> [13] 2 4 NA NA 2 4 7 NA NA NA(5) 3 2 -#> [25] NA NA(5) 6 2 6 NA(5) NA(5) 3 6 NA NA 7 -#> [37] NA(5) 3 6 NA NA 6 NA 7 NA 4 2 7 -#> [49] 6 7 NA 7 6 6 NA(5) NA(5) 2 2 3 NA(5) -#> [61] NA(5) 4 7 7 7 7 6 4 NA(5) NA 4 6 -#> [73] NA 3 7 NA(5) 7 4 NA NA(5) NA 4 NA 6 -#> [85] 4 NA 3 NA(5) 3 7 6 NA 6 NA 7 NA -#> [97] 6 7 6 NA
    +print_tagged_na(set_na(dummy, na = c("Refused" = 5), as.tag = TRUE))
    #> [1] NA 3 7 NA(5) 7 4 NA NA(5) NA 4 NA 6 +#> [13] 4 NA 3 NA(5) 3 7 6 NA 6 NA 7 NA +#> [25] 6 7 6 NA 7 4 2 3 NA(5) NA NA 6 +#> [37] 7 NA 2 NA(5) 4 NA(5) 4 NA 2 NA 3 7 +#> [49] 7 7 NA 4 6 NA 2 2 2 4 6 NA(5) +#> [61] NA(5) 7 3 6 2 NA 3 2 3 2 3 2 +#> [73] NA 4 NA NA NA 7 7 3 4 NA(5) 7 4 +#> [85] NA NA 6 NA 7 NA(5) NA(5) NA 4 2 2 4 +#> [97] 3 3 NA NA(5)
    # create sample data frame dummy <- data.frame(var1 = sample(1:8, 100, replace = TRUE), @@ -268,12 +268,12 @@

    Examp var3 = sample(1:6, 100, replace = TRUE)) # set value 2 and 4 as missings dummy %>% set_na(na = c(2, 4)) %>% head()

    #> var1 var2 var3 -#> 1 7 10 3 -#> 2 NA 8 NA -#> 3 NA 1 5 -#> 4 3 8 3 -#> 5 5 6 NA -#> 6 1 6 1
    dummy %>% set_na(na = c(2, 4), as.tag = TRUE) %>% get_na()
    #> $var1 +#> 1 8 7 1 +#> 2 3 5 1 +#> 3 3 NA NA +#> 4 NA NA NA +#> 5 5 9 5 +#> 6 NA 8 1
    dummy %>% set_na(na = c(2, 4), as.tag = TRUE) %>% get_na()
    #> $var1 #> 2 4 #> NA NA #> diff --git a/docs/reference/shorten_string.html b/docs/reference/shorten_string.html index f1637631..c06d45dc 100644 --- a/docs/reference/shorten_string.html +++ b/docs/reference/shorten_string.html @@ -64,7 +64,7 @@ sjmisc - 2.7.4.9000 + 2.7.5
    diff --git a/docs/reference/sjmisc-package.html b/docs/reference/sjmisc-package.html index b7382d98..3991f684 100644 --- a/docs/reference/sjmisc-package.html +++ b/docs/reference/sjmisc-package.html @@ -72,7 +72,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/split_var.html b/docs/reference/split_var.html index f82640ef..e3db5337 100644 --- a/docs/reference/split_var.html +++ b/docs/reference/split_var.html @@ -67,7 +67,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/spread_coef.html b/docs/reference/spread_coef.html index 563dd0c6..f204f025 100644 --- a/docs/reference/spread_coef.html +++ b/docs/reference/spread_coef.html @@ -66,7 +66,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/std.html b/docs/reference/std.html index 35ac2d8f..77309117 100644 --- a/docs/reference/std.html +++ b/docs/reference/std.html @@ -67,7 +67,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/str_contains.html b/docs/reference/str_contains.html index 8ac56da8..583f4762 100644 --- a/docs/reference/str_contains.html +++ b/docs/reference/str_contains.html @@ -65,7 +65,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/str_pos.html b/docs/reference/str_pos.html index 63a9f619..1de1bd19 100644 --- a/docs/reference/str_pos.html +++ b/docs/reference/str_pos.html @@ -65,7 +65,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/str_start.html b/docs/reference/str_start.html index f26f6989..4c40a1ae 100644 --- a/docs/reference/str_start.html +++ b/docs/reference/str_start.html @@ -65,7 +65,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/to_character.html b/docs/reference/to_character.html index f6d62bea..0378c93e 100644 --- a/docs/reference/to_character.html +++ b/docs/reference/to_character.html @@ -66,7 +66,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/to_dummy.html b/docs/reference/to_dummy.html index e0752d2f..4e3530ca 100644 --- a/docs/reference/to_dummy.html +++ b/docs/reference/to_dummy.html @@ -64,7 +64,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/to_factor.html b/docs/reference/to_factor.html index 250f2dc5..c70d2903 100644 --- a/docs/reference/to_factor.html +++ b/docs/reference/to_factor.html @@ -64,7 +64,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/to_label.html b/docs/reference/to_label.html index f3bf70e2..b90da3ad 100644 --- a/docs/reference/to_label.html +++ b/docs/reference/to_label.html @@ -68,7 +68,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/to_long.html b/docs/reference/to_long.html index 2526a3b8..5b75ed81 100644 --- a/docs/reference/to_long.html +++ b/docs/reference/to_long.html @@ -65,7 +65,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/to_value.html b/docs/reference/to_value.html index a8fb79e2..db1f9250 100644 --- a/docs/reference/to_value.html +++ b/docs/reference/to_value.html @@ -65,7 +65,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/trim.html b/docs/reference/trim.html index aa414091..dc4dbe3b 100644 --- a/docs/reference/trim.html +++ b/docs/reference/trim.html @@ -64,7 +64,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/var_rename.html b/docs/reference/var_rename.html index 416c270a..caf32015 100644 --- a/docs/reference/var_rename.html +++ b/docs/reference/var_rename.html @@ -64,7 +64,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/var_type.html b/docs/reference/var_type.html index a16b8aad..a92ec98d 100644 --- a/docs/reference/var_type.html +++ b/docs/reference/var_type.html @@ -66,7 +66,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/word_wrap.html b/docs/reference/word_wrap.html index af0bcae4..6ea4c215 100644 --- a/docs/reference/word_wrap.html +++ b/docs/reference/word_wrap.html @@ -64,7 +64,7 @@ sjmisc - 2.7.4.9000 + 2.7.5 diff --git a/docs/reference/zap_inf.html b/docs/reference/zap_inf.html index 5d2ef787..c1fd556d 100644 --- a/docs/reference/zap_inf.html +++ b/docs/reference/zap_inf.html @@ -64,7 +64,7 @@ sjmisc - 2.7.4.9000 + 2.7.5