Re: [R] Problems with Mann-Kendall trend test
Dear, You have to store your data as a Time-Series (ts), first. To define a column of data as ts, you may use this: library(timeSeries)Nile <- read.csv(file.choose(), header=F)#If your data is monthly, you may define the frequency as 12, for annual ts set freq. as 1. #If your data starts from for e.g., 1990, then:NileTS <- ts(Nile, frequency=1, start=c(1990,1))#To plot the time seriesplot.ts(NileTS) Morteza On Saturday, June 18, 2016 3:47 AM, lily liwrote: Dear R users, Can anyone help me with mann-kendall trend test? I tried to use the newest packages 'trend', and the function mk.test, but had problems in applying the input data. For example, res <- mk.test(Nile), Nile is a time-series data. But when I use my dataset, with one column which is a time-series data, it says "error: input must be ts object". How to do this? Thanks for your help. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Help me
Moses, If I understand correctly, you are installed R and Rstudio.Please do find the package(s) you would like to use.Once you run rstudio, you can search and install the package(s) using the bottom right corner menu:Packages> Install> install from Repository (Cran)> search the package you would like to use in the box below 'Packages',then select the package name, and do not forget to let the default settings for "install dependencies", since you're new the R, and finally Install the package. Once the package is downloaded and installed, you can see the name of the installed package in the same window. To run it, you have to check the box to load the package.You may find the documentation for each package using 'help()', help(type the package name).For the rest, instead of using "Help me" in the subject line, please mention the package name and your problem, and explain exactly what would you do in the body. Good Luck.Morteza On Thursday, March 3, 2016 2:12 PM, Moss Mosswrote: Please, I need help from you. I am new to R. I installed R, Rstudio and R Crans or packages that I will like to use. Thanks for your help on that. Right now, what do I do? Will I upload the CRAN packages already installed, so that a GUI interface will come up. I am working on Location Model and need some help. Moses __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] zyp Vs. kendall package for Time Series Trend
Dear members, I need to detect trends in time series. To remove the effect of "Lag-1 serial correlation", it is suggested to use either Yue or Zhang method. Both methods are available in "zyp" package. The package uses "kendall" package for trend analysis. Based on Yue (2002), if the lag-1 serial correlation is significant, TFPW method will remove the effects of it prior to the trend test; otherwise trend test will be applied on original time series. I've compared the results of a sample time series with non-significant lag-1 serial correlation, using both zyp & kendall packages. "yuepilon" method in "zyp" gives me the following results:tau: 0.075 & sig: 0.388 while "kendall" package gives me this: tau: 0.109 & sig: 0.216 The question is : Does "zyp" change the significance of the trend in this case as well? Is this a malfunction or did I miss something? I've checked the script and it is mentioned (ln 65) : # Prewhiten the original series c <- acf(data,lag.max=1,plot=FALSE,na.action=na.pass)$acf[2] Thank you for your consideration. Best regards, Morteza __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] missForest: Looping through files in a folder
Dear members, Could you please help me on this issue. I've already searched and I watched some videos, but it was not useful.I need help to loop through the files in a folder (200+ csv files). I am using missForest() to impute missing values. If I run the code for each single file, I have to do as following: ## main script for each single file G1334108 <- read.csv(file.choose(), header = T) G1334108.F <- missForest(G1334108, verbose = TRUE, maxiter = 5) write.csv(G1334108.F$ximp, file = 'G1334108_F.csv') I tried these below script codes to loop the function before writing here: # 1st tryall.files <- list.files() my.files <- grep(".*csv", all_files, value=T) for(i in my.files){ # do your operations here G1344108.Forest <- missForest(G1344108, verbose = TRUE, maxiter = 5) # save output.filename <- gsub("(.*?).csv", "\\1.csv", i) write.table(G1344108.Forest$ximp, output.filename) }## 2nd try files <- list.files()lapply(files, function(x) {my.files <- read.csv("*.csv", header = T)missforest.out <- missForest(my.files, verbose = TRUE, maxiter = 5)write.csv(missforest.out$ximp, file = '*_F.csv') }Thank you for the time.Best regards,Morteza [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] missForest: Looping through files in a folder
Hi Jim,Thank you very much for the time.You saved me 3 days! Best regards, Morteza On Saturday, January 2, 2016 5:33 AM, Jim Lemon <drjimle...@gmail.com> wrote: Hi Morteza,What you may want is this: my.files<-list.files(pattern=".csv")newfiles<-gsub(".","_F.",my.files,fixed=TRUE)for(i in 1:length(my.files)) { mydat<-read.csv(my.files[i]) mydatimp<-missForest(mydat,verbose=TRUE,maxiter=5) write.csv(mydatimp$ximp,newfiles[i])} Jim On Sat, Jan 2, 2016 at 5:32 AM, Morteza Firouzi via R-help <r-help@r-project.org> wrote: Dear members, Could you please help me on this issue. I've already searched and I watched some videos, but it was not useful.I need help to loop through the files in a folder (200+ csv files). I am using missForest() to impute missing values. If I run the code for each single file, I have to do as following: ## main script for each single file G1334108 <- read.csv(file.choose(), header = T) G1334108.F <- missForest(G1334108, verbose = TRUE, maxiter = 5) write.csv(G1334108.F$ximp, file = 'G1334108_F.csv') I tried these below script codes to loop the function before writing here: # 1st tryall.files <- list.files() my.files <- grep(".*csv", all_files, value=T) for(i in my.files){ # do your operations here G1344108.Forest <- missForest(G1344108, verbose = TRUE, maxiter = 5) # save output.filename <- gsub("(.*?).csv", "\\1.csv", i) write.table(G1344108.Forest$ximp, output.filename) }## 2nd try files <- list.files()lapply(files, function(x) {my.files <- read.csv("*.csv", header = T)missforest.out <- missForest(my.files, verbose = TRUE, maxiter = 5)write.csv(missforest.out$ximp, file = '*_F.csv') }Thank you for the time.Best regards,Morteza [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.