1 + 1[1] 2
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see https://quarto.org.
When you click the Render button a document will be generated that includes both content and the output of embedded code. You can embed code like this:
1 + 1[1] 2
You can add options to executable code like this
[1] 4
The echo: false option disables the printing of code (only output is displayed).
Figure 1 further explores the impact of temperature on ozone level.
library(tidyverse)
library(ggvis)
airquality %>%
select(Ozone, Temp) %>%
filter(Ozone != "NA") %>%
ggvis(~Ozone, ~Temp) %>%
layer_points() %>%
layer_smooths(stroke := "blue") %>%
layer_model_predictions(model = "lm", formula = Temp ~ Ozone, stroke := "red")rm(list = ls())
library(Statamarkdown)No Stata executable found.
No Stata executable found.
No Stata executable found.
No Stata executable found.
The 'stata' engine is ready to use.
stataexe <- "D:/StataMP17/StataMP-64.exe"
knitr::opts_chunk$set(engine.path = list(stata = stataexe))
sysuse auto.dta
describe
regress price mpg(1978 automobile data)
Contains data from D:\StataMP17\ado\base/a/auto.dta
Observations: 74 1978 automobile data
Variables: 12 13 Apr 2020 17:45
(_dta has notes)
-------------------------------------------------------------------------------
Variable Storage Display Value
name type format label Variable label
-------------------------------------------------------------------------------
make str18 %-18s Make and model
price int %8.0gc Price
mpg int %8.0g Mileage (mpg)
rep78 int %8.0g Repair record 1978
headroom float %6.1f Headroom (in.)
trunk int %8.0g Trunk space (cu. ft.)
weight int %8.0gc Weight (lbs.)
length int %8.0g Length (in.)
turn int %8.0g Turn circle (ft.)
displacement int %8.0g Displacement (cu. in.)
gear_ratio float %6.2f Gear ratio
foreign byte %8.0g origin Car origin
-------------------------------------------------------------------------------
Sorted by: foreign
Source | SS df MS Number of obs = 74
-------------+---------------------------------- F(1, 72) = 20.26
Model | 139449474 1 139449474 Prob > F = 0.0000
Residual | 495615923 72 6883554.48 R-squared = 0.2196
-------------+---------------------------------- Adj R-squared = 0.2087
Total | 635065396 73 8699525.97 Root MSE = 2623.7
------------------------------------------------------------------------------
price | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
mpg | -238.8943 53.07669 -4.50 0.000 -344.7008 -133.0879
_cons | 11253.06 1170.813 9.61 0.000 8919.088 13587.03
------------------------------------------------------------------------------
library(knitr)
pythonpath <- "D:/Python/Python39/python.exe"
opts_chunk$set(engine="python", engine.path = pythonpath, comment = "")
print("Hello, world.")Hello, world.
import math
math.sqrt(8)2.8284271247461903
import sympy
sympy.sqrt(8)2*sqrt(2)
from sympy import symbols
x, y, t = symbols("x y t")
expr = x + 2*y
x*exprx*(x + 2*y)
from sympy import expand, factor
expanded_expr = expand(x*expr)
expanded_exprx**2 + 2*x*y
factor(expanded_expr)x*(x + 2*y)
from sympy import *
a = Integral(cos(x)*exp(x), x)
aIntegral(exp(x)*cos(x), x)
Eq(a, a.doit())Eq(Integral(exp(x)*cos(x), x), exp(x)*sin(x)/2 + exp(x)*cos(x)/2)
init_printing(use_unicode=True)
diff(sin(x)*exp(x), x) x x
ℯ ⋅sin(x) + ℯ ⋅cos(x)
integrate(exp(x)*sin(x) + exp(x)*cos(x), x) x
ℯ ⋅sin(x)
Integral(cos(x)**2, (x, 0, pi))π
⌠
⎮ 2
⎮ cos (x) dx
⌡
0
integrate(sin(x**2), (x, -oo, oo))√2⋅√π
─────
2
limit(sin(x)/x, x, 0)1
solve(x**2 - 2, x)[-√2, √2]
y = Function('y')
dsolve(Eq(y(t).diff(t, t) - y(t), exp(t)), y(t)) # y′′ - y = e^t -t ⎛ t⎞ t
y(t) = C₂⋅ℯ + ⎜C₁ + ─⎟⋅ℯ
⎝ 2⎠
latex(Integral(cos(x)**2, (x, 0, pi)))\int\limits_{0}^{\pi} \cos^{2}{\left(x \right)}\, dx
exitUse exit() or Ctrl-Z plus Return to exit
\[ \int\limits_{0}^{\pi} \cos^{2}{\left(x \right)}\ dx \]