Thanks for your most reasonable reply, Henrique.
- Gundala Viswanath
Jakarta - Indonesia
On Tue, Jan 13, 2009 at 8:01 PM, Henrique Dallazuanna wrote:
> Try this:
>
> unlist(ifelse(q %in% names(x), x[q], NA))
>
> On Tue, Jan 13, 2009 at 8:49 AM, Gundala Viswanath
> wrote:
>>
>> Dear all,
>>
>>
Which R version do you have? I'm asking this because my 2.7.0 gives a
different error message:
> x[[q]]
Error in x[[q]] : recursive indexing failed at level 2
Anyway, as Wacek said, x[[q]] is equivalent to
x[["some"]][["more"]][["not_there"]] -- and you don't have an element called
"more" in x[[
Wacek Kusnierczyk wrote:
>
> x[[q]] is equivalent to x[['some']][['more']][['not_there']]. since
> x[['some']] is an atomic integer vector, it won't collaborate with
> [['more']]
>
æsj, one more lousy statement. x[['some']] is an atomic *double* vector
*with no element named 'more'*, hence x[
Wacek Kusnierczyk wrote:
>
> on the side, this fails as well (guess why), though some might expect it
> should work fine:
>
> x[[c('some', 1)]]
> # expected an integer, but subscript out of bounds reported
>
>
expected a double, not an integer, of course, since the value comes from
runif.
vQ
Gundala Viswanath wrote:
> Dear all,
>
> Suppose I have a hash created with this
>
> x <- list()
> for (i in c('test', 'some', 'more')){
>x[[i]] <- runif(1)
> }
>
this is not really a hash, even though you can retrieve elements by
name, and not only by integer index.
also, try to navigate
Try this:
unlist(ifelse(q %in% names(x), x[q], NA))
On Tue, Jan 13, 2009 at 8:49 AM, Gundala Viswanath wrote:
> Dear all,
>
> Suppose I have a hash created with this
>
> x <- list()
> for (i in c('test', 'some', 'more')){
> x[[i]] <- runif(1)
> }
>
> then I want to extract the elem of that ha
Dear all,
Suppose I have a hash created with this
x <- list()
for (i in c('test', 'some', 'more')){
x[[i]] <- runif(1)
}
then I want to extract the elem of that hash with
a vector
> q <- c("some", "more", "not_there")
But why this failed?
> extracted <- x[[q]]
Error in x[[q]] : subscript
7 matches
Mail list logo