diff --git a/docs/news/index.html b/docs/news/index.html index 6c1f904..2b106b1 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -144,6 +144,7 @@
%>%
is now imported from dplyr
Some base R functions like subset
drop variable and
+
Some base R functions like base::subset()
drop variable and
value labels attached to a variable. copy_labels
coud be used
to restore these attributes.
copy_labels_from
is intended to be used with dplyr
syntax,
+
copy_labels_from
is intended to be used with dplyr syntax,
see examples.
look_for
emulates the lookfor
Stata command in R. It supports
-searching into the variable names of regular R data frames as well as into
+
look_for
emulates the lookfor
Stata command in R. It supports
+searching into the variable names of regular R data frames as well as into
variable labels descriptions.
The command is meant to help users finding variables in large datasets.
list of keywords, a character string (or several character strings), which can be formatted as a regular expression suitable for a grep
pattern, or a vector of keywords; displays all variables if not specified
list of keywords, a character string (or several character strings), which can be
+formatted as a regular expression suitable for a base::grep()
pattern, or a vector of keywords;
+displays all variables if not specified
The function looks into the variable names for matches to the keywords. If available,
variable labels are included in the search scope.
Variable labels of data.frame imported with foreign or
-memisc packages will also be taken into account (see to_labelled
).
look_for
and lookfor
are equivalent.
to_labelled()
).
+look_for()
and lookfor()
are equivalent.
look_for(iris)#> variable diff --git a/docs/reference/na_values.html b/docs/reference/na_values.html index 3dfc99b..19db38f 100644 --- a/docs/reference/na_values.html +++ b/docs/reference/na_values.html @@ -172,22 +172,22 @@Arg
Value
--
na_values
will return a vector of values that should also be considered as missing. -na_range
will return a numeric vector of length two giving the (inclusive) - extents of the range.+
set_na_values
andset_na_range
will return an updated - copy of.data
.+
na_values()
will return a vector of values that should also be considered as missing. +na_range()
will return a numeric vector of length two giving the (inclusive) +extents of the range.
set_na_values()
andset_na_range()
will return an updated +copy of.data
.Details
-See
+labelled_spss
for a presentation of SPSS's user defined missing values. -Note thatis.na
will returnTRUE
for user defined misssing values. -You can useuser_na_to_na
to convert user defined missing values toNA
.See
haven::labelled_spss()
for a presentation of SPSS's user defined missing values. +Note thatbase::is.na()
will returnTRUE
for user defined misssing values. +You can useuser_na_to_na()
to convert user defined missing values toNA
.Note
-+
set_na_values
andset_na_range
could be used withdplyr
.
set_na_values()
andset_na_range()
could be used with dplyr syntax.See also
-+
labelled_spss
,user_na_to_na
haven::labelled_spss()
,user_na_to_na()
Examples
v <- labelled(c(1,2,2,2,3,9,1,3,2,NA), c(yes = 1, no = 3, "don't know" = 9)) diff --git a/docs/reference/recode.haven_labelled.html b/docs/reference/recode.haven_labelled.html index 463ae1c..15aaf1e 100644 --- a/docs/reference/recode.haven_labelled.html +++ b/docs/reference/recode.haven_labelled.html @@ -40,7 +40,7 @@ - @@ -130,7 +130,7 @@Recode values
-@@ -198,7 +198,7 @@Extend
recode
method from haven to +Extend
dplyr::recode()
method from dplyr to works with labelled vectors.Arg
See also
-+
recode
(dplyr)Examples
x <- labelled(1:3, c(yes = 1, no = 2)) diff --git a/docs/reference/reexports.html b/docs/reference/reexports.html index b2f15b0..cb81f74 100644 --- a/docs/reference/reexports.html +++ b/docs/reference/reexports.html @@ -139,7 +139,7 @@Objects exported from other packages
These objects are imported from other packages. Follow the links below to see their documentation.
-
- dplyr
- +
%>%
- dplyr
- haven
- diff --git a/docs/reference/remove_labels.html b/docs/reference/remove_labels.html index 4d62008..b2d0acf 100644 --- a/docs/reference/remove_labels.html +++ b/docs/reference/remove_labels.html @@ -40,9 +40,9 @@ - + @@ -131,9 +131,9 @@
format_tagged_na
,is.labelled
,is_tagged_na
,labelled
,labelled_spss
,na_tag
,print_tagged_na
,tagged_na
Remove variable label, value labels and user defined missing values
-Use
+remove_var_label
to remove variable label,remove_val_labels
-to remove value labels,remove_user_na
to remove user defined missing values (na_values and na_range) -andremove_labels
to remove all.Use
remove_var_label()
to remove variable label,remove_val_labels()
+to remove value labels,remove_user_na()
to remove user defined missing values (na_values and na_range) +andremove_labels()
to remove all.remove_labels(x, user_na_to_na = FALSE, keep_var_label = FALSE) @@ -163,12 +163,12 @@Arg
Details
-Be careful with
remove_user_na
andremove_labels
, user defined missing values +Be careful with
-remove_user_na()
andremove_labels()
, user defined missing values will not be automatically converted toNA
, except if you specifyuser_na_to_na = TRUE
.user_na_to_na(x)
is an equivalent ofremove_user_na(x, user_na_to_na = TRUE)
.If you prefer to convert variables with value labels into factors, use
+to_factor
-or useunlabelled
.If you prefer to convert variables with value labels into factors, use
to_factor()
+or useunlabelled()
.Examples
x1 <- labelled_spss(1:10, c(Good = 1, Bad = 8), na_values = c(9, 10)) diff --git a/docs/reference/to_character.html b/docs/reference/to_character.html index b6e1b53..e8dd49a 100644 --- a/docs/reference/to_character.html +++ b/docs/reference/to_character.html @@ -40,7 +40,7 @@ - @@ -131,7 +131,7 @@Convert input to a character vector
-@@ -164,7 +164,7 @@By default,
to_character
is a wrapper forbase::as.character()
. +By default,
to_character()
is a wrapper forbase::as.character()
. For labelled vector, to_character allows to specify if value, labels or labels prefixed with values should be used for conversion.Arg
Should values with no label be converted to `NA`?
Should values with no label be converted to NA
?
If some values doesn't have a label, automatic labels will be created, except if
- nolabel_to_na
is TRUE
.
nolabel_to_na
is TRUE
.
v <- labelled(c(1,2,2,2,3,9,1,3,2,NA), c(yes = 1, no = 3, "don't know" = 9)) diff --git a/docs/reference/to_factor.html b/docs/reference/to_factor.html index aa64c20..89241aa 100644 --- a/docs/reference/to_factor.html +++ b/docs/reference/to_factor.html @@ -41,11 +41,10 @@ +unlabelled(x) is a shortcut for to_factor(x, strict = TRUE, unclass = TRUE, labelled_only = TRUE)." /> @@ -135,11 +134,10 @@Convert input to a factor.
The base function
-base::as.factor()
is not a generic, but this variant -is. By default,to_factor
is a wrapper forbase::as.factor()
. -Please note thatto_factor
differs slightly fromas_factor
-method provided byhaven
package.+is. By default,
unlabelled(x)
is a shortcut for -to_factor(x, strict = TRUE, unclass = TRUE, labelled_only = TRUE)
.to_factor()
is a wrapper forbase::as.factor()
. +Please note thatto_factor()
differs slightly fromhaven::as_factor()
+method provided by haven package. +
unlabelled(x)
is a shortcut forto_factor(x, strict = TRUE, unclass = TRUE, labelled_only = TRUE)
.to_factor(x, ...) @@ -197,7 +195,7 @@Arg
Should values with no label be converted to `NA`?
Should values with no label be converted to NA
?
If not converted to a factor (when strict = TRUE
),
-convert to a character or a numeric factor?
base::unclass()
?
If some values doesn't have a label, automatic labels will be created, except if
- nolabel_to_na
is TRUE
.
nolabel_to_na
is TRUE
.
If sort_levels == 'values'
, the levels will be sorted according to the values of x
.
- If sort_levels == 'labels'
, the levels will be sorted according to labels' names.
- If sort_levels == 'none'
, the levels will be in the order the value labels are defined
- in x
. If some labels are automatically created, they will be added at the end.
- If sort_levels == 'auto'
, sort_levels == 'none'
will be used, except if some
- values doesn't have a defined label. In such case, sort_levels == 'values'
will
- be applied.
sort_levels == 'labels'
, the levels will be sorted according to labels' names.
+If sort_levels == 'none'
, the levels will be in the order the value labels are defined
+in x
. If some labels are automatically created, they will be added at the end.
+If sort_levels == 'auto'
, sort_levels == 'none'
will be used, except if some
+values doesn't have a defined label. In such case, sort_levels == 'values'
will
+be applied.
When applied to a data.frame, only labelled vectors are converted by default to a
- factor. Use labelled_only = FALSE
to convert all variables to factors.
labelled_only = FALSE
to convert all variables to factors.
unlabelled()
is a shortcut for quickly removing value labels of a vector
or of a data.frame. If all observed values have a value label, then the vector
will be converted into a factor. Otherwise, the vector will be unclassed.
-If you want to remove value labels in all cases, use remove_val_labels
.
remove_val_labels()
.
v <- labelled(c(1,2,2,2,3,9,1,3,2,NA), c(yes = 1, no = 3, "don't know" = 9)) diff --git a/docs/reference/to_labelled.html b/docs/reference/to_labelled.html index d1d4053..81892ef 100644 --- a/docs/reference/to_labelled.html +++ b/docs/reference/to_labelled.html @@ -177,26 +177,26 @@Value
A tbl data frame or a labelled vector.
Details
--
to_labelled
is a general wrapper calling the appropriate sub-functions.
memisc_to_labelled
converts adata.set
object created with ++
to_labelled()
is a general wrapper calling the appropriate sub-functions.-
memisc_to_labelled()
converts amemisc::data.set()
object created with memisc package to a labelled data frame.
foreign_to_labelled
converts data imported withread.spss
-orread.dta
from foreign package to a labelled data frame, -i.e. usinglabelled
class. +-
foreign_to_labelled()
converts data imported withforeign::read.spss()
+orforeign::read.dta()
from foreign package to a labelled data frame, +i.e. usinghaven::labelled()
. Factors will not be converted. Therefore, you should useuse.value.labels = FALSE
-when importing withread.spss
orconvert.factors = FALSE
when -importing withread.dta
.To convert correctly defined missing values imported with
+read.spss
, you should +when importing withforeign::read.spss()
orconvert.factors = FALSE
when +importing withforeign::read.dta()
.To convert correctly defined missing values imported with
-foreign::read.spss()
, you should have usedto.data.frame = FALSE
anduse.missings = FALSE
. If you used the optionto.data.frame = TRUE
, meta data describing missing values will not be attached to the import. If you useduse.missings = TRUE
, missing values would have been converted toNA
.So far, missing values defined in Stata are always imported as
+NA
by -read.dta
and could not be retrieved byforeign_to_labelled
.So far, missing values defined in Stata are always imported as
NA
by +foreign::read.dta()
and could not be retrieved byforeign_to_labelled()
.See also
-+
labelled
(foreign),read.spss
(foreign), -read.dta
(foreign),data.set
(memisc), -importer
(memisc),to_factor
.
haven::labelled()
,foreign::read.spss()
, +foreign::read.dta()
,memisc::data.set()
, +memisc::importer,to_factor()
.Examples
if (FALSE) { diff --git a/docs/reference/update_labelled.html b/docs/reference/update_labelled.html index 7aacd53..f19ca65 100644 --- a/docs/reference/update_labelled.html +++ b/docs/reference/update_labelled.html @@ -41,7 +41,7 @@ @@ -131,8 +131,8 @@Update labelled data to last version
-@@ -165,9 +165,12 @@Labelled data imported with
haven
version 1.1.2 or before or -created withlabelled
version 1.1.0 or before was using +Labelled data imported with haven version 1.1.2 or before or +created with
haven::labelled()
version 1.1.0 or before was using "labelled" and "labelled_spss" classes.Details "haven_labelled_spss" are used instead.
Since haven 2.3.0, "haven_labelled" class has been evolving using now vctrs package.
-
update_labelled
convert labelled vectors ++
update_labelled()
convert labelled vectors from the old to the new classes and to reconstruct all labelled vectors with the last version of the package.See also
+ +
A named vector for val_labels
(see labelled
) or a character string
-for val_labels
. NULL
to remove the labels.
+
A named vector for val_labels()
(see haven::labelled()
) or a character string
+for val_labels()
. NULL
to remove the labels.
For data frames, it could also be a named list with a vector of value labels per variable.
value labels to be applied to the data.frame,
-using the same syntax as value
in `val_labels(df) <- value`.
value
in val_labels(df) <- value
.
val_labels
will return a named vector.
- val_label
will return a single character string.
set_value_labels
, add_value_labels
and remove_value_labels
will return an updated
- copy of .data
.
val_labels()
will return a named vector.
+val_label()
will return a single character string.
set_value_labels()
, add_value_labels()
and remove_value_labels()
will return an updated
+copy of .data
.
set_value_labels
, add_value_labels
and remove_value_labels
could be used with dplyr
.
- While set_value_labels
will replace the list of value labels, add_value_labels
and
- remove_value_labels
will update that list (see examples).
set_value_labels()
, add_value_labels()
and remove_value_labels()
+could be used with dplyr syntax.
+While set_value_labels()
will replace the list of value labels,
+add_value_labels()
and remove_value_labels()
will update that list (see examples).
v <- labelled(c(1,2,2,2,3,9,1,3,2,NA), c(yes = 1, no = 3, "don't know" = 9)) diff --git a/docs/reference/val_labels_to_na.html b/docs/reference/val_labels_to_na.html index 2fce3dd..534f830 100644 --- a/docs/reference/val_labels_to_na.html +++ b/docs/reference/val_labels_to_na.html @@ -145,7 +145,7 @@Arg
See also
- +Examples
v <- labelled(c(1, 2, 9, 1, 9), c(dk = 9)) diff --git a/docs/reference/var_label.html b/docs/reference/var_label.html index a19c571..a13d797 100644 --- a/docs/reference/var_label.html +++ b/docs/reference/var_label.html @@ -166,22 +166,22 @@Arg
.labels +using the same syntax as variable labels to be applied to the data.frame, -using the same syntax as
value
in `var_label(df) <- value`.value
invar_label(df) <- value
.Value
-+
set_variable_labels
will return an updated copy of.data
.
set_variable_labels()
will return an updated copy of.data
.Details
For data frames, if
+match a column of the data frame will be taken into account. Ifvalue
is a named list, only elements whose name will - match a column of the data frame will be taken into account. Ifvalue
- is a character vector, labels should in the same order as the columns of the - data.frame.value
+is a character vector, labels should in the same order as the columns of the +data.frame.Note
-+
set_variable_labels
could be used withdplyr
.
set_variable_labels()
could be used with dplyr syntax.Examples
var_label(iris$Sepal.Length)#> NULLvar_label(iris$Sepal.Length) <- 'Length of the sepal'