0

I am new to using R studio and I would like to create a histogram on lake lengths. I currently have my data in meters with my lowest number being 150 and my highest 600000.

This is my current code:

library(dplyr)
library(ggplot2)
#setwd()
data<-read.csv('SS_histo.csv')
llength<-data$Length
hist(lllength,main="Distribution of Lake Lengths",
     xlab="Lake length Range", col="blue", freq=TRUE, breaks=3)

I have three problems which I would appreciate some help with:

  1. My x-axis is presented in 0e+00, 1e+00, 2e+00, etc. Please may you advise on how I change this to a number?
  2. I would like to create an overflow bin, where all values greater than 1500m are found.
  3. I am aware that the Sturges rule may help with determining the number of bins I should use. Please may I ask if anyone knows of any code which I can use/adapt for this rule?

Current Histogram

Apologies that the code is very basic as I am new to R. Any help would be greatly appreciated!

Quinten
  • 35,235
  • 5
  • 20
  • 53
Leeza
  • 3
  • 2
  • 1
    Welcome to SO, Leeza! `hist` is base graphics, not `ggplot2`; if you want the latter, use `ggplot(data, aes(Length)) + geom_histogram()`. For help on generating histograms in R, it might be useful for you to look at a [gallery](https://r-graph-gallery.com/histogram.html) of them with code to regenerate. It'll help you learn how to control the aesthetics. – r2evans Sep 28 '22 at 08:39
  • For base graphics axis labeling, see https://stackoverflow.com/q/5963047/3358272 (and `?axis`). – r2evans Sep 28 '22 at 08:42

0 Answers0