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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:47:28+00:00 2026-05-16T16:47:28+00:00

From the (simplified) data below that represents a user choosing between three options, I

  • 0

From the (simplified) data below that represents a user choosing between three options, I want to create a set of boxplots of the percentage of times a user chose a value, based upon the factor of value. So I want three boxplots, the percentage users chose 0, 1 and 2.

I’m sure I’m missing something obvious, as I often do with R. I can get the percentages using by(dat, dat$user, function(user) {table(user$value)/length(user$value)*100}), but don’t know how to turn that into boxplots.

Hope that makes sense.

user|value
1|2
1|1
1|0
1|2
1|0
2|2
2|2
2|2
2|0
2|2
3|2
3|0
3|1
3|0
3|1
4|2
4|0
4|1
4|0
4|1
5|2
5|0
5|1
5|0
5|1
6|2
6|0
6|0
6|1
6|2
7|0
7|0
7|1
7|0
7|1
8|2
8|2
8|1
8|1
8|2
9|1
9|0
9|0
9|0
9|0
10|1
10|2
10|0
10|2
10|1
  • 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-16T16:47:29+00:00Added an answer on May 16, 2026 at 4:47 pm

    I would approach creating the summary using the plyr package. First, you should convert value to a factor, so that when some user never picked some value, that value will have 0%.

    dat$value <- factor(dat$value)
    

    Now, you write your summary function that takes a data frame (technically this step can be smushed into the next step, but this way it’s more legible).

    p.by.user <- function(df){
      data.frame(prop.table(table(df$value)))
    }
    

    Then, apply this function to every subset of dat defined by user.

    dat.summary <- ddply(dat, .(user), p.by.user)
    

    A base graphics boxplot of this data would be done like this.

    with(dat.summary, boxplot(Freq ~ Var1, ylim = c(0,1)))
    

    If you don’t mind my two cents, I don’t know that boxplots are the right way to go with this kind of data. This isn’t very dense data (if your sample is realistic), and boxplots don’t capture the dependency between decisions. That is, if some user chose 1 super frequently, then they must have chosen the other much less frequently.

    You could try a filled bar chart for each user, and it wouldn’t require any pre-summarization if you use ggplot2. The code would look like this

    ggplot(dat, aes(factor(user), fill = value)) + geom_bar()
        # or, to force the range to be between 0 and 1
        # + geom_bar(position = "fill")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a dynamic select input (dropdown menu) from JSON. I have
Given the example queries below (Simplified examples only) DECLARE @DT int; SET @DT=20110717; --
The Problem: I want to return all of the rows from the Primary Data
I have a recursive method which is simplified below: private List<string> data; public string
I've pasted a very simplified version of my SQL query below. The problem that
I have this code (which is way simplified from the real code): public interface
I'm using Google Translation API to translate text from Chinese Simplified to English in
When using this code (simplified for asking): var rows1 = (from t1 in db.TABLE1
I have a fairly simple Linq query (simplified code): dim x = From Product
I am using the jQuery plugin from the jQuery build of TinyMCE. This simplified

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.