Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6876379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:28:12+00:00 2026-05-27T04:28:12+00:00

Lets have the following dataframe inside R: df <- data.frame(sample=rnorm(1,0,1),params=I(list(list(mean=0,sd=1,dist=Normal)))) df <- rbind(df,data.frame(sample=rgamma(1,5,5),params=I(list(list(shape=5,rate=5,dist=Gamma))))) df

  • 0

Lets have the following dataframe inside R:

df <- data.frame(sample=rnorm(1,0,1),params=I(list(list(mean=0,sd=1,dist="Normal"))))
df <- rbind(df,data.frame(sample=rgamma(1,5,5),params=I(list(list(shape=5,rate=5,dist="Gamma")))))
df <- rbind(df,data.frame(sample=rbinom(1,7,0.7),params=I(list(list(size=7,prob=0.7,dist="Binomial")))))
df <- rbind(df,data.frame(sample=rnorm(1,2,3),params=I(list(list(mean=2,sd=3,dist="Normal")))))
df <- rbind(df,data.frame(sample=rt(1,3),params=I(list(list(df=3,dist="Student-T")))))

The first column contains a random number of a probability distribution and the second column stores a list with its parameters and name.
The dataframe df looks like:

      sample       params
1 0.85102972 0, 1, Normal
2 0.67313218  5, 5, Gamma
3 3.00000000 7, 0.7, ....
4 0.08488487 2, 3, Normal
5 0.95025523 3, Student-T

Q1: How can I have the list of name distributions for all records? df$params$dist does not work. For a single record is easy, for example the third one: df$params[[3]]$dist

Q2: Is there any alternative way of storing data like this? something like a multi-dimensional dataframe? I do not want to add columns for each parameter because it will scatter the dataframe with missing values.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:28:13+00:00Added an answer on May 27, 2026 at 4:28 am

    It’s probably more natural to store information like this in a pure list structure, than in a data frame:

    distList <- list(normal = list(sample=rnorm(1,0,1),params=list(mean=0,sd=1,dist="Normal")),
                        gamma = list(sample=rgamma(1,5,5),params=list(shape=5,rate=5,dist="Gamma")),
                        binom = list(sample=rbinom(1,7,0.7),params=list(size=7,prob=0.7,dist="Binomial")),
                        normal2 = list(sample=rnorm(1,2,3),params=list(mean=2,sd=3,dist="Normal")),
                        tdist = list(sample=rt(1,3),params=list(df=3,dist="Student-T")))
    

    And then if you want to extract just the distribution name from each, we can use sapply to loop over the list and extract just that piece:

    sapply(distList,function(x) x[[2]]$dist)
         normal       gamma       binom     normal2       tdist 
       "Normal"     "Gamma"  "Binomial"    "Normal" "Student-T" 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say i have the following unordered list <ul> <li><a>Hank</a></li> <li><a>Alice</a></li> <li><a>Tom</a></li> <li><a>Ashlee</a></li> </ul>
Lets say I have the following data: <XmlDataProvider x:Key=Values> <x:XData> <folder name=C:> <folder name=stuff
Let's say I have the following data frame. dat <- data.frame(city=c(Chelsea,Brent,Bremen,Olathe,Lenexa,Shawnee), tag=c(rep(AlabamaCity,3), rep(KansasCity,3))) I
Lets say I have the following class structure in my data access layer: interface
All right, let's say I have the following plot. df = data.frame(date=c(rep(2008:2013, by=1)), value=c(303,407,538,696,881,1094))
Lets say I have the following code: abstract class Animal case class Dog(name:String) extends
Lets say I have the following: public class MyObject { [Bindable] public var foo:int
Lets say i have the following c# classes: abstract class a { protected abstract
Lets say I have the following array in JavaScript: var skins = new Array('Light',
Lets say I have the following pages: # Include.asp <% Response.Write IsIncluded() & <br>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.