을하지만 다른 답변이 많이 SO에있다 (here for example)이이 문제를 다루고 있습니다. 다른 좋은 선택이 있지만 시간 계열 작업에 xts를 사용합니다.
> stockprices <- data.frame(prices=c(1.1,2.2,3.3),
timestamps=c('2011-01-05 11:00','2011-01-05 12:00','2011-01-05 13:00'))
> stockprices
prices timestamps
1 1.1 2011-01-05 11:00
2 2.2 2011-01-05 12:00
3 3.3 2011-01-05 13:00
당신은 따라서 XTS 시계열로 변환 할 수 있습니다 : 데이터를 가정
는
당신은 데이터 프레임은 read.table를 통해로드 수도, 두 개의 열입니다
> require(xts)
> stockprices.ts <- xts(stockprices$prices, order.by=as.POSIXct(stockprices$timestamps))
> stockprices.ts
[,1]
2011-01-05 11:00:00 1.1
2011-01-05 12:00:00 2.2
2011-01-05 13:00:00 3.3
없었다 어떤 경우 시간,하지만 날짜 만? –
@ScottDavis : 간단한 날짜를 원한다면'as.POSIXct' 함수 호출을'as.Date'로 변경할 수 있습니다. – khoxsey