-
-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
例えば次のような、上の項目と同じことを示す 〃 に対して、 〃 ではなく前の値を代入させる。
d_sample <- structure(
list(code = c("欠番", "〃",
"新設", "欠番", "〃", "〃")),
row.names = c(NA, -6L),
class = c("tbl_df",
"tbl", "data.frame")
)
d_sample
#> # A tibble: 6 x 1
#> code
#> <chr>
#> 1 欠番
#> 2 〃
#> 3 新設
#> 4 欠番
#> 5 〃
#> 6 〃 こうする。
d_sample %>%
dplyr::mutate(code = dplyr::na_if(code, y = "〃")) %>%
tidyr::fill(code, .direction = "down")
#> # A tibble: 6 x 1
#> code
#> <chr>
#> 1 欠番
#> 2 欠番
#> 3 新設
#> 4 欠番
#> 5 欠番
#> 6 欠番 tidyr::fill(.direction = "down")は固定値でも良さそう。
Metadata
Metadata
Assignees
Labels
No labels