Nothing
#' Rescue lost attributes
#'
#' You can use this function if some of your items have lost their attributes during wrangling
#' Variables have to have the same name (Duh) and no attributes should be overwritten.
#' But use with care. Similar to [labelled::copy_labels()].
#'
#'
#' @param df_no_attributes the data frame with missing attributes
#' @param df_with_attributes the data frame from which you want to restore attributes
#'
#' @export
#'
rescue_attributes <- function(df_no_attributes, df_with_attributes) {
for (i in seq_along(names(df_no_attributes))) {
var <- names(df_no_attributes)[i]
if (var %in% names(df_with_attributes) &&
is.null(attributes(df_no_attributes[[var]]))) {
attributes(df_no_attributes[[var]]) <-
attributes(df_with_attributes[[var]])
} else {
for (e in seq_along(names(attributes(df_with_attributes[[var]])))) {
attrib_name <- names(attributes(df_with_attributes[[var]]))[e]
if (!attrib_name %in% names(attributes(df_no_attributes[[var]]))) {
attributes(df_no_attributes[[var]])[[attrib_name]] <-
attributes(df_with_attributes[[var]])[[attrib_name]]
}
}
}
}
df_no_attributes
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.