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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:53:29+00:00 2026-06-07T18:53:29+00:00

I need create a box plot from a data.frame with three numeric columns ,

  • 0

I need create a box plot from a data.frame with three numeric columns, and use the argument split to separate the boxes by paint. I have a large data.frame, but what I need is in the example below:

paint<-c("blue", "black", "red", "blue", "black", "red", "blue", "black", "red")
car1<-c(100, 138, 123, 143, 112, 144, 343, 112, 334)
car2<-c(111, 238, 323, 541, 328, 363, 411, 238, 313)
car3<-c(432, 123, 322, 342, 323, 522, 334, 311, 452)
data<-data.frame(paint, car1, car2, car3)

>data
      paint  car1 car2 car3
   1  blue   100  111  432
   2  black  138  238  123
   3  red    123  323  322
   4  blue   143  541  342
   5  black  112  328  323
   6  red    144  363  522
   7  blue   343  411  334
   8  black  112  238  311
   9  red    334  313  452

When I used only one column the following function works:

boxplot(split(data[,2], data[,1]))

But when I try to create a boxplot using three columns the function does not work:

boxplot(split(data[,2:4], data[,1]))

Thanks for the help and sorry for poor English.

  • 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-07T18:53:31+00:00Added an answer on June 7, 2026 at 6:53 pm

    Try putting your data into long form first and then plotting:

    temp = reshape(data, direction="long", varying=2:4, sep="")
    boxplot(split(temp[,3], temp[,1]))
    # boxplot(car ~ paint, data=temp) ### Formula notation, easier to read
    

    enter image description here

    Or, use lattice:

    library(lattice)
    bwplot(car1 + car2 + car3 ~ paint, data=data)
    

    I’m not sure why that notation doesn’t work with base R’s boxplot though.

    enter image description here

    Update

    In case I misinterpreted your original question (after reading Roman’s comment), here’s an option (again using lattice) that puts boxplots for car1, car2, and car3 separately but side-by-side. This uses the long-form data temp created in the first example:

    bwplot(car ~ paint | paste0("Car ", time), data = temp)
    

    enter image description here

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

Sidebar

Related Questions

I need to create alert dialog with 3 check boxes....And when top check box
I need to create a activity which should look like as a dialog box
I have a need to create a small pop up information box when a
I need to create a drop down menu in struts2 from List. How can
I need to create a box-shadow on some block element, but only (for example)
i just need to create an edit box with keyboard below..Below keyboard,,there should be
I have a linux box with a bank of modems and need to create
I need to create a simple input box on my website in C#. It
i need to create a block View with a search box attach to the
I need to create a one pixel shadow on three sides of an element

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.