Dear List, I have an atomic vector named "Results" Results [1] 1 1 1 attr(,"prob") [1] 0.6666667 1.0000000 1.0000000 Levels: 0 1 when I type attributes(Results) $levels [1] "0" "1" $class [1] "factor" $prob [1] 0.6666667 1.0000000 1.0000000 However, when I type Results$prob It has the following warning message: NULL Warning message: In Results$prob : $ operator is invalid for atomic vectors, returning NULL I've been doing some search and seems that this question was asked by someone before and I can not seem to find a solution to extract the value from the atomic vector, could somebody help me with this? Thanks a lot! Jack [[alternative HTML version deleted]]
jim holtman
2008-Jan-10 03:35 UTC
[R] question on how to extract values from atomic vector
There are a couple of ways of getting the values:> x <- cbind(a=1:3, pi=pi) # simple matrix w/ dimnames > attributes(x)$dim [1] 3 2 $dimnames $dimnames[[1]] NULL $dimnames[[2]] [1] "a" "pi"> attributes(x)$dim[1] 3 2> attr(x, 'dim')[1] 3 2>So in your case, attr(Results, 'prob') or attributes(Results)$prob On Jan 9, 2008 10:12 PM, Jack Luo <jluo.rhelp at gmail.com> wrote:> Dear List, > > I have an atomic vector named "Results" > > Results > [1] 1 1 1 > attr(,"prob") > [1] 0.6666667 1.0000000 1.0000000 > Levels: 0 1 > > when I type > > attributes(Results) > $levels > [1] "0" "1" > > $class > [1] "factor" > > $prob > [1] 0.6666667 1.0000000 1.0000000 > > However, when I type > Results$prob > > It has the following warning message: > > NULL > Warning message: > In Results$prob : $ operator is invalid for atomic vectors, returning NULL > > I've been doing some search and seems that this question was asked by > someone before and I can not seem to find a solution to extract the value > from the atomic vector, could somebody help me with this? > > Thanks a lot! > > Jack > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?