Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Storing functions in dataframe in R

I am doing some bayesian analysis and have empirical distributions for many features (that is, one distribution for each feature). I want to store the feature indices, their distribution functions and some other information in a data frame or a tibble, one row for each feature, for convenience of further usage.

But I think data.frame or tibble function in R won’t allow functions as their input. Is there an alternative way to save those as a dataframe-type structure?

Thanks in advance!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can do store those functions as part of a data.table or tibble, like with this example:

data.table(id=c(1,2,3), dist_funcs = list(pnorm, ppois, pbinom))

Output:

      id    dist_funcs
   <num>        <list>
1:     1 <function[1]>
2:     2 <function[1]>
3:     3 <function[1]>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading