Skip to content
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

Empty strings in character or factor variables #19

Closed
vincentarelbundock opened this issue Oct 14, 2023 · 0 comments
Closed

Empty strings in character or factor variables #19

vincentarelbundock opened this issue Oct 14, 2023 · 0 comments

Comments

@vincentarelbundock
Copy link
Contributor

vincentarelbundock commented Oct 14, 2023

Thanks for your work on this great package! I use it all the time and love it.

I’m wondering if it would be possible to handle empty strings more gracefully. For example, this CSV file includes empty strings in the sex column. If I read the file with read.csv(url,na.strings="") then tabular() works without issues. However, if I read the file with read.csv(url), then I get a cryptic error message. I feel that empty strings may be a valid category in some cases.

library(tables)

url <- 'https://vincentarelbundock.github.io/Rdatasets/csv/palmerpenguins/penguins.csv'

dat <- read.csv(url, na.strings = "")
tabular(Factor(sex) ~ bill_length_mm * mean * Arguments(na.rm = TRUE), data = dat)
#                       
#         bill_length_mm
#  sex    mean          
#  female 42.10         
#  male   45.85

dat <- read.csv(url)
tabular(Factor(sex) ~ bill_length_mm * mean * Arguments(na.rm = TRUE), data = dat)
# Error in as.name(catname): attempt to use zero-length variable name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant