user432797
user432797

Reputation: 603

Remove kind of data from a column when plotting using barplot in r (not ggplot)

I'm trying to get the boxplot of chess_games$cream_rating~chess_games$victory_status

Data:

A data.frame: 6 × 8
    rated   turns   victory_status  winner  increment_code  cream_rating    charcoal_rating   opening_name
    <lgl>   <int>   <fct>          <fct>    <fct>            <int>          <int>              <fct>
1   FALSE   13     outoftime       cream    15+2             1500           1191              Slav Defense: Exchange Variation
2   TRUE    16      resign        charcoal  5+10             1322           1261              Nimzowitsch Defense: Kennedy Variation
3   TRUE    61      mate           cream    5+10             1496           1500              King's Pawn Game: Leonardis Variation
4   TRUE    61      mate           cream    20+0            1439            1454              Queen's Pawn Game: Zukertort Variation
5   TRUE    95      mate           cream    30+3            1523            1469              Philidor Defense
6   FALSE   5       draw            draw    10+0            1250            1002              Sicilian Defense: Mongoose Variation

When I try this code:

chess_games_rated<-chess_games$cream_rating 
chess_games_victory<-chess_games$victory_status
boxplot(chess_games_rated~chess_games_victory)

I get:

enter image description here

Why I'm getting draws when I suppose not, how to remove draws from the graph?

Upvotes: 1

Views: 118

Answers (1)

jay.sf
jay.sf

Reputation: 72974

Because you didn't filter it out?

boxplot(cream_rating ~ victory_status, chess_games[!chess_games$winner %in% "draw", ])

enter image description here

Data:

chess_games <- structure(list(rated = c(FALSE, TRUE, TRUE, TRUE, TRUE, FALSE
), turns = c(13L, 16L, 61L, 61L, 95L, 5L), victory_status = c("outoftime", 
"resign", "mate", "mate", "mate", "draw"), winner = c("cream", 
"charcoal", "cream", "cream", "cream", "draw"), increment_code = c("15+2", 
"5+10", "5+10", "20+0", "30+3", "10+0"), cream_rating = c(1500L, 
1322L, 1496L, 1439L, 1523L, 1250L), charcoal_rating = c(1191L, 
1261L, 1500L, 1454L, 1469L, 1002L), opening_name = c("Slav", 
"Nimzowitsch", "King", "Queen", "Philidor", "Sicilian")), class = "data.frame", row.names = c("1", 
"2", "3", "4", "5", "6"))

Upvotes: 1

Related Questions