[R] Question about making array dataset inside a package

Wallace Hui wlwhui at student.math.uwaterloo.ca
Wed Sep 5 22:18:26 CEST 2007


Hello

I have a question about how I can include an array dataset inside a  
package. In our package, one R function is designed to take an array  
of 2 rows * 2 columns * k levels as input data enter by the user,  
where k is positive integers. I am trying to include a 3-D array of  
2-by-2-by-8 as dataset in the package, so users can load the data  
using data(dataname). We prefer to load the data as dataset, rather  
than include the long syntax in the help file for users to copy and  
paste. I can generate array in R console using long chain of syntax  
like:   > arraydat=array(.....omitted.......)

However, I cannot figure a way to save the data in 3D array data frame format
using write(), write.table(), or use data.frame() etc. If I directly  
copy-paste the screen output to a text file. I cannot read it into R  
using like:

> arraydat=read.table("array.txt", header=TRUE)

This will give me a 2 rows by (2*k) columns two-dimension data set,  
and lost all level (or depth) structure for the purpose of our R  
function. The header is messed too.

I appreciate if any expert can tell me how to include/save array  
stucture in dataset in R, and also how to read it into R to preserve  
the header and array structure.

Thank you for your time.



More information about the R-help mailing list