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

  • Home
  • SEARCH
  • 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 9225779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:39:54+00:00 2026-06-18T04:39:54+00:00

Possible Duplicate: How to create a prop.table() for a three dimension table? I am

  • 0

Possible Duplicate:
How to create a prop.table() for a three dimension table?

I am new to R, and I have been working on a three way table and need some help. Here is the table description via dput:

mytable <- structure(c(42L, 151L, 313L, 69L, 22L, 46L, 47L, 24L, 17L, 36L, 108L, 16L), .Dim = c(2L, 2L, 3L), .Dimnames = list(c("0", "1" ), c("female", "male"), c("adult", "child", "unknown")), class = "table") 

I would like to access elements of this table by using the attribute names. For example:
mytable["0"]["female"]["adult"]Is it possible to do this ?

Also, I am trying to calculate proportions. Here is my table….

, , adult

      female male
    0     42  313
    1    151   69

    , , child

      female male
    0     22   47
    1     46   24

    , , unknown

      female male
    0     17  108
    1     36   16

I would like to calculate proportions for age group-sex-0|1. When I run prop.table(mytable)it is calculating proportions of the cells, but it is considering all the three age groups.

, , adult

          female       male
    0 0.04713805 0.35129068
    1 0.16947250 0.07744108

    , , child

          female       male
    0 0.02469136 0.05274972
    1 0.05162738 0.02693603

    , , unknown

          female       male
    0 0.01907969 0.12121212
    1 0.04040404 0.01795735

I want proportions for each age group and sex. For example: Of all the adults, females with 1 are 78 %. How do we do this ?

  • 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-06-18T04:39:55+00:00Added an answer on June 18, 2026 at 4:39 am

    Is this what you are chasing?

    The data:

    test <- structure(c(42L, 151L, 313L, 69L, 22L, 46L, 47L, 24L, 17L, 36L, 108L, 16L), .Dim = c(2L, 2L, 3L), .Dimnames = list(c("0", "1" ), c("female", "male"), c("adult", "child", "unknown")), class = "table") 
    

    Get the column percentages (2) within each sub-table (3):

    prop.table(test,c(2,3))
    

    Results in:

    , , adult
    
         female      male
    0 0.2176166 0.8193717
    1 0.7823834 0.1806283
    
    , , child
    
         female      male
    0 0.3235294 0.6619718
    1 0.6764706 0.3380282
    
    , , unknown
    
         female      male
    0 0.3207547 0.8709677
    1 0.6792453 0.1290323
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to create multidemensional arraylist in Java? I have been having trouble
Possible Duplicate: Create instance of generic type in Java? I have some code: public
Possible Duplicate: Create new class from a Variable in Java I have a string
Possible Duplicate: Create an alert on any view controller after Facebook request:didFailWithError: I have
Possible Duplicate: Create new C++ object at specific memory address? I am writing what
Possible Duplicate: Most efficient way to create a zero filled JavaScript array? I wish
Possible Duplicate: Activator.CreateInstance - How to create instances of classes that have parameterized constructors
Possible Duplicate: Create a date with T-SQL I've a data table that stores each
Possible Duplicate: How to create XSD file programmatically in C#? I have an XDocument
Possible Duplicate: How to create comma separated list from array in PHP? I have

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.