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
Allow spaces in id column name #25
Comments
Hi, |
Well, technically, R does allow variable names with spaces :) but I agree with you that this may not be worth "fixing" here as much as it is worth updating the documentation. |
The issue with that is that data.frame(
`Enc ID` = 1234,
DxCode = 'N390')
#> Enc.ID DxCode
#> 1 1234 N390
data.frame(
`Enc ID` = 1234,
DxCode = 'N390',
check.names = FALSE)
#> Enc ID DxCode
#> 1 1234 N390 Created on 2019-12-13 by the reprex package (v0.3.0) The error you see is that the name of the input dt <- data.frame(
`Enc ID` = 1234,
DxCode = 'N390',
check.names = FALSE)
comorbidity(dt, id = 'Enc ID', code = 'DxCode', icd = 'icd10', score = 'charlson', assign0 = F)
#> Error in parse(text = x, keep.source = FALSE): <text>:1:5: unexpected symbol
#> 1: Enc ID
#> ^ Created on 2019-12-13 by the reprex package (v0.3.0) This still does not work. I now call the dt <- data.frame(
`Enc ID` = 1234,
DxCode = 'N390'
)
comorbidity(dt, id = 'Enc ID', code = 'DxCode', icd = 'icd10', score = 'charlson', assign0 = F)
#> Warning: The input 'id' string has been modified by make.names(). See ?
#> make.names() for more details.
#> Enc.ID ami chf pvd cevd dementia copd rheumd pud mld diab diabwc hp rend canc
#> 1 1234 0 0 0 0 0 0 0 0 0 0 0 0 0 0
#> msld metacanc aids score index wscore windex
#> 1 0 0 0 0 0 0 0 Created on 2019-12-13 by the reprex package (v0.3.0) It now works! As you can see, when names are changed a warning is triggered: #> Warning: The input 'id' string has been modified by make.names(). See ?
#> make.names() for more details. What do you think about all of the above @salmasian? |
This is similar to the normal R behavior (i.e. in other places, R also cleans up variable names) so I think it is is a worthwhile effort and I support that. The warning should not be suppressed. |
Sounds good to me - I am actually the one triggering the warning 😃 I am closing this, and will submit to CRAN by the end of the year. Thanks again @salmasian! |
The way #20 was fixed does not allow for the
id
column's name to contain spaces.What you get is an error message:
The text was updated successfully, but these errors were encountered: