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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:35:32+00:00 2026-05-12T14:35:32+00:00

Does anyone have any good thoughts on how to code complex tabulations in R?

  • 0

Does anyone have any good thoughts on how to code complex tabulations in R?

I am afraid I might be a little vague on this, but I want to set up a script to create a bunch of tables of a complexity analogous to the stat abstract of the united states.

e.g.: http://www.census.gov/compendia/statab/tables/09s0015.pdf

And I would like to avoid a whole bunch of rbind and hbind statements.

In SAS, I have heard, there is a table creation specification language; I was wondering if there was something of similar power for R?

Thanks!

  • 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-12T14:35:33+00:00Added an answer on May 12, 2026 at 2:35 pm

    It looks like you want to apply a number of different calculations to some data, grouping it by one field (in the example, by state)?

    There are many ways to do this. See this related question.

    You could use Hadley Wickham’s reshape package (see reshape homepage). For instance, if you wanted the mean, sum, and count functions applied to some data grouped by a value (this is meaningless, but it uses the airquality data from reshape):

    > library(reshape)
    > names(airquality) <- tolower(names(airquality))
    > # melt the data to just include month and temp
    > aqm <- melt(airquality, id="month", measure="temp", na.rm=TRUE)
    > # cast by month with the various relevant functions
    > cast(aqm, month ~ ., function(x) c(mean(x),sum(x),length(x)))
      month X1   X2 X3
    1     5 66 2032 31
    2     6 79 2373 30
    3     7 84 2601 31
    4     8 84 2603 31
    5     9 77 2307 30
    

    Or you can use the by() function. Where the index will represent the states. In your case, rather than apply one function (e.g. mean), you can apply your own function that will do multiple tasks (depending upon your needs): for instance, function(x) { c(mean(x), length(x)) }. Then run do.call("rbind" (for instance) on the output.

    Also, you might give some consideration to using a reporting package such as Sweave (with xtable) or Jeffrey Horner’s brew package. There is a great post on the learnr blog about creating repetitive reports that shows how to use it.

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

Sidebar

Ask A Question

Stats

  • Questions 182k
  • Answers 182k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer git filter-branch is the way to go. Make a copy… May 12, 2026 at 4:23 pm
  • Editorial Team
    Editorial Team added an answer In the digital world, nothing is really continuous. Just get… May 12, 2026 at 4:23 pm
  • Editorial Team
    Editorial Team added an answer Instead of CurrentDb you could use with CodeDb wich points… May 12, 2026 at 4:23 pm

Related Questions

I'm working on a problem in C# 2.0/.NET 2.0 where I have a Sortedlist
I seem to get into an annual debate about the use of the $Log$
I'm toying with the idea of implementing a generic Producer/Consumer pair + processing queue
Good morning, all. This is my first question on stackoverflow, so hopefully this isn't
I would like to be able to hide another application's window from the taskbar,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.