R: fixed a bug when many graphs were created, causing #550.