what I have managed to do in R