From 4d135fd2675557134817ac5b70e158d63ffc7e23 Mon Sep 17 00:00:00 2001 From: Josep Pueyo-Ros Date: Wed, 30 Oct 2024 09:54:38 +0100 Subject: [PATCH] adapted labels to issue with 'sf_column' not being last --- R/clean_names.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/clean_names.R b/R/clean_names.R index 5570b1d..388144d 100644 --- a/R/clean_names.R +++ b/R/clean_names.R @@ -111,10 +111,10 @@ clean_names.sf <- function(dat, ..., set_labels = FALSE) { # clean all but last column sf_cleaned <- make_clean_names(sf_names[cols_to_rename], ...) # rename original df - names(dat)[1:n_cols] <- sf_cleaned + names(dat)[cols_to_rename] <- sf_cleaned if(set_labels){ - for (i in seq_along(sf_names[1:n_cols])){ + for (i in seq_along(sf_names[cols_to_rename])){ attr(dat[[i]], "label") <- sf_names[[i]] } }