回答者ID
Character
ID-0001 (1)
ID-0001: 1 (0.05%)
ID-0002 (1)
ID-0002: 1 (0.05%)
ID-0003 (1)
ID-0003: 1 (0.05%)
ID-0004 (1)
ID-0004: 1 (0.05%)
ID-0005 (1)
ID-0005: 1 (0.05%)
ID-0006 (1)
ID-0006: 1 (0.05%)
(Others) (1,994)
(Others): 1,994 (99.70%)
Not NA: 100.00%
NA0 (0.00%)
Unique Values2,000
Min Length7
Max Length7
回答日
Date
Not NA: 100.00%
NA0 (0.00%)
Min2023-01-01
Max2024-12-30
Median2024-01-08
Average2024-01-07
性別
Character
女 (1,016)
女: 1,016 (50.80%)
男 (984)
男: 984 (49.20%)
Not NA: 100.00%
NA0 (0.00%)
Unique Values2
Min Length1
Max Length1
年代
Character
30代 (481)
30代: 481 (24.05%)
40代 (429)
40代: 429 (21.45%)
50代 (404)
50代: 404 (20.20%)
20代 (392)
20代: 392 (19.60%)
60代 (197)
60代: 197 (9.85%)
10代 (97)
10代: 97 (4.85%)
Not NA: 100.00%
NA0 (0.00%)
Unique Values6
Min Length3
Max Length3
推奨度
Integer
Not NA: 100.00%
NA0 (0.00%)
Min4
Max10
Median9
Average8.418
Std Dev1.49
5 Columns   2,000 Rows
5 Columns   2,000 Rows
# Set libPaths.
.libPaths("/Users/im/.exploratory/R/4.4")

# Load required packages.
library(janitor)
library(lubridate)
library(hms)
library(tidyr)
library(stringr)
library(readr)
library(cpp11)
library(forcats)
library(RcppRoll)
library(dplyr)
library(tibble)
library(bit64)
library(zipangu)
library(exploratory)
library(crayon)

# Custom R function as Data.
mIp2ost4.func <- function(){
  set.seed(456)
  
  library(dplyr)
  
  n <- 2000
  
  npsデータ <- tibble(
    回答者ID = sprintf("%04d", 1:n),
    回答日 = sample(seq(as.Date("2023-01-01"), as.Date("2024-12-31"), by = "day"), n, replace = TRUE),
    性別 = sample(c("男", "女"), n, replace = TRUE),
    年代 = sample(c("10代", "20代", "30代", "40代", "50代", "60代"), n, replace = TRUE,
               prob = c(0.05, 0.2, 0.25, 0.2, 0.2, 0.1))
  ) %>%
    rowwise() %>%
    mutate(
      推奨度 = case_when(
        年代 %in% c("20代", "30代") & 性別 == "女" ~ sample(9:10, 1, prob = c(0.45, 0.55)),
        年代 %in% c("20代", "30代") & 性別 == "男" ~ sample(8:10, 1, prob = c(0.2, 0.4, 0.4)),
        年代 == "40代" ~ sample(6:10, 1, prob = c(0.1, 0.1, 0.25, 0.3, 0.25)),
        年代 == "50代" ~ sample(5:9, 1, prob = c(0.1, 0.15, 0.3, 0.3, 0.15)),
        年代 == "60代" ~ sample(4:9, 1, prob = c(0.15, 0.15, 0.25, 0.25, 0.15, 0.05)),
        TRUE ~ sample(7:10, 1, prob = c(0.15, 0.2, 0.35, 0.3))
      )
    ) %>%
    ungroup()
  
}

# Steps to produce the output
mIp2ost4.func() %>%
  readr::type_convert() %>%
  exploratory::clean_data_frame() %>%
  arrange(回答日) %>%
  mutate(回答者ID = str_c("ID-", 回答者ID)) %>%
  mutate(回答者ID = str_c("ID-",str_pad(row_number(), width=4, pad=0)))
Enter a Note Name
Loading the Note Editor...