-
Notifications
You must be signed in to change notification settings - Fork 194
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
Provide a convenient way to silence "New names" message when using col_names = FALSE #580
Comments
readxl affords no control over this and I'm not aware of a tibble option that helps either. It is ultimately emitted via library(readxl)
suppressMessages(
read_excel(readxl_example("clippy.xlsx"), col_names = FALSE)
)
#> # A tibble: 5 x 2
#> ...1 ...2
#> <chr> <chr>
#> 1 name value
#> 2 Name Clippy
#> 3 Species paperclip
#> 4 Approx date of death 39083
#> 5 Weight in grams 0.9 Created on 2019-08-08 by the reprex package (v0.3.0.9000) |
My suggestion was to add this as a feature. Here is a simple implementation how I'm currently implementing
Is this something that seems a better fit with |
Yeah I do think it's a better issue to ponder in tibble (or conceivably even further upstream). Because ... I'm not going to add an argument to |
Also: what is your context? Is this about an Rmd document or similar? |
My reason for asking about |
I get that I'm a couple years late to the party but I second the notion that this is a problem with readxl, not with generic tibble construction. IMO, readxl should provide default column names when none or provided - this shouldn't require changing the core tibble API/contract and readxl is in a much better position to understand how many columns are being read than the user code calling it. You could even use col_names = NULL as the flag to provide default colnames (e.g. "Col1" or "ColA") without changing the current behavior. |
New names: This type of output is not at all helpful. |
In my case, I want to skip the first column and I indicate it through col_types with the "_" character which means "skip column". Yet I got the message that the name of this column has been changed, which I couldn't care less about. If I use |
I can confirm this is still happening and still annoying. |
Would also like a solution to this, please |
Thanks to a change in a low-level package (vctrs), we now have a really nice solution to this in readxl and elsewhere. Add library(readxl)
packageVersion("vctrs")
#> [1] '0.5.1'
read_excel(path = readxl_example('clippy.xlsx'), col_names = FALSE)
#> New names:
#> • `` -> `...1`
#> • `` -> `...2`
#> # A tibble: 5 × 2
#> ...1 ...2
#> <chr> <chr>
#> 1 name value
#> 2 Name Clippy
#> 3 Species paperclip
#> 4 Approx date of death 39083
#> 5 Weight in grams 0.9
read_excel(
path = readxl_example('clippy.xlsx'),
col_names = FALSE,
.name_repair = "unique_quiet"
)
#> # A tibble: 5 × 2
#> ...1 ...2
#> <chr> <chr>
#> 1 name value
#> 2 Name Clippy
#> 3 Species paperclip
#> 4 Approx date of death 39083
#> 5 Weight in grams 0.9 Created on 2022-12-09 with reprex v2.0.2.9000 Place to read more if you're curious: r-lib/vctrs#1629 |
When using
col_names = FALSE
, an automated message with "New names" lists the (new) column names. Can a feature be added that avoids printing this information? Something likemessages = FALSE
. It would be helpful when working with fixed/known inputs for which new column names are specified programmatically.The following code replicates the display:
Here is the output:
The text was updated successfully, but these errors were encountered: