I am student computer science student and novice R user.
Below is my Dataframe.
set.seed(1234)
df <- data.frame(
                  sex = rep(c('M','F'), 10),
                  profession = rep(c('Doctor','Lawyer'), each = 5),
                  pariticpant = rep(1:10, 2),
                  x = runif(20, 1, 10),
                  y = runif(20, 1, 10))
I want to find the differences in x and y for each day and for each participant. This will create a 10-row dataframe.
dday will replace day as the values will be the differences between the days. 
dday sex profession participant dx   dy
0-1  M   Doctor     1           5.22 1.26
.
.
.
Would there be a proper way in R to perform this function?

 
     
    