[R] vector access

Joshua Wiley jwiley.psych at gmail.com
Fri Oct 8 22:26:04 CEST 2010


Dear Xin,

You really provided great information!  You can use the function,
names().  Here is an example:

# mimic your data
a <- c("ae21" = 1.863869)
a
names(a)
# the result should be
> names(a)
[1] "ae21"

Hope that helps, and thanks for making it easy to answer,

Josh

On Fri, Oct 8, 2010 at 11:07 AM, Xgong <xingong98 at gmail.com> wrote:
>
> Hi,
>
> I have a question about vector access. sorry if it is too basic.
>
>> a
> ae21
>    1.863869
>
> My question is how to retrieve "ae21" from vector "a". here is some other
> information you might need.
>
>> str(a)
>  Named num 1.86
>  - attr(*, "names")= chr"ae21"
>> class(a)
> [1] "numeric"
>> is.vector(a)
> [1] TRUE
>> a[[1]]
> [1] 1.863869
>
> Thank you in advance for your help!
>
> Xin
> --
> View this message in context: http://r.789695.n4.nabble.com/vector-access-tp2968825p2968825.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org 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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/



More information about the R-help mailing list