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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:41:03+00:00 2026-06-01T15:41:03+00:00

I have to call the table() function on 10 variables in R. Is there

  • 0

I have to call the table() function on 10 variables in R. Is there any way of doing it in one shot, without calling them individually like table(v1), table(v2)… table(v10)?

  • 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-01T15:41:04+00:00Added an answer on June 1, 2026 at 3:41 pm

    If your variables are arranged as columns in a data.frame, you could use lapply:

    df <- data.frame(aa = rpois(10, 4), bb = rpois(10, 3), c = rpois(10, 7))
    
    tabList <- lapply(df, table)
    

    Then you get a list with the various tables:

    > tabList
    $aa
    
    1 3 4 5 6 7 
    2 3 2 1 1 1 
    
    $bb
    
    1 2 3 4 5 
    1 2 4 1 2 
    
    $c
    
     3  4  5  6  7  9 11 12 
     1  1  1  3  1  1  1  1 
    

    EDIT:

    For variables across multiple data.frames, you might try putting them into a list and then using lapply again:

    df2 <- df[sample(rownames(df), 15, replace = TRUE), ]
    
    df3 <- df[sample(rownames(df), 20, replace = TRUE), ]
    
    dfList <- list(df = df, df2 = df2, df3 = df3)
    
    lapply(dfList, function(x) lapply(x, FUN = table))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple table (lets call it Table1) that has a NVARCHAR field
I have a table, let's call is [MYTABLE] , with an FOR INSERT, UPDATE
I have problems filling a temporary table with the resultset from a procedure call
I have a database with two tables - let's call them Foo and Bar.
I want to call COUNT_BIG function over my table. This table returns a lot
I have a function that is called on document.ready that loops through a table
I have 2 table-valued function that are very similar, the only difference is that
There seems to be a problem with the code I have for calling php
I have a question about saving a dataframe with unequal lengths. Is there way
tl;dr: Is there a way to prevent alteration to ( essentially lock ) variables

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.