R 데이터프레임 특정기간 추출

Jmnote (토론 | 기여)님의 2019년 12월 2일 (월) 00:24 판 (새 문서: ==개요== ;R 데이터프레임 특정기간 추출 ==날짜(Date)== <source lnag='r'> df <- read.table( header=T, stringsAsFactors=FALSE, text=" date fruit ea 2019-05-30...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

R 데이터프레임 특정기간 추출

2 날짜(Date)

df <- read.table( header=T, stringsAsFactors=FALSE, text="
date        fruit    ea
2019-05-30  apple    1
2019-06-01  apple    1
2019-06-03  banana   2
2019-06-05  apple    3
2019-06-06  banana   4
")
df$date <- as.Date(df$date)
df <- df[df$date >= "2019-06-01" & df$date <= "2019-06-05",]
df
##         date  fruit ea
## 2 2019-06-01  apple  1
## 3 2019-06-03 banana  2
## 4 2019-06-05  apple  3

3 같이 보기