intial
This commit is contained in:
commit
e79fd84b94
|
@ -0,0 +1,6 @@
|
||||||
|
linters: lintr::linters_with_defaults(
|
||||||
|
line_length_linter(120),
|
||||||
|
commented_code_linter = NULL,
|
||||||
|
trailing_whitespace_linter = NULL
|
||||||
|
)
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
# install.packages("bayesrules")
|
||||||
|
|
||||||
|
library(bayesrules)
|
||||||
|
library(dplyr)
|
||||||
|
|
||||||
|
data(fake_news)
|
||||||
|
# make it a tibble for the sake printing
|
||||||
|
fake_news <- tibble::as_tibble(fake_news)
|
||||||
|
|
||||||
|
fake_news |> glimpse()
|
||||||
|
|
||||||
|
# proportion of each type of article
|
||||||
|
fake_news |>
|
||||||
|
group_by(type) |>
|
||||||
|
summarise(
|
||||||
|
n = n(),
|
||||||
|
prop = n / nrow(fake_news) # <- is there a NSE way
|
||||||
|
# of getting total rows of
|
||||||
|
# original DF?
|
||||||
|
)
|
||||||
|
|
||||||
|
# we can also do this with the tally function
|
||||||
|
fake_news|>
|
||||||
|
group_by(type) |>
|
||||||
|
tally() |>
|
||||||
|
mutate(prop = n / sum(n))
|
||||||
|
|
Loading…
Reference in New Issue