R関数入門
Richie Cotton
Data Evangelist at DataCamp
mean には引数が3つあります
x: 数値または日時ベクトルtrim: 計算前に両端から除外する外れ値の割合na.rm: 計算前に NA を除去位置で渡す
mean(numbers, 0.1, TRUE)
名前で渡す
mean(na.rm = TRUE, trim = 0.1, x = numbers)
一般的な引数は位置、まれな引数は名前
mean(numbers, trim = 0.1, na.rm = TRUE)
library(readr)
test_scores_geography_raw <- read_csv("test_scores_geography.csv")
library(dplyr)
test_scores_geography_clean <- test_scores_geography_raw %>%
select(person_id, first_name, last_name, test_date, score)
library(readr)
test_scores_geography_raw <- read_csv("test_scores_geography.csv")
library(dplyr)
test_scores_geography_clean <- test_scores_geography_raw %>%
select(person_id, first_name, last_name, test_date, score)
library(readr)
test_scores_geography_raw <- read_csv("test_scores_geography.csv")
library(dplyr)
test_scores_geography_clean <- test_scores_geography_raw %>%
select(person_id, first_name, last_name, test_date, score)
library(readr)
test_scores_geography_raw <- read_csv("test_scores_geography.csv")
library(dplyr)
test_scores_geography_clean <- test_scores_geography_raw %>%
select(person_id, first_name, last_name, test_date, score)
library(readr)
test_scores_geography_raw <- read_csv("test_scores_geography.csv")
library(dplyr)
test_scores_geography_clean <- test_scores_geography_raw %>%
select(person_id, first_name, last_name, test_date, score)
library(readr)
test_scores_geography_raw <- read_csv("test_scores_geography.csv")
library(dplyr)
test_scores_geography_clean <- test_scores_geography_raw %>%
select(person_id, first_name, last_name, test_date, score)
library(readr)
test_scores_english_raw <- read_csv("test_scores_english.csv")
library(dplyr)
test_scores_english_clean <- test_scores_english_raw %>%
select(person_id, first_name, last_name, test_date, score)
library(readr)
test_scores_art_raw <- read_csv("test_scores_art.csv")
library(dplyr)
test_scores_art_clean <- test_scores_art_raw %>%
select(person_id, first_name, last_name, test_date, score)
library(readr)
test_scores_spanish_raw <- read_csv("test_scores_spanish.csv")
library(dplyr)
test_scores_spanish_clean <- test_scores_spanish_raw %>%
select(person_id, first_name, last_name, test_date, score)
library(readr)
test_scores_geography_raw <- read_csv("test_scores_geography.csv")
library(dplyr)
library(lubridate)
test_scores_geography_clean <- test_scores_geography_raw %>%
select(person_id, first_name, last_name, test_date, score) %>%
mutate(test_date = mdy(test_date))
library(readr)
test_scores_english_raw <- read_csv("test_scores_english.csv")
library(dplyr)
library(lubridate)
test_scores_english_clean <- test_scores_english_raw %>%
select(person_id, first_name, last_name, test_date, score) %>%
mutate(test_date = mdy(test_date))
library(readr)
test_scores_art_raw <- read_csv("test_scores_art.csv")
library(dplyr)
library(lubridate)
test_scores_art_clean <- test_scores_art_raw %>%
select(person_id, first_name, last_name, test_date, score) %>%
mutate(test_date = mdy(test_date))
library(readr)
test_scores_spanish_raw <- read_csv("test_scores_spanish.csv")
library(dplyr)
library(lubridate)
test_scores_spanish_clean <- test_scores_spanish_raw %>%
select(person_id, first_name, last_name, test_date, score) %>%
mutate(test_date = mdy(test_date))
library(readr)
test_scores_geography_raw <- read_csv("test_scores_geography.csv")
library(dplyr)
library(lubridate)
test_scores_geography_clean <- test_scores_geography_raw %>%
select(person_id, first_name, last_name, test_date, score) %>%
mutate(test_date = mdy(test_date)) %>%
filter(!is.na(score))
library(readr)
test_scores_english_raw <- read_csv("test_scores_english.csv")
library(dplyr)
library(lubridate)
test_scores_english_clean <- test_scores_english_raw %>%
select(person_id, first_name, last_name, test_date, score) %>%
mutate(test_date = mdy(test_date)) %>%
filter(!is.na(score))
library(readr)
test_scores_art_raw <- read_csv("test_scores_art.csv")
library(dplyr)
library(lubridate)
test_scores_art_clean <- test_scores_art_raw %>%
select(person_id, first_name, last_name, test_date, score) %>%
mutate(test_date = mdy(test_date)) %>%
filter(is.na(score))
library(readr)
test_scores_spanish_raw <- read_csv("test_scores_spanish.csv")
library(dplyr)
library(lubridate)
test_scores_spanish_clean <- test_scores_spanish_raw %>%
select(person_id, first_name, last_name, test_date, score) %>%
mutate(test_date = mdy(test_date)) %>%
filter(!is.na(score))
関数はコードの重複をなくします。
また、再利用・共有が容易になります。
R関数入門