Note that any ordinary assignments done within the function are local and temporary and lost after exit from the function. Thus the assignment X <- qr(X) does not affect the value of the argument in the calling program.
To understand completely the rules governing the scope of S-PLUS assignments the reader needs to be familiar with the notion of an evaluation frame. This is a somewhat advanced, though hardly difficult, topic and is not covered further in these notes.
If global and permanent assignments are intended within a function, then the `superassignment' operator, `<<-' can be used. See the help document for details, and also see the synchronize() function.