Added loss function as argument to sgd, added R example plot