This version: 2024-10-24
DT
は、JavaScriptライブラリDataTablesへのRインターフェースを提供する。パッケージのインストールを行う。
install.packages("DT")
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(wooldridge)
data(wage1)
# マークダウンに表示するための準備
library(rgl)
library(knitr)
knit_hooks$set(webgl = hook_webgl)
writeLines(c('<script type="text/javascript">',
readLines(system.file('WebGL', 'CanvasMatrix.js', package = 'rgl')), '</script>'))
## Warning in file(con, "r"): file("") only supports open = "w+" and open = "w+b":
## using the former
rgl::plot3d(x = wage1$educ, y = wage1$tenure, z = wage1$wage,
xlab = "Education", ylab = "Tenure", zlab = "Wage")
fit <- lm(wage ~ educ + tenure, data = wage1)
coefs <- coef(fit)
planes3d(coefs[2], coefs[3], -1, coefs[1], col="blue", alpha=0.5)
rgl::rgl.snapshot("3Dplot.png")
rgl::rgl.postscript("3Dplot.pdf", fmt = "pdf")