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:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.
norm <- rnorm(100, mean = 0, sd = 1)
norm
## [1] -0.96287391 -1.46682836 0.31019158 -0.60710226 -0.15531983 -0.86295996
## [7] 1.72184802 1.48605529 0.69661508 -2.00051747 0.27556489 -0.49446713
## [13] 0.32370237 0.22412380 -1.43654195 0.98090834 0.14570381 -1.19871548
## [19] 2.48496844 -1.57199098 0.36252316 1.04768521 -1.27317919 -0.96162645
## [25] 0.62205929 -1.95316515 -0.22282145 0.74800410 -1.14631644 0.08229539
## [31] -0.92987537 -0.96016775 1.28232710 0.58847939 -0.97642455 1.52019604
## [37] -0.18480206 -0.38731745 -0.30019433 -0.03827892 0.86360974 1.41269130
## [43] -1.00100794 0.69987005 1.26248691 -1.45377859 -1.36467213 -1.65766421
## [49] -1.29602886 -0.45714633 -0.02410020 -0.64479523 -0.19566218 0.03689530
## [55] -0.31125690 -0.51926517 -0.29765829 0.86346691 0.09478064 0.07182334
## [61] -1.87186289 0.74845902 2.31415453 -1.11940990 0.44942563 -1.36717813
## [67] -0.41155253 1.88625444 -0.52164914 -1.81965346 -0.23844108 1.27449045
## [73] 2.04831601 0.64064284 0.02699442 0.32359303 1.83563039 -0.37636465
## [79] 0.54561944 0.42644870 1.67798530 -0.33020882 -1.69399076 0.46288691
## [85] -1.69950419 1.95462767 0.34480193 0.75001932 -0.68577564 0.41634557
## [91] 0.49739149 0.07505601 0.82926605 -0.29250859 0.46148871 -0.26353646
## [97] -0.55911416 -0.54292906 -0.34257457 -0.25860843
A <- c("a", "a", "b", "b")
B <- c(5, 10, 15, 20)
dataframe <- data.frame(A, B)
print(dataframe)
## A B
## 1 a 5
## 2 a 10
## 3 b 15
## 4 b 20
## A B
## 1 a 5
## 2 a 10
## 3 b 15
## 4 b 20
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 4.0.2 ✔ tibble 3.2.1
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.0.4
## ── 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
A <- c("a", "a", "b", "b")
B <- c(5, 10, 15, 20)
dataframe <- data.frame(A, B)
print(dataframe)
## A B
## 1 a 5
## 2 a 10
## 3 b 15
## 4 b 20
boxplot(B~A,data=dataframe)
library(knitr)
kable(dataframe, digits = 2)
| A | B |
|---|---|
| a | 5 |
| a | 10 |
| b | 15 |
| b | 20 |
library(pander)
plant <- c("a", "b", "c")
temperature <- c(20, 20, 20)
growth <- c(0.65, 0.95, 0.15)
dataframe <- data.frame(plant, temperature, growth)
emphasize.italics.cols(3) # Make the 3rd column italics
pander(dataframe) # Create the table
| plant | temperature | growth |
|---|---|---|
| a | 20 | 0.65 |
| b | 20 | 0.95 |
| c | 20 | 0.15 |
query6 <- "
SELECT productScale, COUNT(*) AS jumlah_item
FROM products
GROUP BY productScale
"
query8 <- "
SELECT
c.country,
od.quantityOrdered * od.priceEach AS value
FROM customers c
JOIN orders o
ON c.customerNumber = o.customerNumber
JOIN orderdetails od
ON o.orderNumber = od.orderNumber
WHERE c.country IN ('Denmark','Finland','Norway','Sweden')
"