Re: [Rcpp-devel] Returning an element from a List with its attributes?

2013-08-20 Thread Kevin Ushey
Hi Tal, In your example, note that x[[1]] is not a list; hence it must first be coerced to a list, and attributes are lost in this conversion. This is fairly standard in R code; eg x <- 1; attr(x, "animal") <- "cat"; x; as.list(x), so you can't blame Rcpp for being consistent with R here. The onu

Re: [Rcpp-devel] Returning an element from a List with its attributes?

2013-08-20 Thread Tal Galili
Dear Wush and others, Just to followup and say I've used this idea here: https://github.com/talgalili/dendextendRcpp/blob/master/src/cut_lower.cpp In general, it would have been better for me, where it possible to do some (or all) of the things below: 1) Get the length of a List 2) Change the attr

Re: [Rcpp-devel] Rcpp build trouble with strings

2013-08-20 Thread jacob.a.russell.th
Hey Dirk, I know that linking to a shared library is not enough, and that I need to runtime load the actual libraries that have their shared code stored separately. I wanted to do this in a way that when loaded by someone who installs the package, the shared libraries that I am including are avail

Re: [Rcpp-devel] Returning an element from a List with its attributes?

2013-08-20 Thread Tal Galili
Hello Wush, Indeed, thank you! I will write more on this after I finish the code, since there are some bits which are a mystery to me. Tal Contact Details:--- Contact me: tal.gal...@gmail.com | Read me: www.talgalili.com (Hebre

Re: [Rcpp-devel] Returning an element from a List with its attributes?

2013-08-20 Thread Wush Wu
Hi Tal, ``` cppFunction(' std::vector temp2_fail(RObject x){ std::vector lower; List x_list(wrap(x)); int n = x_list.size(); lower.push_back(x); return(lower) ; } ') ``` Is this what you want? 2013/8/20 Tal Galili > Dear list members, > > I would like to be able to

[Rcpp-devel] Returning an element from a List with its attributes?

2013-08-20 Thread Tal Galili
Dear list members, I would like to be able to get an element pushed with its attributes, and I came across the following problem: cppFunction(' std::vector temp(List x){ std::vector lower; lower.push_back(x); return(lower) ; } ') x = list(structure(1L, animal = "cat")) temp(