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 9133365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:28:34+00:00 2026-06-17T08:28:34+00:00

I have a data frame with something like the following structure: Trial Index Condition1

  • 0

I have a data frame with something like the following structure:

Trial Index    Condition1    Condition2    Measures
1              A             Y             ...
2              A             Y             ...        
3              B             Y             ...
4              B             Y             ...
5              A             Z             ...
6              A             Z             ...        
7              B             Z             ...
8              B             Z             ...

I would like to compute a number of summary measures on each combination of Condition1 and Condition2, and for the margins. I can use multiple calls to ddply to do this, but I was wondering if there is some simple way to get a single data structure out of it, something like:

Condition1    Condition2    Mean    Median    ....
A             Y             ...     ...       ....
A             Z             ...     ...       ....
A             -             ...     ...       ....             
B             Y             ...     ...       ....
B             Z             ...     ...       ....
B             -             ...     ...       ....
-             Y             ...     ...       ....
-             Z             ...     ...       ....
  • 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-17T08:28:35+00:00Added an answer on June 17, 2026 at 8:28 am

    @DWin is right, tables package might be the right clue here. Without taking care of formating here’s an example:

    library(tables)
    d1 <- data.frame(id = 1:10, c1 = sample(c("a","b"), 10, replace = TRUE), 
            c2 = sample(c("c", "d"), 10, replace = TRUE), measures = rnorm(1:10))
    t1 <- tabular((c1 + c2 + c1*c2 +1) ~ (measures)*(mean + median), data = d1)
    
                 measures        
                 mean     median 
          c1 a   -0.33306 -0.1801
             b   -0.54121 -0.6381
          c2 c   -0.04862  0.1647
             d   -0.69615 -0.8129
     c1 a c2 c   -0.26195 -0.2619
             d   -0.38047 -0.1801
        b    c    0.16472  0.1647
             d   -1.01182 -1.1863
             All -0.43713 -0.4678
    

    It takes a while to get into the syntax though; on the plus side it provides functionality to export the tables to LaTeX. If you don’t want/need all the labeling in that tabular object you can extract the values via as.matrix(t1, format = as.numeric).

    NOTE: c1 and c2 on the left hand side of the formula have to be factor for this to work

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data.frame of a time series of data, I would like to
I have two data frames that look like something like the following: df1 <-
I have a data.frame that has a number of duplicate rows, akin to something
I have the following question: I have data frame which looks like this. I
I have a data frame with following structure: pat <- c(rep(1,50), rep(2,50), rep(3,50)) inc
I have the following data frame: id,property1,property2,property3 1,1,0,0 2,1,1,0 3,0,0,1 4,1,1,1 d.f <- structure(list(id
I have a data set which looks something like data<-c(0,1,2,3,4,2,3,1,4,3,2,4,0,1,2,0,2,1,2,0,4) frame<-as.data.frame(data) I now want
I have the following dataframe df <- data.frame( Type=rep(LETTERS[1:6],3), Level=rep(1:3,each=6), Value=1:18) I'd like to
For on the dataframe AB: AB<-data.frame(ID=c(1,2,4),A=c(2,8,8),B=c(6,2,2),dE=c(0,0,0)) I would like to apply the following formula:
I have a data frame like below (20,000 rows by 49 cols). Each row

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.