0

I am trying to create a bar graph of household income, but not all the x-values show up. I would like each bar to be labeled with the price.

Here's the categories of home market value I got from my work's API: "1k-25k", "25k-50k", "50k-75k", "75k-100k", "100k-150k", "150k-200k", "200k-250k", "250k-300k", "300k-350k", "350k-500k", "500k-1mm", "1mm+" I took out the names of the email for privacy and used the first 25 rows only.

#Load Data
Store2 <- read.csv("/Users/Documents/Work/Client2.csv", 
                   na.strings = "", head = TRUE)
#First 25 rows
head(Store2, n = 25)

   PresenceofChildren HomeOwnerStatus HomeMarketValue          Occupation
1                <NA>            <NA>            <NA>                <NA>
2                <NA>            <NA>            <NA>                <NA>
3                <NA>            <NA>            <NA>                <NA>
4                <NA>            <NA>            <NA>                <NA>
5                 Yes             Own       150k-200k                <NA>
6                  No             Own       300k-350k                <NA>
7                 Yes             Own       250k-300k                <NA>
8                  No             Own       150k-200k        Professional
9                  No             Own       150k-200k                <NA>
10               <NA>            <NA>            <NA>                <NA>
11               <NA>            <NA>            <NA>                <NA>
12                Yes             Own       300k-350k                <NA>
13               <NA>            <NA>            <NA>                <NA>
14               <NA>            <NA>            <NA>                <NA>
15                 No             Own       150k-200k                <NA>
16                 No            <NA>       150k-200k   Middle Management
17                 No             Own       350k-500k                <NA>
18                 No            Rent       100k-150k                <NA>
19                 No             Own        500k-1mm White Collar Worker
20               <NA>            <NA>            <NA>                <NA>
21               <NA>            <NA>       200k-250k                <NA>
22                 No             Own       200k-250k                <NA>
23                Yes             Own        500k-1mm   Middle Management
24                 No             Own       100k-150k                <NA>
25                 No            <NA>       350k-500k White Collar Worker

Here's the graph:

#Set the order
res1 <- ordered(Store2$HomeMarketValue, levels = c("1k-25k", "25k-50k", "50k-75k",
                                                    "75k-100k", "100k-150k",
                                                    "150k-200k", "200k-250k", 
                                                   "250k-300k", "300k-350k", 
                                                    "350k-500k", "500k-1mm", "1mm+"))
#Create plot
plot(res1, main = "Distribution of Home Market Value", 
     xlab = "home market value", ylab = "Density")

Home Market Value

Scott Davis
  • 983
  • 6
  • 22
  • 43
  • 1
    The issue here is that there is simply not enough space to fit all the labels. You might have some luck by rotating your labels in the x axis, as in this answer on SO: http://stackoverflow.com/questions/10286473/rotating-x-axis-labels-in-r-for-barplot – Jealie Aug 19 '14 at 23:06
  • increase the width of your plot. – EDi Aug 19 '14 at 23:06

0 Answers0