finished R interface