radiant-rstats / radiant.data

Code for the Data menu in Radiant
https://radiant-rstats.github.io/radiant.data
Other
54 stars 44 forks source link

Pivot: factor and date in catagorical variable #7

Closed kmezhoud closed 7 years ago

kmezhoud commented 7 years ago

@vnijs I can't reproduce the issue using diamonds data set. I am using dosimetry.rda. Case study: I would like to visualize the cumulative doses (sum) of 4 samples of each person. 4 samples means I have 4 sampling dates. Categorical variables: Name (factor) + Date (date) numeric variable: DCE (numeric) apply function: sum

If I invert the order of categorical variable: Date (date) + Name (factor), the error is avoided.

error

Warning: Error in eval: found duplicated column name: Date
Stack trace (innermost first):
    119: <Anonymous>
    118: stop
    117: mutate_impl
    116: mutate_.tbl_df
    115: mutate_
    114: mutate_each_
    113: function_list[[k]]
    112: withVisible
    111: freduce
    110: _fseq
    109: eval
    108: eval
    107: withVisible
    106: %>%
    105: <Anonymous>
    104: do.call
    103: withCallingHandlers
    102: suppressMessages
    101: withCallingHandlers
    100: suppressWarnings
     99: sshhr
     98: eval [tools/data/pivotr_ui.R#168]
     97: eval
     96: withProgress
     95: <reactive:.pivotr> [tools/data/pivotr_ui.R#167]
     84: .pivotr
     83: exprFunc [tools/data/pivotr_ui.R#182]
     82: widgetFunc
     81: func
     80: origRenderFunc
     79: renderFunc
     78: origRenderFunc
     77: output$pivotr
      2: runApp
      1: radiant.data
vnijs commented 7 years ago

The issue is that the name variable has a level called Date. When you try to make a table where Date is a column name and the levels of Name are column names you get this problem. I'm not sure there is an easy solution for this.

kmezhoud commented 7 years ago

I just need to rename Date by date. Thanks

vnijs commented 7 years ago

You can indeed change your data :) What I meant was, there is not an easy way to address this issue in the code