Search code examples
rhistogram

Histogram x-axis showing wrong range


I'm making a histogram from a column in a csv with values ranging from 100,000 to 10,000,000 and yet when I the data into r and make a histogram from that column the x-axis is all messed up, showing extremely large range when the largest value is 10,000,000.

This is where the dataset is from: https://www.kaggle.com/kmldas/hr-case-study

This is the code I use to make the histogram:

hist(study_sample$Annual.Salary)

SS


Solution

  • You can disable scientific notation in R with:

    options(scipen = 999)
    hist(HR_Case_Study$`Annual Salary`)
    

    enter image description here

    Head of data:

    structure(list(Name = c("Aarti Panchal", "Aastha Behl", "Abhinaw Sinha", 
    "Abhishek Dabb", "Abhishek Kumar Preetam", "Addi Studdeard"), 
        Gender = c("Female", "Female", "Male", "Male", "Male", "Female"
        ), Department = c("CEO", "Sales", "Engineering", "Legal", 
        "Support", "Support"), `Annual Salary` = c(10000000, 880500, 
        682200, 563700, 1070900, 1084500), Location = c("Mumbai", 
        "Bengaluru", "Bengaluru", "New Delhi", "New Delhi", "Mumbai"
        ), Rating = c("Very Good", "Very Good", "Good", "Very Good", 
        "Poor", "Poor"), `Distance to Office` = c(25, 7, 15, 5, 10, 
        6), Age = c(31, 40, 28, 39, 26, 38), `Tenure in Company` = c(10.4, 
        18.2, 6.6, 13.3, 4.8, 6.7)), row.names = c(NA, -6L), class = c("tbl_df", 
    "tbl", "data.frame"))