Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 204742

Summarise a group value into single row

$
0
0

I have a large dataset with longitudinal readings from single individuals. I want to summarise information over time into a binary variable. i.e. if diff in the input table below is >5 for any value I want to then reduce the observation for A to a new column saying TRUE.

#Input

individual    val1    val2    diff
A    32    36    -4
A    36    28    8
A    28    26    2
A    26    26    0
B    65    64    1
B    58    59    -1
B    57    54    3
B    54    51    3

#Output

individual    newval
A    TRUE
B    FALSE

Viewing all articles
Browse latest Browse all 204742

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>