knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
5ch(旧2ch)のスレを専用ブラウザで開いた時に保存されるdatファイルを読み込んで、そのスレの各レスを行に持つdata.frameを返します。
remotes::install_github("suzuna/readdat5")
5chのスレを専用ブラウザで開いた時に保存されるdatファイルを読み込んで、そのスレの各レスのdata.frameを返す関数です。
read_dat(file,br_char="[br]",encoding="Shift-JIS")
引数は以下の通りです。
返り値は、以下の列を持つdata.frameです。
なお、元のレスの投稿日時が"2021/1/1 01:23:45.67"のようにミリ秒まで存在する場合、以下のようにすると、datetimeがミリ秒を含んだPOSIXctの列になります。
df <- read_dat(file,br_char="[br]",encoding="Shift-JIS") options(digits.secs=2) df <- df %>% mutate(datetime=as.POSIXct(datetime,format="%Y/%m/%d %H:%M:%OS"))
2個以上のファイルパスを与えることはできません。2個以上のファイルパスを与えたい場合には、purrr::map_dfrなどを用いてください。読み込みたいdatファイルが大量にある場合は、furrr::future_map_dfrなどを用いると、並列化によって高速に読み込めます。
file_path <- c("foo.dat","bar.dat") map_dfr(file_path,~read_dat(file=.x,br_char="[br]",encoding="Shift-JIS"))
文字列ベクトルの各要素の中に含まれる文字参照(character reference)をunescapeする関数です。
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.