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

diff: getdata(dataset), .getdata(dataset), getdata(input$dataset) #1

Closed kmezhoud closed 8 years ago

kmezhoud commented 8 years ago

Dear Dr Vincent, It is not really an issue. It is just for better understanding the code.

getdata(datasat,...): Get data for analysis functions
.getdata(dataset): get active dataset and apply data-filter if available

In Manageand View tabs, radiant uses active datasets by .getdata()or getdata(input$dataset). But in the other tabs Visualize, Pivotr, explore radiant uses getdata(dataset, ....)

In my mind it is enough to use active dataset bygetdata(input$dataset, vars=..,...)for all tabs.

What is the interest of all these options? Karim Thanks

kmezhoud commented 8 years ago

I am having strange case. I added to radiant.data the following functionality: http://ipub.com/shiny-crud-app/ that can edit /remove /delete directly from table (example: http://ipub.com/apps/shiny_crud01/) . here the state that works fine with radiant.data() but not when I add crud01 functions. Here the state that responses dataset is not recognized by getdata(datset, ..) function https://drive.google.com/open?id=0B9NOY9eukkEeMkFTYjNrLUsyaEk

video demo: https://drive.google.com/open?id=0B9NOY9eukkEeS3Y4WXVhckFXRFE

vnijs commented 8 years ago

.getdata is a reactive and is used in the UI functions. getdata is a regular function and is used in exported functions. I need both in radiant.data.

I don't really understand your 2nd question. I can't read the error message (low resolution) and without a reproducible example and code I can't tell what is going on.

Question: Are you editing the radiant.data source code or working to extend radiant.data like in, for example, radiant.design?

kmezhoud commented 8 years ago

I would like to extend radiant.data by other functionalities to manage database of human health measurements. 1- add more easy way to add/remove samples (directly from table). 2- add alert system to remember the date of sampling of each person 2- connect or convert r_data to sqlite database. 3- Secure access for editing database

Here a state where is a responsesdataframe. https://drive.google.com/open?id=0B9NOY9eukkEeMkFTYjNrLUsyaEk

getdata() func can not recognizes responses r_data in my code. It is recognized when it is loaded by radiant.data. I did not change the code of radiant.data. I just add this code http://ipub.com/shiny-crud-app/ into a second tabPanel named Edit like Data

the responseswas added to r_ data by

CreateData <-
  function(data) {
    data <- InitData(data)
    rownames(data) <- GetNextId()
    if(!is.null(r_data[['responses']])){
      #(exists("r_data"))
      r_data[['responses']] <- rbind(r_data$responses, data)

      r_data[[paste0('responses',"_descr")]] <- attr(r_data[['responses']], "description")
      r_data[['datasetlist']] <- c('responses',r_data[['datasetlist']]) %>% unique
    } else {
      r_data[['responses']] <- data

      r_data[[paste0('responses',"_descr")]] <- attr(r_data[['responses']], "description")
      r_data[['datasetlist']] <- c('responses',r_data[['datasetlist']]) %>% unique
    }

  }

Thanks

kmezhoud commented 8 years ago

In which case r_data$responses is recognized by .getdata()and not getdata() ?

Dataset responses is not available. Please load the dataset and use the name in the function call
Warning: Error in eval: 
Stack trace (innermost first):
    129: eval [/Library/Frameworks/R.framework/Versions/3.3/Resources/library/Dosimetrix/app/tools/Ris/radiant.R#135]
    128: eval
    127: %>%
    126: getdata [/Library/Frameworks/R.framework/Versions/3.3/Resources/library/Dosimetrix/app/tools/Ris/radiant.R#119]
    125: <Anonymous> [/Library/Frameworks/R.framework/Versions/3.3/Resources/library/Dosimetrix/app/tools/Ris/visualize.R#112]
    124: do.call
    123: function_list[[k]]
    122: withVisible
    121: freduce
    120: _fseq
    119: eval
    118: eval
    117: withVisible
    116: %>%
    115: <reactive:.visualize> [tools/data/visualize_ui.R#430]
    104: .visualize
    103: eval
    102: eval
    101: %>%
    100: renderPlot [tools/data/visualize_ui.R#380]
     90: <reactive:plotObj>
     79: plotObj
     78: origRenderFunc
     77: output$visualize
      2: runApp
      1: Dosimetrix [/Volumes/DATA/Dosimetrix/R/Dosimetrix.R#24]
vnijs commented 8 years ago

I would suggest the option to add samples etc. should be setup as an extension to radiant.data just like, for example, radiant.design. However, from the Dosimetrix repo it does not seem that this is how you are setting this up.

Writing to/from an sqlite database is something that could be added directly to radiant.data (e.g., through a pull request).

I can't tell what is going on in your example. Can you point me to the code files / lines in the Dosimetrix repo?

kmezhoud commented 8 years ago

I convert my fork as radiant extend. It has now the same structure as radiant.design. The issue is resolved naturally. Now I will work for radiant to add items listed above. Thanks

vnijs commented 8 years ago

If I look, for example, here it seems like you still have a ton of code from radiant.data in your fork. Basically you shouldn't have any code or help files from radiant.data in your application but should source/import from the package like in radiant.design.

kmezhoud commented 8 years ago

Yes I'm aware about this. It is tagged as bkp (bachup) just for moment :)

On Wed, Sep 14, 2016 at 10:32 PM, Vincent Nijs notifications@github.com wrote:

If I look, for example, here https://github.com/kmezhoud/Dosimetrix/tree/master/inst/app/tools/Risbkp it seems like you still have a ton of code from radiant.data in your fork. Basically you shouldn't have any code or help files from radiant.data in your application but should source/import from the package like in radiant.design.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/radiant-rstats/radiant.data/issues/1#issuecomment-247161820, or mute the thread https://github.com/notifications/unsubscribe-auth/AEQG0-pK1AMgeFikQG8E6GRM_vFcsLgRks5qqGgJgaJpZM4J6xHA .

vnijs commented 8 years ago

Ah. OK. I'll close this issue for now then.