-
Notifications
You must be signed in to change notification settings - Fork 132
Option for row_to_names to find the first complete row of names #429 8000
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
Comments
That makes sense and seems pretty straight-forward to me. That said, if we're going to extend the feature, I'd like to consider one more use case: I often know the value to search for in the names row. From your example, I'd want to find the text "Value" in column 1. My typical method would be to do something like: Assuming the that data has been loaded into header_row <- which(my_data[[1]] %in% "Value")
stopifnot(length(header_row) == 1)
my_clean_data <- row_to_names(my_data, header_row) As I think about the solution here, I think that a separate function may be the right answer. Specifically, something that finds a header row like: find_header(data, ...) If no What do you think: Am I adding too much indirection and making |
And, another thought is that you could have it all:
That is probably the best of all worlds: Simple enough to use, and it doesn't add much complexity to the |
I like it! As you note, it keeps the original function simple while opening up more possibilities in a new function. The only hangup I see right now is that if |
Good catch. Let's go with your addition: |
FYI, I'm working on this. |
Feature request
I am working with data that looks like this:
And want to get the
row.names
from line 160. It would be nice if I could tellrow_to_names
to use the first complete row for the names. Often the clutter above the row names is descriptive text that only occupies some columns, so would get skipped in favor of the first row with no NA values.I'm not sure how to work it in - it could be:
row_number
is specified, printing a message of "no row number specified, using the first complete row (row X)`row_number
could accept "first_complete", or0
as a value requesting this behavior.I prefer the second bullet, though I'm not sure if
first_complete
or0
is better. Either way it would be documented.The text was updated successfully, but these errors were encountered: