I have a dataframe as follows:
chr leftPos TBGGT 12_try 324Gtt AMN2 1 24352 34 43 19 43 1 53534 2 1 -1 -9 2 34 -15 7 -9 -18 3 3443 -100 -4 4 -9 3 3445 -100 -1 6 -1 3 3667 5 -5 9 5 3 7882 -8 -9 1 3
I need to create a loop that:
a) Computes the upper and lower limit (UL and LL) for each column from the third column forward.
b) Includes only rows that go beyond UL and LL (Zoutliers).
c) Then count the number of lines in which Zoutlier will be the same direction (i.e., positive or negative) as the previous or next line for the same chr.
Thus, the output will be as follows:
ZScore1 TBGGT 12_try 324Gtt AMN2 nrow 4 6 4 4
So far I have the code as follows:
library(data.table)
The code is flashed from different places. The problem I have is combining parts A) and B) of the code to get the result I want
source share