In this code i try to calculate le difference between too number for two value of th variable phase i have did this
> (output <- read.csv2("C:/RM2Param.csv",sep=",")) OptimYear LRPhase PriorLRPosition OptimPosition 1 2009 -1 1.15641679414676 0.252662968666702 2 2009 -1 1.05365365779321 0.119348307634027 3 2009 -1 0.959670688361124 0.0179266585317901 4 2009 -1 0.87403582415134 0.0217791412141115 5 2009 1 1.15641679414676 0.33037984561357 6 2009 1 1.05365365779321 0.282266634171568 7 2009 1 0.959670688361124 0.199612536004054 8 2009 1 0.87403582415134 0.103774779139200 > PriorLRPosition <- as.numeric(as.character(output[,3])) > OptimPosition <- as.numeric(as.character(output[,4])) > (SimuLRPosition <- rep(1, nrow(output))) [1] 1 1 1 1 1 1 1 1 > output <- cbind(output,SimuLRPosition) > (diffLRPosition <- abs(PriorLRPosition - SimuLRPosition)) [1] 0.15641679 0.05365366 0.04032931 0.12596418 0.15641679 0.05365366 0.04032931 [8] 0.12596418 > output <- cbind(output,diffLRPosition) > (NbOFPriorLRPosition <- nrow(output)/2) [1] 4 > > for (LRPhase in c(-1,1)) + {Phase1 <- output[output[,2]==LRPhase,]} > > Phase1 <- Phase1[order (Phase1[,6]),] > Phase1 OptimYear LRPhase PriorLRPosition OptimPosition SimuLRPosition 7 2009 1 0.959670688361124 0.199612536004054 1 6 2009 1 1.05365365779321 0.282266634171568 1 8 2009 1 0.87403582415134 0.103774779139200 1 5 2009 1 1.15641679414676 0.33037984561357 1 diffLRPosition 7 0.04032931 6 0.05365366 8 0.12596418 5 0.15641679 why when i write for LRPhase in c(1,-1), it gives me the result only for Phase = 1?? i want two results for Phase = 1 and Phase = -1????!!! someone can help me please!!! thank you regards [[alternative HTML version deleted]]
______________________________________________ R-help@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.