-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include dplyr function rename in tidylog package #27
Comments
This is a bit tricky because it’s impossible to tell how the columns were renamed from just inspecting the data frame before and after. This means one has to gather this information from the arguments, which is error-prone. Any ideas would be appreciated. |
Maybe by comparing column names by commando > a <- data.frame(col1 = c(1,2), col2 = c(3,4))
> name_cols_before <- colnames(a)
> name_cols_before
[1] "col1" "col2"
> a <- dplyr::rename(a, newcol1 = col1)
> name_cols_after <- colnames(a)
> name_cols_after
[1] "newcol1" "col2"
> paste(
"Column",
name_cols_before[name_cols_after != name_cols_before],
"renamed as",
name_cols_after[name_cols_after != name_cols_before]
)
[1] "Column col1 renamed as newcol1" This is for Or did I misunderstand your reply? Still thanks for paying attention to this issue. |
Right, that's the approach that's being used for all the other functions. But I always assumed that a <- data.frame(col1 = c(1,2), col2 = c(3,4))
names(a)
#> [1] "col1" "col2"
names(dplyr::rename(a, newcol1 = col1, newcol2 = col2))
#> [1] "newcol1" "newcol2"
names(dplyr::rename(a, newcol1 = col2, newcol2 = col1))
#> [1] "newcol2" "newcol1"
names(dplyr::rename(a, newcol2 = col2, newcol1 = col1))
#> [1] "newcol1" "newcol2" Created on 2019-09-17 by the reprex package (v0.3.0) |
Thanks @elbersb : yes, I played a little with |
While using this very useful package, I find it would be nice to get information also about column renaming while working with
dplyr::rename()
in pipes.The text was updated successfully, but these errors were encountered: