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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:12:27+00:00 2026-06-18T12:12:27+00:00

My data is in the following format: input<-data.frame( region=c(A,T,R,R,T), geomorph=c(F,F,S,S,P), depth=c(2.6,3.5,5.8,6.7,8.9)) > input region

  • 0

My data is in the following format:

input<-data.frame(
    region=c("A","T","R","R","T"),
    geomorph=c("F","F","S","S","P"),
    depth=c(2.6,3.5,5.8,6.7,8.9))

> input
  region geomorph depth
1      A        F   2.6
2      T        F   3.5
3      R        S   5.8
4      R        S   6.7
5      T        P   8.9

I would like to create a summary table such that for the given depth categories (i.e 0-3,3-6,6-10) the number of entries for region (i.e A,R,T) and geomorphology (i.e. F,S,P) are counted and presented as follows:

output<-data.frame(
    depth.category=c("0-3","3-6","6-10"),
    total=c(1,2,2),
    A=c(1,0,0),
    R=c(0,1,1),
    T=c(0,1,1),
    F=c(1,1,0),
    S=c(0,1,1),
    P=c(0,0,1))

> output
  depth.category total A R T F S P
1            0-3     1 1 0 0 1 0 0
2            3-6     2 0 1 1 1 1 0
3           6-10     2 0 1 1 0 1 1

Any suggestions how to go about 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-18T12:12:28+00:00Added an answer on June 18, 2026 at 12:12 pm

    First, just create your intervals using cut, and then use table and cbind the results:

    intervals <- cut(input$depth, breaks=c(0, 3, 6, 10))
    
    cbind(table(intervals),
          table(intervals, input$region),
          table(intervals, input$geomorph))
    #          A R T F P S
    # (0,3]  1 1 0 0 1 0 0
    # (3,6]  2 0 1 1 1 0 1
    # (6,10] 2 0 1 1 0 1 1
    

    The output of the above is a matrix. Use the following if you want a data.frame:

    temp <- cbind(table(intervals),
          table(intervals, input$region),
          table(intervals, input$geomorph))
    
    temp <- data.frame(depth.category = rownames(temp),
                       as.data.frame(temp, row.names = 1:nrow(temp)))
    names(temp)[2] <- "Total"
    temp
    #   depth.category Total A R T F P S
    # 1          (0,3]     1 1 0 0 1 0 0
    # 2          (3,6]     2 0 1 1 1 0 1
    # 3         (6,10]     2 0 1 1 0 1 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string of data with the following format: xpos-ypos-zoom (i.e. 8743-12083-15) that
Consider the following code snippet that takes user input (a date) and format it
I have an input string which data is coming in the following format: http://testing/site/name/lists/tasks
MySQL gives an error when I try to input data into the following table
I have a text file containing the data in following format 12345 Abdt3 hy45d
I have data in the following format: 4:How do you do? 10:Happy birthday 1:Purple
I have a data with the following format: foo<tab>1.00<space>1.33<space>2.00<tab>3 Now I tried to sort
If I am given some data in the following format: data = [ ['Airbus',
I have a XML file with the following data format: <net NetName=abc attr1=123 attr2=234
I have a txt file which contains data in the following format: X1 Y1

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.