This function creates a frequency table, you only need to supply a data.frame and the variable to make the table.
Arguments
- obj
Object used to create the table. Data frame, list or environment (or object coercible by as.data.frame to a data frame)
- var
Variable that you want the table (not written in string format)
- sort_by
Variable you want to sort the
tibble
- desc
if you want decreasing order put
FALSE
Examples
iris %>%
mypdf1::pdf1_freq_tbl(Species) %>%
mypdf1::pdf1_tbl("You can combine this function too!")
#> <table class=" lightable-classic" style='font-family: "Arial Narrow", "Source Sans Pro", sans-serif; margin-left: auto; margin-right: auto;'>
#> <caption>You can combine this function too!</caption>
#> <thead>
#> <tr>
#> <th style="text-align:center;"> Species </th>
#> <th style="text-align:center;"> absolute_frequency </th>
#> <th style="text-align:center;"> relative_frequency </th>
#> </tr>
#> </thead>
#> <tbody>
#> <tr>
#> <td style="text-align:center;"> setosa </td>
#> <td style="text-align:center;"> 50 </td>
#> <td style="text-align:center;"> 0.3333 </td>
#> </tr>
#> <tr>
#> <td style="text-align:center;"> versicolor </td>
#> <td style="text-align:center;"> 50 </td>
#> <td style="text-align:center;"> 0.3333 </td>
#> </tr>
#> <tr>
#> <td style="text-align:center;"> virginica </td>
#> <td style="text-align:center;"> 50 </td>
#> <td style="text-align:center;"> 0.3333 </td>
#> </tr>
#> <tr>
#> <td style="text-align:center;"> Total </td>
#> <td style="text-align:center;"> 150 </td>
#> <td style="text-align:center;"> 0.9999 </td>
#> </tr>
#> </tbody>
#> </table>