stringr::str_length("あいうえお12345")[1] 10
stringr::str_length("あいうえお12345")[1] 10
stringr::str_detect("あいうえお12345", "あ")[1] TRUE
stringr::str_detect("あいうえお12345", "[0-9]") # 数字[1] TRUE
stringr::str_split("東京都港区三田", "都|区") # 正規表現の|はorの意味[[1]]
[1] "東京" "港" "三田"
stringr::str_c("今の日時", lubridate::now(), sep = ": ")[1] "今の日時: 2023-07-17 10:01:18.08186"
stringr::str_glue("今の日時: {lubridate::now()}")今の日時: 2023-07-17 10:01:18.127982
paste("東京", NA, "三田", sep = "_")[1] "東京_NA_三田"
stringr::str_c("東京", NA, "三田", sep = "_")[1] NA
stringr::str_sub(c("千代田区", "中央区", "港区"), start = 1, end = -2)[1] "千代田" "中央" "港"
stringr::str_subset(c("千代田区", "中央区", "港区", "武蔵野市", "立川市"), ".*区")[1] "千代田区" "中央区" "港区"
city <- tibble::tibble(city = c("千代田区", "中央区", "港区", "武蔵野市", "立川市"))
city |>
dplyr::mutate(city_name = stringr::str_extract(city, ".*区"))city <- tibble::tibble(city = c("千代田区", "中央区", "港区", "武蔵野市", "立川市"))
city |>
dplyr::mutate(center_name = stringr::str_replace_all(city, "区|市", "支店"))city <- tibble::tibble(city = c("千代田区", "中央区", "港区", "武蔵野市", "立川市"))
city |>
dplyr::mutate(city_name = stringr::str_remove_all(city, "区|市"))stringr::str_trim(" あいうえお 12345 ")[1] "あいうえお 12345"
stringr::str_pad(
c("1", "10", "100"),
width = 3, # 揃える桁数
pad = "0" # 埋め合わせに使う文字
)[1] "001" "010" "100"
for(i in 1:5){
stringr::str_dup("A", i) |>
print()
}[1] "A"
[1] "AA"
[1] "AAA"
[1] "AAAA"
[1] "AAAAA"
stringr::str_to_lower("R PACKAGES FOR DATA SCIENCE")[1] "r packages for data science"
stringr::str_to_upper("R packages for data science")[1] "R PACKAGES FOR DATA SCIENCE"
stringr::str_to_sentence("see how the tidyverse makes data science faster,")[1] "See how the tidyverse makes data science faster,"
stringr::str_to_title("R packages for data science")[1] "R Packages For Data Science"
separate_address("東京都港区三田2丁目15−45")
## 結果は下記の通り
# $prefecture
# [1] "東京都"
# $city
# [1] "港区"
# $street
# [1] "三田2丁目15−45"zipangu::convert_jyear("平成12年")[1] 2000
zipangu::kansuji2arabic_all("平成一三年一月一六日")[1] "平成13年1月16日"
zipangu::str_conv_hirakana("カスミガセキ", to = "hiragana")[1] "かすみがせき"
zipangu::str_conv_zenhan("千代田区霞が関2-1-2", "hankaku")[1] "千代田区霞が関2-1-2"
zipangu::str_conv_normalize("①A") [1] "1A"
zipangu::find_date_by_wday(year = 2020, month = 1, wday = 2, ordinal = 2) # 2020年1月の第2月曜日[1] "2020-01-13"
zipangu::harmonize_prefecture_name(c("東京", "北海道", "京都"), to = "long")[1] "東京都" "北海道" "京都府"
zipangu::harmonize_prefecture_name(c("東京都", "北海道", "京都府"), to = "short")[1] "東京" "北海道" "京都"
zipangu::is_jholiday(date = as.Date("2021-07-23")) # TRUE[1] TRUE
zipangu::jholiday(2020, lang = "jp")$元日
[1] "2020-01-01"
$成人の日
[1] "2020-01-13"
$建国記念の日
[1] "2020-02-11"
$天皇誕生日
[1] "2020-02-23"
$春分の日
[1] "2020-03-20"
$昭和の日
[1] "2020-04-29"
$憲法記念日
[1] "2020-05-03"
$みどりの日
[1] "2020-05-04"
$こどもの日
[1] "2020-05-05"
$海の日
[1] "2020-07-23"
$スポーツの日
[1] "2020-07-24"
$山の日
[1] "2020-08-10"
$敬老の日
[1] "2020-09-21"
$秋分の日
[1] "2020-09-22"
$文化の日
[1] "2020-11-03"
$勤労感謝の日
[1] "2020-11-23"
zipangu::jholiday_spec(2010, "海の日", lang = "jp")[1] "2010-07-19"