1

I have 64 different data sets: data 1, data 2, data 3... data 64. I need to calculate the "DTW" distance between each data set and finally get the distance matrix, the code I am using is :

zooData <- zoo(data1$length, data1$Time.Elapsed)
zooData2<-zoo(data2$length,data2$Time.Elapsed)
alignment<-dtw(zooData,zooData2)
alignment$normalizedDistance

In this way, I have to manually change the data set name one by one. The process is super tedious. I am thinking I can use "for loop" to solve this problem, maybe I can put 64 different data sets into a list, and using "for loop"? I am not sure how can I achieve this goal in R. Anyone can help me? Thank you very much!

Yiyang
  • 39
  • 11
  • Please post some data. – harre Dec 03 '15 at 21:07
  • @harre I am sorry but I have 64 different data sets and each of them is very large,, how can I post to here? The main question for me is I already imported 64 different data set into R, but I don't know how to put them into a list, and then I can use "for loop" to get my result "automatically". – Yiyang Dec 03 '15 at 21:09
  • You can eventually post a small subset and indicate the sizes of your data in the original question. Possibly you can do something smarter than a loop. http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – harre Dec 03 '15 at 21:13
  • @harre Thank you, I ll read it. – Yiyang Dec 03 '15 at 21:20
  • @ TheTime Can you give me more explanation about how to use this function in my case? I just searched the information about this function, but still not sure how to use it. I am new to R, Thank you for your help. – Yiyang Dec 03 '15 at 21:22
  • Do an SO or Google search on '[r] mget'. There are many different examples and your curren failure to describe the names of the target files prevents any potential responder from offering effective advice. – IRTFM Dec 03 '15 at 21:27
  • See this too http://stackoverflow.com/questions/29604004/how-can-i-refer-to-multiple-databases-using-the-same-looping-vector-in-r/29604344 – harre Dec 03 '15 at 21:32
  • @42- Thank you, I ll try my best to digest the information. Sorry but I am confused why the file names are important, data1, data 2, data 3... data64 represent target file names, not enough? Thank you for your help. – Yiyang Dec 03 '15 at 21:34

0 Answers0