The raw data for the example in Box 6.8 does not exist. Indeed enough information is given in that box to complete the calculations but most of that information in in summarized form. A reasonable approximation of the length data can be made from the results shown for the length frequency graph. The code on this page shows how I simulated those data. The age data that would be required to estimated Linfinity and K cannot be simulated from the given information.

The basic idea is to "expand" the counts of individuals in each of the 1-cm length bins to the value at the low end of the bin and then add a random "millimeter" component to simulate data recorded to millimeters.

I will begin this process entering the length bins (lower-value of the bin) and the frequency in the bins into two vectors,

> bins <- 9:52
> freqs <- c(5, 39, 43, 55, 64, 86, 106, 99, 82, 81, 56, 45, 27, 36, 43, 52, 65, 73, 63, 42, 44, 40, 37, 31, 36, 15,
+     19, 18, 13, 8, 20, 19, 9, 12, 9, 11, 13, 13, 4, 10, 6, 3, 3, 4)

I then check the length of these vectors to make sure that they at least match (I don’t trust myself!)

> length(bins)
[1] 44
> length(freqs)
[1] 44

A vector of the "floor" measurement for each fish (i.e., the lowest whole cm) can be found by repeating each value in the bins vector the number of times shown in the freqs vector. This is accomplished with,

> len.cm <- rep(bins, times = freqs)

I then create a table of these results to see if they match up with the summary information in the box,

> table(len.cm)
len.cm
  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45
  5  39  43  55  64  86 106  99  82  81  56  45  27  36  43  52  65  73  63  42  44  40  37  31  36  15  19  18  13   8  20  19   9  12   9  11  13
 46  47  48  49  50  51  52
 13   4  10   6   3   3   4

I then multiple the values by 10 to convert the cm to mm,

> len.mm <- len.cm * 10

The random number seed is then set (only so that you can reproduce the exact same results that I have produced),

> set.seed(2101)

and as many random numbers from between 0 and 1 in values of 0.1 are produced as there are in the len.mm vector and then added to the len.mm vector,

> rands <- sample(seq(0, 0.9, by = 0.1), length(len.mm), replace = TRUE)
> len.mm <- len.mm + rands

The values in len.mm now contain random data that appears to have been measured to the nearest mm but when summarized in a length-frequency graph by 1-cm bins should match the results shown in Box 6.8. This histogram can be created with,

> hbins <- seq(90, 530, by = 10)
> h <- hist(len.mm, breaks = hbins, right = FALSE)
> h$mids
 [1]  95 105 115 125 135 145 155 165 175 185 195 205 215 225 235 245 255 265 275 285 295 305 315 325 335 345 355 365 375 385 395 405 415 425 435 445
[37] 455 465 475 485 495 505 515 525
> h$counts
 [1]   5  39  43  55  64  86 106  99  82  81  56  45  27  36  43  52  65  73  63  42  44  40  37  31  36  15  19  18  13   8  20  19   9  12   9  11
[37]  13  13   4  10   6   3   3   4
Box6_8Aa-009.png

Finally, these simulated data were written out to a text file (Box6_8.txt) for use in the main vignette.

> write.table(data.frame(len = len.mm), "Box6_8.txt", quote = FALSE, row.names = FALSE, col.names = TRUE)