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

Cannot Load Files when ID Column is Aliased #97

Open
billdenney opened this issue May 18, 2018 · 6 comments
Open

Cannot Load Files when ID Column is Aliased #97

billdenney opened this issue May 18, 2018 · 6 comments

Comments

@billdenney
Copy link
Contributor

In my $INPUT block, I specify that "ID=USUBJIDNUMERIC". With that, the ID in the tables is now titled "USUBJIDNUMERIC" rather than "ID".

I think that the fix would be to detect mapping and allow an argument that makes it to the index_table function (

xpose/R/read_nm_tables.R

Lines 366 to 377 in 942f8b1

dplyr::mutate(type = dplyr::case_when(
.$col == 'ID' ~ 'id',
.$col == 'DV' ~ 'dv',
.$col == 'TIME' ~ 'idv',
.$col == 'OCC' ~ 'occ',
.$col == 'DVID' ~ 'dvid',
.$col == 'AMT' ~ 'amt',
.$col == 'MDV' ~ 'mdv',
.$col == 'EVID' ~ 'evid',
.$col == 'IPRED' ~ 'ipred',
.$col == 'PRED' ~ 'pred',
.$col %in% c('RES', 'WRES', 'CWRES', 'IWRES', 'EWRES', 'NPDE') ~ 'res',
) where the different required column types are mapped. Ideally, this would be auto-detected from the $INPUT block and possible to override by the user.

Generally, this can apply for any column since they all could be mapped to different names.

@billdenney
Copy link
Contributor Author

... And, something like the following could help with the feature request:

parse_nonmem_input_block <- function(code) {
  all_code <- paste(code, collapse=" ")
  var_blocks <- strsplit(x=all_code, split=" +")[[1]]
  name_blocks <- strsplit(x=var_blocks, split="=", fixed=TRUE)
  name_blocks %>%
    purrr::map(.f=function(x) {
      if (length(x) == 1) {
        setNames(x, nm=x)
      } else if (length(x) == 2) {
        setNames(object=x[2], nm=x[1])
      } else {
        stop("$INPUT elements must be mapped with either no equal sign or one equal sign.  Cannot parse '", paste(x, collapse="="), "'")
      }
    })
}

parse_nonmem_input_block(xpdb$code %>% filter(subroutine %in% "inp") %>% magrittr::extract2("code"))

@bguiastr
Copy link
Collaborator

@billdenney I have done some updates on read_nm_tables(), among other things I removed the dependency on the ID column and preserved the filenames in preparation to #140

Can you check can check d7686e9 and see if that solves this issue for you?

@billdenney
Copy link
Contributor Author

I'll try to check this soon. (I'm about to be off to ACoP, but hopefully I can check when I get back.)

@billdenney
Copy link
Contributor Author

I just tried the dev branch (not just the specific patch), but I was getting what appeared to be unrelated errors. Are you switching the class name away from xpose_data to xpdb? The errors appeared to be related to that.

@bguiastr
Copy link
Collaborator

bguiastr commented Nov 3, 2019 via email

@billdenney
Copy link
Contributor Author

Thanks for that update. I need most of those PRs for some of my current projects that I’m updating. I’m going to add another couple of PRs that will make it functional for my projects, and hopefully they will be helpful to your efforts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants