1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Dateなんてもう嫌いだ

Last updated at Posted at 2021-05-31

はじめに

rで as.Date 使うたびにググっている気がするので備忘録。

Dateにするとき

基本は文字列→Dateに変換

hoge_date <- as.Date("1960-01-01")

文字列からDateにするとき

数字だけからDateにしたいときは format="" で指定。

hoge <- "19600101"
hoge_date <- as.Date(hoge_date, format = "%Y%m%d")

hogeがintegerだとエラーを吐くので文字列にしてからas.Date()する

hoge_date <- as.Date(as.character(hoge_date), format = "%Y%m%d")
1
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?