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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:17:29+00:00 2026-05-28T00:17:29+00:00

Thanks in advance for your response. I am trying to create a stacked bar

  • 0

Thanks in advance for your response.
I am trying to create a stacked bar plot from a csv file, and I have run into the following hiccup:
First I put the csv into a variable:

test <- read.csv(file=\"test4.csv\",sep=\",\",head=TRUE")

Then I try to create a bar plot using the following

barplot(test)

and I get the following error,

Error in barplot.default(test) : 'height' must be a vector or a matrix

so I try

barplot(t(test))

and it works but as expected the axis are switched, so I try

barplot(t(t(test)))

and it works, but I feel there must be a better solution than transposing the transposed.

  • 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-28T00:17:29+00:00Added an answer on May 28, 2026 at 12:17 am

    The issue is that read.csv outputs a data frame and barplot expects either a vector or a matrix. The barplot function works when you transpose because t() coerces data frames to matrices.

    If you either start with

    test <- as.matrix(read.csv(file="test4.csv",sep=",",head=TRUE))
    

    or later on do

    barplot(as.matrix(test))
    

    then you should be fine.

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

Sidebar

Related Questions

Thanks in advance for your help. I have a need within an application to
Thanks in advance for your assistance. I have the following exported part: [Export (typeof(INewComponent))]
Thanks in advance for your help. I'm new to JSON and I've been trying
Thanks in advance for your input. I have a question regarding the following AppleScript.
Thanks in advance for your help experts. I want to be able to copy
Hi thanks in advance for your help. I'm just getting started learning Python and
First off, thanks in advance for your help. This issue is driving me nuts.
I have the following problem, thanks in advance for any help regarding this issue.
This one has me pretty rattled so I thank you in advance for your
Thanks in advance to anyone who can think of a more efficient or a

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.