s-news
[Top] [All Lists]

another problem with names

To: "S-PLUS Newsgroup (E-mail)" <s-news@lists.biostat.wustl.edu>
Subject: another problem with names
From: "Winifred Lambert" <winnie@ccb.ensco.com>
Date: Mon, 11 Dec 2000 14:36:44 -0500
S-PLUS 2000 Windows 2000

I'm having another problem with names.  I have a script that loops
through 3 levels and calculates some basic statistics - 7 values in all
for 24 hours in a day.  I want all the stats for one level to be output
to one matrix.  I create an output matrix name variable in the script
using the following:

stats <- paste("Indep", level, "2H", "stat", sep=".")

looping on the variable 'level'.

I then create the matrix with the necessary dimensions using

assign(stats, matrix(nrow=24, ncol=7))

I now want to name the rows and columns.  I have these names stored in
the character vectors statnames (7) and TIME (24):

> statnames
[1] "POD.obs" "POD.erf" "FAR.obs" "FAR.erf" "B.obs"   "B.erf"   "Skill"

> TIME
 [1] "00Z" "01Z" "02Z" "03Z" "04Z" "05Z" "06Z" "07Z" "08Z" "09Z" "10Z"
"11Z" "12Z" "13Z" "14Z" "15Z" "16Z" "17Z"
[19] "18Z" "19Z" "20Z" "21Z" "22Z" "23Z"

I can insert the names when I use the explicit file name for the matrix,
e.g. for level=10,

dimnames(Indep.10.2H.stat) <- list(TIME, statnames)

but I cannot get it to work using the variable 'stats', e.g.

dimnames(get(stats)) <- list(TIME, statnames) ....get() cannot be on the
LHS

With this command:
> assign(dimnames(stats), list(TIME, statnames))
I got the error:
Error in assign.default: No data to interpret as a character string: #
NULL

And with this command:
> assign(dimnames(get(stats)), list(TIME, statnames))
I got the error:
Error in assign.default: object of mode list and length 2 used as string
value: list(..

It seems like I cannot name the matrix rows and columns using the matrix
name variable.  I really need to use this variable in the script so I
can automate the process.  Is there something else I can try?  Thanks
much...

*************************************************
Winifred C. Lambert            Senior Scientist/Meteorologist
ENSCO, Inc.
Aerospace Sciences and Engineering Division
1980 N Atlantic Ave, Suite 230
Cocoa Beach, FL  32931
VOICE:  321.853.8130           FAX:  321.853.8415
lambert.winifred@ensco.com <mailto:lambert.winifred@ensco.com> 
 
AMU Quarterly Reports on the Web:
http://technology.ksc.nasa.gov/WWWaccess/AMU/home.html 
*************************************************
 


<Prev in Thread] Current Thread [Next in Thread>
  • another problem with names, Winifred Lambert <=