Hello I have two for loops that I am trying to optimize... I looked for vectorization or for using some funcions of the apply family but really cannot do it. I am writting my code with some small data set. With this size there is no problem but sometimes I will have hundreds of rows so it is really important to optimize the code. Any suggestion will be very welcomed.
library("TSMining") dataS = data.frame(V1 = sample(c(1,2,3,4),30,replace = T), V2 = sample(c(1,2,3,4),30,replace = T), V3 = sample(c(1,2,3,4),30,replace = T), V4 = sample(c(1,2,3,4),30,replace = T)) saxM = Func.matrix(5) colnames(saxM) = 1:5 rownames(saxM) = 1:5 matrixPrepared = matrix(NA, nrow = nrow(dataS), ncol = nrow(dataS)) FOR(I IN 1:(NROW(DATAS)-1)){ FOR(J IN (1+I):NROW(DATAS)){ MATRIXPREPARED[I,J] = FUNC.DIST(AS.CHARACTER(DATAS[I,]), AS.CHARACTER(DATAS[J,]), SAXM, N=60) } } matrixPrepared Thank you! ------ Aurora González Vidal Phd student in Data Analytics for Energy Efficiency Faculty of Computer Sciences University of Murcia @. aurora.gonzal...@um.es T. 868 88 7866 www.um.es/ae [[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.