[R] Question about making array dataset inside a package

Kuhn, Max Max.Kuhn at pfizer.com
Wed Sep 5 22:23:22 CEST 2007


Please read 

  http://cran.r-project.org/doc/manuals/R-exts.html 

especially Section 1.1.3. Use save to create an Rdata file.

Max

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Wallace Hui
Sent: Wednesday, September 05, 2007 4:18 PM
To: r-help at stat.math.ethz.ch
Subject: [R] Question about making array dataset inside a package

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.

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

----------------------------------------------------------------------
LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}}



More information about the R-help mailing list