say I have data look's like this
vehicle <- c(1,2)
no_of_visits <- c(3,2,4,3,1)
duration <- c(20,30,18,15,20)
bind <- cbind(vehicle, no_of_visits, duration)
vehicle| no_of_visits | duration
----------------
1 | 3 | 20
------------
1 | 2 | 30
------------
1 | 4 | 18
-----------
2 | 3 | 15
-----------
2 | 1 | 20
-----------
And, here in one row i want to show the summarized values and below that i want to show those summed up values
Now, it should look like this
vehicle|no_of_visits|duration
----------------------------
1 | 9 | 68
--------
--------
1 | 3 | 20
--------
1 | 2 | 30
--------
1 | 4 | 18
-------
2 | 4 | 35
-------
-------
2 | 3 | 15
-------
2 | 1 | 2
-------
how to make it work?
Thanks
By using
dplyr
EDIT: for you additional requirement
1st Option:
2nd Option