assign(x, value, frame=<<see below>>, where=<<see below>>, ...) assign.default(x, value, frame=<<see below>>, where=<<see below>>, immediate=F)
It is an error to give both frame and where.
The x argument provides the name of the object that will be created. For example, assign("a$b", 1) is distinctly not the way to create the component b of object a; rather it will create an object named a$b. If you created this object, you would need to use the get function to use the object. This allows you to create objects (to correspond with objects in another language, perhaps) whose names are not legal object names in S-PLUS. If you do want to assign the b component of a, then create all of a and assign a.
If both where and frame are omitted, the assign function works exactly the same way as the <- operator; that is, it assigns (permanently) to the working data when used at the top level (typed by the user, for example), and to the local frame of a function call when used from inside a function.
This is a generic function, currently with only a default method. The methods are for the class of where; that is, if where is a special type of database, you can write an assign method to store objects into such a database. The default method creates a file containing the usual binary form of S-PLUS objects.
assign("abc", 1:3) # assign "abc"assign(".Options", options, frame=0) # session dataset
assign(".Counts", counts, w=1) # to working data (even in a function)
# make up variable names in a loop for(i in 1:10) assign(paste("sample", i, sep="."), runif(10))
# save each column of matrix x under a different name for(i in seq(ncol(x))) assign(colname[i], x[,i])