log | R Documentation |
Compute the natural logarithm of a value, or the natural log of each element of a vector.
log(x, base = exp(1))
base::log2()
, base::log10()
, base::exp()
, mutate()
# Natural log of e: log(exp(1)) #> [1] 1 ----------------------------------- # Compute the natural log of every # element of a vector: c(1, 2, 3) %>% log() #> [1] 0.0000000 0.6931472 1.0986123 ----------------------------------- # Use log() with mutate(): library(gapminder) gapminder %>% select(country, year, gdpPercap) %>% mutate(gdp_log = log(gdpPercap)) #> # A tibble: 1,704 x 4 #> country year gdpPercap gdp_log <fct> <int> <dbl> <dbl> #> 1 Afghanistan 1952 779. 6.66 #> 2 Afghanistan 1957 821. 6.71 #> 3 Afghanistan 1962 853. 6.75
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.