RStudioの1.4がリリースされましたので、早速インストールし、visual markdown editorを使いました。美しい表示で編集できます。 Markdownをあまり使っていなかったので、練習に授業のアンケートの簡単なレポートを作成しました。
# Rのスクリプトを書く場合このように書きます。
# import libraries
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.3 ✓ purrr 0.3.4
## ✓ tibble 3.0.4 ✓ dplyr 1.0.2
## ✓ tidyr 1.1.2 ✓ stringr 1.4.0
## ✓ readr 1.4.0 ✓ forcats 0.5.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(janitor)
##
## Attaching package: 'janitor'
## The following objects are masked from 'package:stats':
##
## chisq.test, fisher.test
library(likert)
## Loading required package: xtable
##
## Attaching package: 'likert'
## The following object is masked from 'package:dplyr':
##
## recode
# load the data
d0 <- read_csv("data/computerEnglish.csv")
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## .default = col_character()
## )
## ℹ Use `spec()` for the full column specifications.
d0 %>%
clean_names() %>%
select(response_1, response_2,
response_3, response_4,
response_6,
response_7, response_8) %>%
slice(-8) %>%
mutate_all(funs(str_replace(., "-", "どちらかというとそう思う"))) -> d1
## Warning: `funs()` is deprecated as of dplyr 0.8.0.
## Please use a list of either functions or lambdas:
##
## # Simple named list:
## list(mean = mean, median = median)
##
## # Auto named with `tibble::lst()`:
## tibble::lst(mean, median)
##
## # Using lambdas
## list(~ mean(., trim = .2), ~ median(., na.rm = TRUE))
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
# convert likert scores to factor and specify levels
d1$response_1 <- factor(d1$response_1,
levels = c("そう思わない", "どちらかというとそう思わない", "どちらともいえない", "どちらかというとそう思う", "そう思う"),
ordered = TRUE)
d1$response_2 <- factor(d1$response_2,
levels = c("そう思わない", "どちらかというとそう思わない", "どちらともいえない", "どちらかというとそう思う", "そう思う"),
ordered = TRUE)
d1$response_3 <- factor(d1$response_3,
levels = c("そう思わない", "どちらかというとそう思わない", "どちらともいえない", "どちらかというとそう思う", "そう思う"),
ordered = TRUE)
d1$response_4 <- factor(d1$response_4,
levels = c("そう思わない", "どちらかというとそう思わない", "どちらともいえない", "どちらかというとそう思う", "そう思う"),
ordered = TRUE)
d1$response_6 <- factor(d1$response_6,
levels = c("そう思わない", "どちらかというとそう思わない", "どちらともいえない", "どちらかというとそう思う", "そう思う"),
ordered = TRUE)
d1$response_7 <- factor(d1$response_7,
levels = c("そう思わない", "どちらかというとそう思わない", "どちらともいえない", "どちらかというとそう思う", "そう思う"),
ordered = TRUE)
d1$response_8 <- factor(d1$response_8,
levels = c("そう思わない", "どちらかというとそう思わない", "どちらともいえない", "どちらかというとそう思う", "そう思う"),
ordered = TRUE)
# convert the data to a data frame
d2 <- as.data.frame(d1)
# create a likert object
d2_likert <- likert(d2)
# summarize the data
summary(d2_likert)
## Item low neutral high mean sd
## 1 response_1 0.000000 0.000000 100.00000 4.761905 0.4310805
## 2 response_2 0.000000 0.000000 100.00000 4.785714 0.4152997
## 3 response_3 0.000000 0.000000 100.00000 4.738095 0.4450006
## 4 response_4 0.000000 0.000000 100.00000 4.761905 0.4310805
## 7 response_8 2.380952 4.761905 92.85714 4.738095 0.6647766
## 5 response_6 0.000000 9.523810 90.47619 4.642857 0.6559829
## 6 response_7 0.000000 9.523810 90.47619 4.595238 0.6647766
“echo=FALSE”を追加するとコードなしにグラフのみを表示することができます。
response_1からresponse_8の質問文は次です。
授業は全体として関心の持てる内容でしたか。
授業は全体として関心の持てる内容でしたか。
授業のインターネットやコンピュータやスマートフォンの使い方について、全体として理解できましたか。
インターネットやコンピュータの理解やスキルの習得に、授業は役立ちましたか
授業で学んだ英語は難しかったですか。
授業で学んだ英語について、全体として理解できましたか。
授業は英語の知識を深めるのに役立ちましたか。
大学の授業において、コンピュータやインターネットの利用を進めるべきだと思いますか。
“echo=FALSE”を追加すると、次のようにスクリプトなしにグラフのみ表示されます。