daily pastebin goal
36%
SHARE
TWEET

Untitled

a guest Jan 24th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. tst_df <- data.frame(id = letters[1:5], x = 1:5, y = 6:10)
  3. tst_df
  4.  
  5.  
  6. m_dist_wrapper <- function(a,b) {
  7.   apply(b,2, function(x) m_dist(a,x))
  8. }
  9.  
  10. m_dist <- function(a,b) {
  11.   # b = c(b1,b2)
  12.   sqrt(sum((a-b)^2))
  13. }
  14.  
  15. tst_df %>% mutate ( abc = m_dist_wrapper(c(1,1), rbind(x,y) ))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top