Description Usage Arguments Details Value Author(s) See Also Examples

Creates a histogram from values in a frequency table. Primarily used with already summarized length frequency data.

1 2 3 4 5 6 7 8 9 10 | ```
histFromSum(x, ...)
## Default S3 method:
histFromSum(x, y, ...)
## S3 method for class 'table'
histFromSum(x, ...)
## S3 method for class 'formula'
histFromSum(x, data = NULL, ...)
``` |

`x` |
A numeric vector of bin/category values, a formula of the form |

`...` |
Additional arguments for |

`y` |
A numeric vector of count/frequency values. |

`data` |
A data.frame that contains the |

Creates a histogram fro values in a frequency table. The frequency table may be constructed from `xtabs`

, `table`

, or be in the form of a matrix or a data.frame (as if read in from an external data file).

None, but a graphic is created.

Derek H. Ogle, derek@derekogle.com

See `hist`

and `hist.formula`

for related functionality.

1 2 3 4 5 6 7 8 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 | ```
## Make some dummy data with a length category variable
set.seed(634434789)
df <- data.frame(tl=round(rnorm(100,100,20)))
df$lcat10 <- lencat(df$tl,w=10)
## Summarize as tables
( tbl1 <- xtabs(~lcat10,data=df) )
( tbl2 <- table(df$lcat10) )
## Turn the tables into a data.frame for testing (convert
## the categories variables to numeric with fact2num())
df2 <- data.frame(tbl1)
df2$lcat10 <- fact2num(df2$lcat10)
## Turn the table into a matrix for testing
( mat1 <- cbind(lcat10=as.numeric(rownames(tbl1)),freq=tbl1) )
## Histogram of the raw data ... set breaks and x-axis label
brks <- seq(20,160,10)
xlbl <- "Total Length (mm)"
hist(~tl,data=df,breaks=brks,xlab=xlbl)
## Use this function with various inputs ... changed colors
## on each plot so that it was obvious that a new plot was made.
# table from xtabs()
histFromSum(tbl1,breaks=brks,xlab=xlbl,col="gray75")
# table from table()
histFromSum(tbl2,breaks=brks,xlab=xlbl,col="gray70")
# vectors from data.frame
histFromSum(df2$lcat10,df2$Freq,breaks=brks,xlab=xlbl,col="gray65")
# vectors from matrix
histFromSum(mat1[,"lcat10"],mat1[,"freq"],breaks=brks,xlab=xlbl,col="gray60")
# formula from a data.frame
histFromSum(Freq~lcat10,data=df2,breaks=brks,xlab=xlbl,col="gray55")
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.