This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
library(mosaicCalc)
## Loading required package: mosaic
## Registered S3 method overwritten by 'mosaic':
## method from
## fortify.SpatialPolygonsDataFrame ggplot2
##
## The 'mosaic' package masks several functions from core packages in order to add
## additional features. The original behavior of these functions should not be affected by this.
##
## Attaching package: 'mosaic'
## The following objects are masked from 'package:dplyr':
##
## count, do, tally
## The following object is masked from 'package:Matrix':
##
## mean
## The following object is masked from 'package:ggplot2':
##
## stat
## The following objects are masked from 'package:stats':
##
## binom.test, cor, cor.test, cov, fivenum, IQR, median, prop.test,
## quantile, sd, t.test, var
## The following objects are masked from 'package:base':
##
## max, mean, min, prod, range, sample, sum
## Loading required package: mosaicCore
##
## Attaching package: 'mosaicCore'
## The following objects are masked from 'package:dplyr':
##
## count, tally
##
## Attaching package: 'mosaicCalc'
## The following object is masked from 'package:stats':
##
## D
m = 1
b = 2
slice_plot(m * x + b ~ x, domain(x = range(-10, 10)))
library(mosaicCalc)
m = -3
b = -2
slice_plot(m * x + b ~ x, domain(x = range(0, 10)))
library(mosaicCalc)
g <- makeFun(2*x^2 - 5*x + 2 ~ x)
slice_plot(g(x) ~ x , domain(x = range(-2, 2)))
contour_plot(
sin(2*pi*t/10)*exp(-.2*x) ~ t & x,
domain(t = range(0,20), x = range(0,10)))
interactive_plot(
sin(2*pi*t/10)*exp(-.5*x) ~ t & x,
domain(t = 0:20, x = 0:10))
You can also embed plots, for example:
Housing = read.csv("http://www.mosaic-web.org/go/datasets/Income-Housing.csv")
Housing[1:3,1:2]
## Income IncomePercentile
## 1 3914 5
## 2 10817 15
## 3 21097 30
Housing$Income
## [1] 3914 10817 21097 34548 51941 72079
gf_point(
CrimeProblem ~ Income, data=Housing ) %>%
slice_plot(
45 - Income/2500 ~ Income, color = "yellow")
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.