[R] Request for Help on Named Vectors

arun smartpink111 at yahoo.com
Wed May 22 19:34:50 CEST 2013


Hi,
May be this helps:
month.dayslong<-rep(31,7)
 names(month.dayslong)<- c("January","March","May","July","August","October","December")
month.dayslong
# January    March      May     July   August  October December 
 #     31       31       31       31       31       31       31 

 unname(month.dayslong)
#[1] 31 31 31 31 31 31 31
#or
 as.vector(month.dayslong)
#[1] 31 31 31 31 31 31 31
 identical(unname(month.dayslong),as.vector(month.dayslong))
#[1] TRUE
identical(unname(month.dayslong),month.dayslong)
#[1] FALSE
A.K.



>I have started learning R and have the following query : 
>
>i have a named vector like below 
>
> month.dayslong 
> January    March      May     July   August  October December 
 >     31       31       31       31       31       31       31 
>
>like the command names(months.days) giving only the names from 
the vector , is there any command which will give only the numeric 
values : like  >31 31 31 31 etc...



More information about the R-help mailing list