⛑️
データサイエンス100本ノック(構造化データ加工編)をRで解く 1 - 10
R-001
df_receipt %>% head(10)
R-002
df_receipt %>%
select(
sales_ymd,
customer_id,
product_cd,
amount
) %>%
head(10)
R-003
df_receipt %>%
select(
sales_ymd,
customer_id,
product_cd,
amount
) %>%
rename(
sales_date = sales_ymd
) %>%
head(10)
R-004
df_receipt %>%
select(
sales_ymd,
customer_id,
product_cd,
amount
) %>%
rename(
sales_date = sales_ymd
) %>%
dplyr::filter(
customer_id == "CS018205000001"
)
R-005
df_receipt %>%
select(
sales_ymd,
customer_id,
product_cd,
amount
) %>%
rename(
sales_date = sales_ymd
) %>%
dplyr::filter(
customer_id == "CS018205000001",
amount >= 1000
)
R-006
df_receipt %>%
select(
sales_ymd,
customer_id,
product_cd,
quantity,
amount
) %>%
rename(
sales_date = sales_ymd
) %>%
dplyr::filter(
customer_id == "CS018205000001",
{amount >= 1000} | {quantity >= 5}
)
R-007
df_receipt %>%
select(
sales_ymd,
customer_id,
product_cd,
quantity,
amount
) %>%
rename(
sales_date = sales_ymd
) %>%
dplyr::filter(
customer_id == "CS018205000001",
{amount >= 1000} & {amount <= 2000}
)
R-008
df_receipt %>%
select(
sales_ymd,
customer_id,
product_cd,
quantity,
amount
) %>%
rename(
sales_date = sales_ymd
) %>%
dplyr::filter(
customer_id == "CS018205000001",
product_cd != "P071401019"
)
R-009
df_store %>%
dplyr::filter(
!(prefecture_cd == "13" & floor_area > 900)
)
R-010
df_store %>%
dplyr::filter(
str_starts(store_cd, "S14")
) %>%
head(10)
Discussion