0

I need to make histograms with the breaks with my size classes, which are:

1:1.2, 1.2:1.4, 1.4:1.6, 1.6:1.8, 1.8:2, 2:2.2, 2.2:2.4, etc

and their respective frequencies are:

4, 20, 52, 142, 205, 307, 445

I'm using the following code:

op <- par(mfrow = c(1, 2))
hist1 <- hist(log(Huentelauquen$Age[Huentelauquen$Regime==unique(Huentelauquen$Regime)[1]]),breaks=5,main=unique(Huentelauquen$Regime)[1],xlab="log(Age)")
hist2 <- hist(log(Huentelauquen$Age[Huentelauquen$Regime==unique(Huentelauquen$Regime)[2]]),breaks=5,main=unique(Huentelauquen$Regime)[2],xlab="log(Age)")

It works like this but as I said I need the breaks with the size classes! Thanks in advance

thelatemail
  • 91,185
  • 12
  • 128
  • 188
  • I don't understand what you're asking. Can you please provide a reproducible example, and clarify exactly what you want that you aren't getting with the present code. (BTW, you can give a sequence to the `breaks` argument in `hist` - e.g. `breaks = seq(1, 2.4, .2)` – Melissa Key Apr 26 '18 at 00:37
  • See https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example on reproducible examples. – Melissa Key Apr 26 '18 at 00:47
  • Hmm sorry but I don't know how to explain better :( This code works but my supervisor says the breaks must be the size classes.. – Catarina Ferreira Apr 26 '18 at 00:48
  • If the code isn't producing the right result, it may *run* but it's not doing the job. Someone here can probably help get the right output, but you need to describe what you are trying to get. What do you mean by size classes? – Melissa Key Apr 26 '18 at 00:51
  • Are the breaks that you describe for Age or for log(Age)? You say "It works like this " Is the problem that this produces a histogram but with other break points? – G5W Apr 26 '18 at 01:23
  • Exactly, it runs but is not doing the job.. not with the break points I need.. the size classes are what I have put in the question; like, there are 20 individuals that fall between 1.2 to 1.4 classes. This is about age-frequency distributions, using 0.2-year size classes (that were obtained for each site and exploitation regime, by plotting the natural logarithm of the frequency as a function of the gastropod's age).. Later on I'll need to do catch curve analysis, that focuses on the proportions of the different age and size classes harvested by a fishery.. Hope it is more clear :/ – Catarina Ferreira Apr 26 '18 at 01:31

1 Answers1

0

Ok I finally got what I wanted, which is something like this:

freq = Loco$Age

range(freq)

breaks_me = seq(min(Loco$Age), max(Loco$Age), by=0.2)

freq.cut = cut(freq, breaks=length(breaks_me), right=FALSE, 
   include.lowest = TRUE, order_result=T)

freq.freq = table(freq.cut)

freq.freq 

freq.cut

cbind(freq.freq)

freq.freq

Now my supervisor asks how to extract from the geo_histogram the same frequency table as through this previous process that apparently is harder to understand and more time consuming... I accept help as well!

Punintended
  • 727
  • 3
  • 7