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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:01:48+00:00 2026-05-25T15:01:48+00:00

I have a table like: 12 34 45 45 56 23 45 56 77

  • 0

I have a table like:

12 34  45  45 56
23 45  56  77 77
14 94  15  45 56
15 38  25  84 65
72 35  35  4  57
18 14  45  47 56
42 34  55  55 59

I would like to get in a vector the sum of the columns like

vector[0]= 12+23+14+15+72+18+42
vector[1]= 34+45+94+38+35+14+34
vector[2]= 45+56+15+25+35+45+55
vector[3]= 45+77+45+84+4 +47+55
vector[4]= 56+77+56+65+57+56+59

I did it in C# like

for ( i = 0; i < columns; i++)
{
  vector[i] += reader.GetDouble(i);
}

in which reader gets the corresponding element

But how to do this kind of thing in R?

so I would begin with..

for(i in (1:columns))
{

}
  • 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-25T15:01:48+00:00Added an answer on May 25, 2026 at 3:01 pm
    colSums(x)
    

    or

    apply(x,2,sum)
    

    if you want to be more general and less efficient.

    edit: if you want to be even less efficient and use a for loop,

    v <- numeric(ncol(x))
    for (i in seq(ncol(x))) {
       v[i] <- sum(x[,i])
    }
    

    We could continue making this less efficient by (1) using a nested for loop and (2) failing to preallocate space for the vectors …

    See also:

    • Sum rows in data.frame or matrix (the same but for rows)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table full of cells and i would like to get on
i have a table in access and i would like to get the SQL
I have an (access) database table which contains data I would like to populate
I would like to have a table header that looks like the image shown
I have a table and I would like to be able to set up
I have a Customers table and would like to assign a Salesperson to each
I have this table structure and would like to map it using Fluent Hibernate
I have the following table and would like to replace the string text of
I have a table that stores the price of various products and would like
I would like to use Bind and Unbind Please. I have a table with

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.