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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:21:33+00:00 2026-06-14T16:21:33+00:00

I have a dataframe(df) with 3 columns: test1 test2 res 500 23 30.75 200

  • 0

I have a dataframe(df) with 3 columns:

test1   test2    res
500    23        30.75
200    23        31.36
110    26        30.38
105    23        31.57
55     21        33.56
35     21        31.39
27     18        36.89
23     23        35.44 

I want to have one graph contians boxplots for both results. I have melted the data based on “res” and called the new one (df_melt) and I got the following:

res      variable  value
30.75     test1   500    
31.36     test1   200
30.38     test1   110
31.57     test1   105
33.56     test1    55
31.39     test1    35
36.89     test1    27
35.44     test1    23
30.75     test2    23
31.36     test2    23
30.38     test2    26
31.57     test2    23
33.56     test2    21
31.39     test2    21
36.89     test2    18
35.44     test2    23 

Now, I want to boxplot the data so, x-axis=res, and y-axis= value based on variable column. Therefore, I would expect two boxplots for each “res” value as I have two type of data in variable ( i.e.test1 and test2).

I have tried this :

boxplot(df_melt$value~df_melt$res)

I got only 8 boxplot and it is not clear for which test??? How I can add the second test to the graph so I can compare them.

The whole reason why I want to include them together so I can compare them ….

  • 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-14T16:21:34+00:00Added an answer on June 14, 2026 at 4:21 pm

    I suppose you are looking for a barplot, since you can’t generate a boxplot based on a single value.

    library(ggplot2)
    
    ggplot(df_melt, aes(x = factor(res), y = value, fill = variable)) +
      geom_bar(stat="identity", position="dodge")
    

    enter image description here


    Update: A boxplot solution based on the comment of the OP:

    An analogous graph with multiple boxplots in different colours can be generated with:

    ggplot(df_melt, aes(x = factor(res), y = value, fill = variable)) +
      geom_boxplot() +
      scale_fill_manual(values = c("white", "darkgray"))
    

    Note that this graph only makes sense if you have multiple values in values for each combination of res and variable.

    The colours of the boxplots will be white and dark grey. You can modify the colour with the scale_fill_manual function.

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

Sidebar

Related Questions

I have a dataframe with over 200 columns. The issue is as they were
I have a dataframe with columns labeled A,B & C. I want to add
I have a dataframe with a bunch of columns. I'd like to drop one
I have a dataframe with some numeric columns. Some row has a 0 value
I have a dataframe with >100 columns, and I would to find the unique
I have a dataframe with one column that I would like to split into
I have a two column dataframe in R and i want to add a
I have a dataframe with 3 columns $x -- at http://pastebin.com/SGrRUJcA $y -- at
I have a dataframe with 6 columns and many rows that includes positions for
I have a big dataframe with columns such as: ID, time, OS, IP Each

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.