[R] “For” calculation is so slow

2012-05-22 Thread jiangxijixzy
Dear All, The function I wrote can run well with the small data, but with the large data, the function runs very very slowly. How can I correct it? Thank you very much. My function as below: a<-c(1:240) b<-c(1:240) l=function(a,b){ v=0 u=0 uv=0 v[1]=0 u[1]=0 uv[1]=0 for (i in 1:(length(s)-1)){ v[

[R] pick up the values

2012-05-02 Thread jiangxijixzy
Hi, I have a list of data, e.g. r[[i]] r[[1]]= 1 2 1 6 5 5 5.5 3 r[[2]]= 46 35 78 35 … r[[500]]. In the first column, the selected values should like this: (the later value)-(the former value)>=1 In the second column, the selected values should like this: (the form

Re: [R] Batch importing data

2012-05-02 Thread jiangxijixzy
Thank you very much. -- View this message in context: http://r.789695.n4.nabble.com/Batch-importing-data-tp4592997p4602378.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/l

[R] list objects calculation

2012-05-02 Thread jiangxijixzy
I have two kinds of list, for example, one is like t[[1]]= 1 6 2 7 3 8 4 9 5 10 ... t[[731]] the other is k[[1]]= 9 10 ... k[[731]] I want to have a new list,like x x[[1]]= (1-9)/9(6-10)/10 (2-9)/9(7-10)/10 (3-9)/9(8-10)/10 (4-9)/9(9-10)/10 (5-9)/9(10-10)/10 ... x[[731]] How s

[R] Batch importing data

2012-04-27 Thread jiangxijixzy
I want to import data from about 2000 text files, and hope to create a data frame to make it easy to quote the data. For example, the files like this Oil_20030801.txt, Oil_20030804.txt, Oil_20030805.txt … Oil_20120427.txt The dates aren’t continuous. I want to create the data frame called “Oil”, li