-1
       ax  ay  az  bx  by  bz cx cy cz dx dy dz ex ey ez Hid       PX       PY       PZ
1   330 295 998   0   0   0  0  0  0  0  0  0  0  0  0   0 279.6626 310.3374 923.4111
2     0   0   0 260 375 941  0  0  0  0  0  0  0  0  0   0 279.6626 310.3374 923.4111
3     0   0   0 245 375 949  0  0  0  0  0  0  0  0  0   0 279.6667 310.2424 924.7394
4   330 295 998   0   0   0  0  0  0  0  0  0  0  0  0   0 279.6667 310.2424 924.7394

For same PX,PY and PZ values I want to merge the rows for eg the output should be

    ax  ay  az  bx  by  bz cx cy cz dx dy dz ex ey ez Hid       PX       PY       PZ
1   330 295 998 260 375 941   0  0  0  0  0  0  0  0  0   0 279.6626 310.3374 923.4111
2   330 295 998 245 375 949  0  0  0  0  0  0  0  0  0   0 279.6667 310.2424 924.7394
Jaap
  • 81,064
  • 34
  • 182
  • 193
user459
  • 111
  • 8
  • you don't say anything about the output you want but jour could take a look at join() from the dplyr package https://stat545-ubc.github.io/bit001_dplyr-cheatsheet.html – MLavoie Jan 13 '16 at 12:35
  • 1
    See also: http://stackoverflow.com/questions/9723208/aggregate-multiple-variables-simultaneously – Jaap Jan 13 '16 at 12:39

1 Answers1

3

With data.table, you can try this (your data.frame being called df):

library(data.table)
setDT(df)[, lapply(.SD, max), by=.(PX, PY, PZ)]
#         PX       PY       PZ  ax  ay  az  bx  by  bz cx cy cz dx dy dz ex ey ez Hid
#1: 279.6626 310.3374 923.4111 330 295 998 260 375 941  0  0  0  0  0  0  0  0  0   0
#2: 279.6667 310.2424 924.7394 330 295 998 245 375 949  0  0  0  0  0  0  0  0  0   0
Cath
  • 23,906
  • 5
  • 52
  • 86