2016-11-14 3 views
1

데이터 열을 CSV로 데이터 프레임에 내 보낸 날짜 열이 있습니다. "가져 오기 데이터 세트 ..." "CSV에서 가져온 것"즉 d<-read_csv(data.csv). 데이터 프레임에서 동물원 및/또는 xts 객체를 만들고 싶습니다.엑셀에서 동물원 (또는 xts)으로 날짜 열을 읽으십시오

데이터는 다음과 같습니다

30/04/2016 
31/05/2016 
30/06/2016 

나는 다음과 같은 오류를 얻을 :

dates <- c('30/04/2016','31/05/2016','30/06/2016') 
d <- dates 
z <- read.zoo(d) 

Error in read.zoo(d) : index has bad entry at data row 1

z <- read.zoo(d, FUN = as.Date()) 

Error in as.Date() : argument "x" is missing, with no default

z <- read.zoo(d, FUN = as.Date(format="%d/%m/%Y")) 

Error in as.Date(format = "%d/%m/%Y") : argument "x" is missing, with no default

을 1 오류가 나쁜 항목 행은 무엇

ts.z <- read.zoo(d,index=1,tz='',format="%d/%m/%Y") 

Error in read.zoo(d, index = 1, tz = "", format = "%d/%m/%Y") :
index has bad entry at data row 1

: 나는 형식 arguemnt 동물원에 직접 읽으면 0

또한, 난 다른 오류가? FUN =을 지정하는 올바른 방법은 무엇입니까? read.zoo에 대한 올바른 입력 클래스 및 구별은 무엇입니까?

답변

1
file -parameter에 대한 ?read.zoo에서

: 귀하의 예제에서 잘못된 무슨 일

character string or strings giving the name of the file(s) which the data are to be read from/written to. See read.table and write.table for more information. Alternatively, in read.zoo , file can be a connection or a data.frame (e.g., resulting from a previous read.table call) that is subsequently processed to a "zoo" series.

d는 파일 이름, 연결 또는 data.frame도 있다는 것이다. data.frame()에 포장해야합니다.

동작하는 예제 :

z <- read.zoo(data.frame(dates), FUN = as.Date, format='%d/%m/%Y') 

준다 :

> z 

2016-04-30 
2016-05-31 
2016-06-30 
> class(z) 
[1] "zoo" 

사용한 입력 데이터 :

dates <- c('30/04/2016','31/05/2016','30/06/2016') 
관련 문제