[R] Fw: summing up and cut off with looping

oslo hokut1 at yahoo.com
Fri Jun 10 21:38:52 CEST 2016


I am so sorry that the data in my previous file was very mass;Here are my data sets
> A  posA posB1    1    92    2    73    5   124    4    75    9   13> 
  pos   a  b    c1   4 0.4  7 0.802   2 0.1  5 0.403   7 0.5  8 0.324   1 0.4  1 0.105  13 0.1  6 0.136  12 0.2 11 0.017   9 0.3 12 0.23> 
 Hi all;
I am quite new in R. I have tried write a loop to sum up a column and cut off when summation reach certain point. Here are a small example and my R codes.
Your helps are truly appreciated,
Oslo

I would like to sum up the B$a column and cut off at 0.7 for the each row of intervals giving in file=A.For example the interval  at the first row in A$posA and A$posB is 1 and 9. So, I need adding up the B$a and cut off B$a>.7 from the 1 to 9 in B$pos. And then I need to the same using the intervals in the second, third..... rows in A. Obviously my loop is wrong and  does not work properly. Please help for my this first experience.  Thanks.

Here are my codes
#sorting B$possort=B[order(B$pos),]
#Running loop
for(i in 1:nrow(A)) {if(sum(B[a$B, i:A[1:2])>0.7) {print(A[1:i,]) } }

    [[alternative HTML version deleted]]

______________________________________________
R-help at 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]]



More information about the R-help mailing list