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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:30:22+00:00 2026-06-17T21:30:22+00:00

Possible Duplicate: How to create grouped barplot with R Species Dbh Height 1 DF

  • 0

Possible Duplicate:
How to create grouped barplot with R

Species      Dbh   Height
1       DF 383.7143 254.3036
2       ES 403.3333 280.0000
3        F 372.0000 270.0000
4       FG 381.5000 275.0000
5       GF 351.5838 242.6522
6       HW 209.0000 198.0000
7       LP 232.8571 218.3333
8       PP 568.5000 330.0000
9       SF 136.4286 154.1000
10      WC 375.0757 234.8777
11      WL 340.0588 252.5714
12      WP 319.7273 251.3939

I want to turn the data above into a bar graph like this one. Species as bins and dbh and height as bars for each bin.

graph

I used the code:

aggregate(ufc[,4:5],ufc[3],mean,na.rm=TRUE)

to get the above data set

I can only get one variable at a time using this code:

barplot(ufc.means$Height, col=rainbow(20), 
                            names.arg=(ufc.means$Species), las=2,main="Height")
  • 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-17T21:30:24+00:00Added an answer on June 17, 2026 at 9:30 pm

    First, do not double post! If necessary edit your previous question, rather than posting a new question.

    Second, the error message that you mentioned in your earlier post is pretty self-explanatory. Here’s the error message:

    Error in barplot.default(ufc.means, col = rainbow(20), names.arg = (ufc.means$Species), : ‘height’ must be a vector or a matrix

    Read that last part carefully: 'height' must be a vector or a matrix, but you are trying to use a data.frame. So, the solution is easy: convert your data.frame to a matrix before using barplot.

    Assuming your data.frame is named “mydf”:

    mymat <- t(mydf[-1])
    colnames(mymat) <- mydf[, 1]
    barplot(mymat, beside = TRUE)
    

    Result:

    enter image description here

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

Sidebar

Related Questions

Possible Duplicate: Create provisioning profile in iphone application i developed my iphone app and
Possible Duplicate: Create event handler for OnScroll for web browser control I would like
Possible Duplicate: Create an Array of the Last 30 Days Using PHP I am
Possible Duplicate: Create an alert on any view controller after Facebook request:didFailWithError: I have
Possible Duplicate: Create Excel file in Java How to save output in excel format
Possible Duplicate: Create shortcut to console.log() In javascript we can easy assign functions to
Possible Duplicate: create multiple variables based on an int count Objective C Equivalent of
Possible Duplicate: PHP create a file without fopen I want to create a file
Possible Duplicate: How to create a static (non-refreshing) menu bar like Facebook? How Facebook
Possible Duplicate: How to create comma separated list from array in PHP? My array

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.