Hi,
I couldn't find the data(manaus) in library(Kendall).
I guess data(GuelphP) is similar to your dataset.
class(GuelphP)
[1] "ts"
?typeof(GuelphP)
#[1] "double"
?head(GuelphP)
#[1] 0.47 0.51 0.35 0.19 0.33 ? NA
?GuelphP
# ? ? ? Jan ? Feb ? Mar ? Apr ? May ? Jun ? Jul ? Aug ? Sep ? Oct ? Nov ? Dec
#1972 0.470 0.510 0.350 0.190 0.330 ? ?NA 0.365 0.650 0.825 1.000 0.385 0.900
#1973 0.295 0.140 0.220 0.200 0.140 0.400 ? ?NA 0.495 1.100 0.590 0.270 0.300
#1974 ? ?NA 0.065 0.240 0.058 0.079 0.065 0.120 0.091 0.058 0.120 0.120 0.110
#1975 0.460 0.150 0.086 0.028 ? ?NA 0.110 0.360 0.180 0.065 0.130 0.120 0.190
#1976 0.150 0.107 0.047 0.055 0.080 0.071 0.121 0.108 0.169 0.066 0.079 0.104
#1977 0.157 0.140 0.070 0.056 0.042 0.116 0.106 0.094 0.097 0.050 0.079 0.114
?
?
alb_data<-read.table(text="
year??? Jan??? Feb??? Mar??? Apr??? May??? Jun??? Jul??? Aug Sep??? Oct???
Nov??? Dec
?1997??? NaN??? NaN??? NaN??? NaN??? NaN??? NaN??? NaN??? NaN 23.406 16.166
16.057 16.803
?1998 14.157 14.605 14.112 17.709 13.800 14.338 14.157 17.404 17.725 15.429
16.090 18.061
?1999 14.888 13.837 15.929 13.637 16.020 14.699 15.987 15.212 14.752 15.935
13.397 21.725
?2000 16.562 18.125 19.600 17.971 16.454 15.129 13.901 21.664 17.675 13.793
13.464 16.452
2001 15.706 16.417 13.324 14.117 13.550 15.825 14.687 14.844 15.006 14.793
13.489 15.726
?2002 11.777 11.775 11.564 13.141 14.462 15.517 18.801 15.652 17.127 14.070
14.626 17.964
",sep="",header=TRUE)
typeof(alb_data)
#[1] "list"
?class(alb_data)
#[1] "data.frame"
alb_data1<-ts(matrix(unlist(t(alb_data[,-1])),ncol=1,byrow=F),frequency=12,start=1997)
#or
alb_data1<- ts(as.vector(unlist(t(alb_data[,-1]))),frequency=12,start=1997)
?alb_data1
#??????? Jan??? Feb??? Mar??? Apr??? May??? Jun??? Jul??? Aug??? Sep??? Oct
#1997??? NaN??? NaN??? NaN??? NaN??? NaN??? NaN??? NaN??? NaN 23.406 16.166
#1998 14.157 14.605 14.112 17.709 13.800 14.338 14.157 17.404 17.725 15.429
#1999 14.888 13.837 15.929 13.637 16.020 14.699 15.987 15.212 14.752 15.935
#2000 16.562 18.125 19.600 17.971 16.454 15.129 13.901 21.664 17.675 13.793
#2001 15.706 16.417 13.324 14.117 13.550 15.825 14.687 14.844 15.006 14.793
#2002 11.777 11.775 11.564 13.141 14.462 15.517 18.801 15.652 17.127 14.070
?# ????? Nov??? Dec
#1997 16.057 16.803
#1998 16.090 18.061
#1999 13.397 21.725
#2000 13.464 16.452
#2001 13.489 15.726
#2002 14.626 17.964
class(alb_data1)
#[1] "ts"
?typeof(alb_data1)
#[1] "double"
is.ts(alb_data1)
#[1] TRUE
library(Kendall)
SeasonalMannKendall(na.omit(alb_data1))
#tau = -0.143, 2-sided pvalue =0.20287
A.K.
----- Original Message -----
From: twynne <timothy.wynne at noaa.gov>
To: r-help at r-project.org
Cc:
Sent: Friday, February 15, 2013 2:14 PM
Subject: [R] convert list into a time series
I am trying to use the SeasonalMannKendall function in the Kendall package.
My dataset (alb_data) is in the same format as the example dataset
(manaus) in the package.
> class(manaus)
[1] "ts"> is.ts(manaus)
[1] TRUE> typeof(manaus)
[1] "double"> alb_data=read.table("R:/albemarle_manken.txt", header=T)
> head(alb_data)
? year? ? Jan? ? Feb? ? Mar? ? Apr? ? May? ? Jun? ? Jul? ? Aug Sep? ?
Oct? ? Nov? ? Dec
1 1997? ? NaN? ? NaN? ? NaN? ? NaN? ? NaN? ? NaN? ? NaN? ? NaN 23.406
16.166 16.057 16.803
2 1998 14.157 14.605 14.112 17.709 13.800 14.338 14.157 17.404 17.725
15.429 16.090 18.061
3 1999 14.888 13.837 15.929 13.637 16.020 14.699 15.987 15.212 14.752
15.935 13.397 21.725
4 2000 16.562 18.125 19.600 17.971 16.454 15.129 13.901 21.664 17.675
13.793 13.464 16.452
5 2001 15.706 16.417 13.324 14.117 13.550 15.825 14.687 14.844 15.006
14.793 13.489 15.726
6 2002 11.777 11.775 11.564 13.141 14.462 15.517 18.801 15.652 17.127
14.070 14.626 17.964> class(alb_data)
[1] "data.frame"> is.ts(alb_data)
[1] FALSE> typeof(alb_data)
[1] "list"
Can anyone please help me get my dataset into the correct format so that
I can run the test?
Thank you for your time and help!
--
View this message in context:
http://r.789695.n4.nabble.com/convert-list-into-a-time-series-tp4658716.html
Sent from the R help mailing list archive at Nabble.com.
??? [[alternative HTML version deleted]]
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.