[R] Axiom alike formula needs to get prooved

Frank Schwidom @chw|dom @end|ng |rom gmx@net
Sat Oct 5 23:56:34 CEST 2019


Hi,

I found the following relationship:

it is given

x is a vector, bm1 and bm2 are vectors of type logical end exactly as long as x

then the following formula returns alwasy TRUE:

all( x[ bm1 & bm2] == x[ bm2][ bm1[ bm2]] )

.

I think it is no such great deal and a lot of R programmers will know this and use it in their code intutively.

But the point is: Years ago I tried to prove this relationship and found no acceptable solution for that.

Is anyone able to prove this in a mathematical correct way?

Besides that: here is another one

it is given a dataframe 'result_df' with at least the column 'result_value'

best_results <- with( result_df, sort( result_value))[1:100] # lower is better
best_results_bmask <- with( result_df, result_value %in% best_results)

best_results_order2 <- with( result_df[ best_results_bmask, ], order( result_value))

df1 <- result_df[best_results_order, ][ best_results_bmask[best_results_order], ]
df2 <- result_df[best_results_bmask, ][best_results_order2, ]

all( df1 == df2)

# that was the easy part, now this:

df3 <- result_df[best_results_order[ best_results_bmask[ best_results_order]], ]

all( df1 == df3) # it works, but how can I understand that and how it is proven?

Regards
Frank Schwidom



More information about the R-help mailing list