swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Swarm-Support] Subject: alternaties to inFile and outFile for ascii


From: Marcus G. Daniels
Subject: Re: [Swarm-Support] Subject: alternaties to inFile and outFile for ascii text?
Date: Tue, 10 May 2005 07:48:10 -0600
User-agent: Mozilla Thunderbird 0.9 (Windows/20041103)

Paul Johnson wrote:

Can you point me at the syntax on setting variables & arrays, possibly just an explanation of the attr settings here.

Well, I don't want to get into a tutorial on R. There are books and a user support list for R is good.

Arrays are created in R with

ary <- array(dims=c(1,2,3))

that would make a multidimensional array that is 1*2*3 and assign it to the variable "ary". Access can be complete ary[1,2,3], or partial ary[1,2,]. The latter returns a vector for the third dimension.

Vectors in R are simply:

v <- c(1,2,3)

Vectors are accessed with v[1], etc.

Finally the `attr' settings: These are hints to Swarm to tell it what data structure to use to load it. The rows of the table should get put into an (Objective C) objects of type MyClass and collected into a Swarm List. It works the same in Java.

Is there a way to just set a vector of doubles and have it read in directly?

You can save about any kind of variable using the R hdf5 module. It's more a question of how to load it in Swarm. Although one could use the HDF5 interface in Swarm to do raw loads of arrays or vectors, I'd instead suggest making minimal data-related classes that contain related arrays or whatever and then just use object serialization. You'll have more self-documenting metadata and structure in your program that way.

Or, suppose I want to insert an array of integers valued 0 and 1 and want them to come into Objective-C as BOOL.

Use "as.logical(v)" where v is your integer vector. The result when loaded into Swarm will work as an Objective C BOOL.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]