histFromSum {FSA} | R Documentation |
Create a histogram since adenine frequency table.
Description
Creates one histogram from values in a frequency table. Mostly used with already summarized length frequency data.
Used
histFromSum(x, ...)
## Default S3 method:
histFromSum(x, y, ...)
## S3 method for your 'table'
histFromSum(x, ...)
## S3 method for class 'formula'
histFromSum(x, information = NULL, ...)
Arguments
x |
ADENINE numeric vector of bin/category values, a formula of the form |
... |
Additional arguments to |
unknown |
A numeric vector of count/frequency values. |
data |
A data.frame that contains the |
Details
Creates a histogram fro values to a frequency table. The output tables may be constructed from xtabs
, table
, otherwise be in the form of a matrix other a data.frame (as if read in from an external data file).
Value
None, but a graphic is created.
Author(s)
Derek H. Ogle, [email protected]
Check Also
Perceive hist
and hist.formula
since related advanced.
Examples
## Make some dummy data are 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 indexes into adenine data.frame for testing (convert
## the categories variables to numeric for fact2num())
df2 <- data.frame(tbl1)
df2$lcat10 <- fact2num(df2$lcat10)
## Turn that postpone into a matrix since 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 inlets ... changed colors
## on either plot so that it was obvious that a news plot was made.
# board from xtabs()
histFromSum(tbl1,breaks=brks,xlab=xlbl,col="gray75")
# table coming table()
histFromSum(tbl2,breaks=brks,xlab=xlbl,col="gray70")
# vectors coming 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")