s-news
[Top] [All Lists]

Re: names function in base package

To: s-news@lists.biostat.wustl.edu
Subject: Re: names function in base package
From: Robert A LaBudde <ral@lcfltd.com>
Date: Sat, 21 Jul 2007 15:05:05 -0400
In-reply-to: <313490.61655.qm@web62012.mail.re1.yahoo.com>
References: <462C66080003E0BE@hawk.dcu.ie> <313490.61655.qm@web62012.mail.re1.yahoo.com>
At 02:36 PM 7/21/2007, Carol wrote:
Hi,
How to name the attributes of an object by name function? Why do I get err msg?

thanks

 x = c(1,2,3,4)
> names(x) = LETTERS[1:4]
Error in "names<-"(`*tmp*`, value = c("A", "B", "C", "D")) :
        no applicable method for "names<-"

names(x) has to be a list of 4 strings.

LETTERS[1:4] is a single string 4 characters long.

Try

names(x)<- c('a','b','c','d')

================================================================
Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: ral@lcfltd.com
Least Cost Formulations, Ltd.            URL: http://lcfltd.com/
824 Timberlake Drive                     Tel: 757-467-0954
Virginia Beach, VA 23464-3239            Fax: 757-467-2947

"Vere scire est per causas scire"
================================================================


<Prev in Thread] Current Thread [Next in Thread>