[R] how to do this trimming/selecting in canonical R?

gildororonar at mail-on.us gildororonar at mail-on.us
Sun Sep 15 03:46:45 CEST 2013


Quoting "Berend Hasselman" <bhh at xs4all.nl>:

> Your trim-point in B is not unique (at least for the data you provided).

Indeed. It's quit a surprise to me. I couldn't figure out why my  
evaluation expression results in multiple trimp-points

> In a general way, I am looking for x and y, where:
> A[x, condition] > max(B[1:y, condition] && A[x, force] > B[y+1, counterforce]

but I'll show you the code I wrote, which is a better explanation of  
my indention:

for( x in seq_len(nrow(A)) ) {
     y = sum(B[,"condition"] < A[x, "condition"])
     if (A[x, "force"] > B[y+1, "counterforce"]) break
}
cat("x=",x,"y=",y,"res=",res,"\n")

Result is:

# x= 5 y= 9 res= TRUE

--
To use the same test data as I have:

> A <- read.table(text = "force condition
0.03515542         1
0.13267882        13
0.26155689        24
0.37453142        38
0.39360520        45
0.43924737        48
0.47669800        50
0.57044795        51
0.81177499        61
0.98860450        94", header=T)

> B <- read.table(text = "counterforce condition
0.965769548         2
0.965266255         5
0.846941244         7
0.818013029        11
0.813139978        22
0.730599939        34
0.715985436        39
0.658073895        40
0.421264948        42
0.373774505        52
0.242191461        62
0.090584590        63
0.070020635        68
0.067366062        83
0.001585313        84", header=T)


-------------------------------------------------

VFEmail.net - http://www.vfemail.net
$14.95 ONETIME Lifetime accounts with Privacy Features!  
15GB disk! No bandwidth quotas!
Commercial and Bulk Mail Options!



More information about the R-help mailing list