Logo Search packages:      
Sourcecode: rserve version File versions  Download package

void org::rosuda::JRclient::Rconnection::assign ( String  sym,
REXP  r 
) throws RSrvException [inline]

assign a content of a REXP to a symbol in R. The symbol is created if it doesn't exist already.

Parameters:
sym symbol name. Currently assign uses CMD_setSEXP command of Rserve, i.e. the symbol value is NOT parsed. It is the responsibility of the user to make sure that the symbol name is valid in R (recall the difference between a symbol and an expression!). In fact R will always create the symbol, but it may not be accessible (examples: "bar\nfoo" or "bar$foo").
ct contents. currently only basic types (int, double, int[], double[]) are supported.
Returns:
true on success, otherwise false

Definition at line 257 of file Rconnection.java.

References org::rosuda::JRclient::Rpacket::isOk(), and org::rosuda::JRclient::Rtalk::request().

                                                                {
            if (!connected || rt==null)
                  throw new RSrvException(this,"Not connected");
            int rl=r.getBinaryLength();
        byte[] symn=sym.getBytes();
        int sl=symn.length+1;
        if ((sl&3)>0) sl=(sl&0xfffffc)+4; // make sure the symbol length is divisible by 4
        byte[] rq=new byte[sl+rl+((rl>0xfffff0)?12:8)];
        int ic;
        for(ic=0;ic<symn.length;ic++) rq[ic+4]=symn[ic];
        while(ic<sl) { rq[ic+4]=0; ic++; }; // pad with 0
            Rtalk.setHdr(Rtalk.DT_STRING,sl,rq,0);
            Rtalk.setHdr(Rtalk.DT_SEXP,rl,rq,sl+4);
        r.getBinaryRepresentation(rq,sl+((rl>0xfffff0)?12:8));
            Rpacket rp=rt.request(Rtalk.CMD_setSEXP,rq);
            if (rp!=null && rp.isOk()) return;
        throw new RSrvException(this,"assign failed",rp);
    }


Generated by  Doxygen 1.6.0   Back to index