[Rd] invalid operands of types ‘SEXPREC*’ and ‘R_len_t’ to binary ‘operator/’ with Rcpp.
Dear R-Developers, I just started learning how to use Rcpp. Earlier while using it, I encountered an error as shown below: file74d8254b96d4.cpp: In function Rcpp::NumericVector foo(Rcpp::NumericVector, Rcpp::NumericVector, Rcpp::NumericVector, Rcpp::Function, Rcpp::Function): file74d8254b96d4.cpp:10: error: invalid operands of types SEXPREC* and R_len_t to binary operator/ make: *** [file74d8254b96d4.o] Error 1 Below is a mock function that can reproduce this error. I wonder if anyone can tell me what is the problem here. Thank you in advance!! foo-cppFunction(' NumericVector foo(NumericVector q, NumericVector shape1, NumericVector shape2, Function pbeta, Function sequence){ NumericVector output(q.size()); output=pbeta(sequence(q.size())/q.size(), shape1, shape2); return output; } ') Best, Xiao [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Segmentation fault on Python+Rpy2+R
Hi, everyone I met a trouble, not only about R, but Python+RPy2+R When I run from rpy2 import robjects or other packages/codes, I receive Segmentation Fault inevitably like this: linux-yhwx:/ # python Python 2.7.2 (default, Aug 19 2011, 20:41:43) [GCC] on linux2 Type help, copyright, credits or license for more information. import rpy2 rpy2.__version__ '2.2.2' import rpy2.tests Segmentation fault linux-yhwx:/ # My OS on cluster is Suse family (not ubuntu or other linuxes), R is 2.15.2-devel Python 2.7.2 and RPy 2.2.2 as described above. Where can I find how this happens or deal with this segment fault? -- View this message in context: http://r.789695.n4.nabble.com/Segmentation-fault-on-Python-Rpy2-R-tp4666997.html Sent from the R devel mailing list archive at Nabble.com. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] invalid operands of types ‘SEXPREC*’ and ‘R_len_t’ to binary ‘operator/’ with Rcpp.
Please use the appropriate mailing list (Rcpp-devel) for Rcpp questions. Romain Le 14 mai 2013 à 06:42, Xiao He praguewaterme...@gmail.com a écrit : Dear R-Developers, I just started learning how to use Rcpp. Earlier while using it, I encountered an error as shown below: file74d8254b96d4.cpp: In function ‘Rcpp::NumericVector foo(Rcpp::NumericVector, Rcpp::NumericVector, Rcpp::NumericVector, Rcpp::Function, Rcpp::Function)’: file74d8254b96d4.cpp:10: error: invalid operands of types ‘SEXPREC*’ and ‘R_len_t’ to binary ‘operator/’ make: *** [file74d8254b96d4.o] Error 1 Below is a mock function that can reproduce this error. I wonder if anyone can tell me what is the problem here. Thank you in advance!! foo-cppFunction(' NumericVector foo(NumericVector q, NumericVector shape1, NumericVector shape2, Function pbeta, Function sequence){ NumericVector output(q.size()); output=pbeta(sequence(q.size())/q.size(), shape1, shape2); return output; } ') Best, Xiao [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] invalid operands of types ‘SEXPREC*’ an d ‘R_len_t’ to binary ‘operator/’ wit h Rcpp.
On 13 May 2013 at 21:42, Xiao He wrote: | Dear R-Developers, | | I just started learning how to use Rcpp. Earlier while using it, I | encountered an error as shown below: | | file74d8254b96d4.cpp: In function �Rcpp::NumericVector | foo(Rcpp::NumericVector, Rcpp::NumericVector, Rcpp::NumericVector, | Rcpp::Function, Rcpp::Function)�: | file74d8254b96d4.cpp:10: error: invalid operands of types �SEXPREC*� and | �R_len_t� to binary �operator/� | make: *** [file74d8254b96d4.o] Error 1 | | Below is a mock function that can reproduce this error. I wonder if anyone | can tell me what is the problem here. Thank you in advance!! | | foo-cppFunction(' |NumericVector foo(NumericVector q, NumericVector shape1, NumericVector | shape2, Function pbeta, Function sequence){ | NumericVector output(q.size()); | output=pbeta(sequence(q.size())/q.size(), shape1, shape2); | return output; | } | ') Really briefly: 1) Wrong mailing list. Rcpp question are to be sent to rcpp-devel 2) Possible error in your function setup. Why do you supply pbeta? What is sequence? 3) Error in how you call pbeta. The first argument is a vector, the other two are scalars. 4) Compiler error is pretty clear for once: it does not understand the division, and you only have one so look there. Here is a minimal working example: library(Rcpp) foo-cppFunction('NumericVector foo(NumericVector q, double shape1, double shape2){ return pbeta(q, shape1, shape2); }') for which I get R source('/tmp/foo.R') R foo(seq(0.1, 0.5, by=0.1), 2, 3) [1] 0.0523 0.1808 0.3483 0.5248 0.6875 Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] call R function from C code
If you are fine with another package doing the legwork for you, calling an R function from C++ is very easy: R library(Rcpp) R cppFunction('NumericVector fun(NumericMatrix X, NumericVector y, Function s) { return s(X, y); }') R set.seed(42); solve(matrix(rnorm(9),3,3), rep(1,3)) [1] -0.778649 1.553893 0.717221 R set.seed(42); fun(matrix(rnorm(9),3,3), rep(1,3), solve) [1] -0.778649 1.553893 0.717221 R So the C++ function 'fun' we created using Rcpp, and which just calls the supplied function on the first two arguments, returns us the same answer from C++ as we get when we call solve(X, y) in R. Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] invalid operands of types ‘SEXPREC*’ an d ‘R_len_t’ to binary ‘operator/’ wit h Rcpp.
Thank you! I will send my reply to Rcpp-devel from now on Re: my question -. Since I thought cppFunction() allows vectorized operations, I thought any R functions I call from R would also allow it. pbeta() within R can be specified as pbeta(runif(10), 1, 2) where the first argument is a vector. the function sequence() basically takes an integer, and produce a vector of consecutive integers starting from 1 to the provided value. Best, Xiao On Tue, May 14, 2013 at 6:39 AM, Dirk Eddelbuettel e...@debian.org wrote: On 13 May 2013 at 21:42, Xiao He wrote: | Dear R-Developers, | | I just started learning how to use Rcpp. Earlier while using it, I | encountered an error as shown below: | | file74d8254b96d4.cpp: In function Rcpp::NumericVector | foo(Rcpp::NumericVector, Rcpp::NumericVector, Rcpp::NumericVector, | Rcpp::Function, Rcpp::Function): | file74d8254b96d4.cpp:10: error: invalid operands of types SEXPREC* and | R_len_t to binary operator/ | make: *** [file74d8254b96d4.o] Error 1 | | Below is a mock function that can reproduce this error. I wonder if anyone | can tell me what is the problem here. Thank you in advance!! | | foo-cppFunction(' |NumericVector foo(NumericVector q, NumericVector shape1, NumericVector | shape2, Function pbeta, Function sequence){ | NumericVector output(q.size()); | output=pbeta(sequence(q.size())/q.size(), shape1, shape2); | return output; | } | ') Really briefly: 1) Wrong mailing list. Rcpp question are to be sent to rcpp-devel 2) Possible error in your function setup. Why do you supply pbeta? What is sequence? 3) Error in how you call pbeta. The first argument is a vector, the other two are scalars. 4) Compiler error is pretty clear for once: it does not understand the division, and you only have one so look there. Here is a minimal working example: library(Rcpp) foo-cppFunction('NumericVector foo(NumericVector q, double shape1, double shape2){ return pbeta(q, shape1, shape2); }') for which I get R source('/tmp/foo.R') R foo(seq(0.1, 0.5, by=0.1), 2, 3) [1] 0.0523 0.1808 0.3483 0.5248 0.6875 Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] invalid operands of types ‘SEXPREC*’ an d ‘R_len_t’ to binary ‘operator/’ wit h Rcpp.
On 14 May 2013 at 06:47, Xiao He wrote: | Thank you! | | I will send my reply to Rcpp-devel from now on Re: my question -. Since I | thought cppFunction() allows vectorized operations, I thought any R functions I | call from R would also allow it. pbeta() within R can be specified as pbeta | (runif(10), 1, 2) where the first argument is a vector. And of course so does the pbeta() we offer in Rcpp, and so does the example I posted below. | the function sequence() | basically takes an integer, and produce a vector of consecutive integers | starting from 1 to the provided value. Ie the same as typing 1:N ? Dirk | | Best, | Xiao | | On Tue, May 14, 2013 at 6:39 AM, Dirk Eddelbuettel e...@debian.org wrote: | | | On 13 May 2013 at 21:42, Xiao He wrote: | | Dear R-Developers, | | | | I just started learning how to use Rcpp. Earlier while using it, I | | encountered an error as shown below: | | | | file74d8254b96d4.cpp: In function ‘Rcpp::NumericVector | | foo(Rcpp::NumericVector, Rcpp::NumericVector, Rcpp::NumericVector, | | Rcpp::Function, Rcpp::Function)’: | | file74d8254b96d4.cpp:10: error: invalid operands of types ‘SEXPREC*’ | and | | ‘R_len_t’ to binary ‘operator/’ | | make: *** [file74d8254b96d4.o] Error 1 | | | | Below is a mock function that can reproduce this error. I wonder if | anyone | | can tell me what is the problem here. Thank you in advance!! | | | | foo-cppFunction(' | | NumericVector foo(NumericVector q, NumericVector shape1, | NumericVector | | shape2, Function pbeta, Function sequence){ | | NumericVector output(q.size()); | | output=pbeta(sequence(q.size())/q.size(), shape1, shape2); | | return output; | | } | | ') | | Really briefly: | | 1) Wrong mailing list. Rcpp question are to be sent to rcpp-devel | | 2) Possible error in your function setup. Why do you supply pbeta? | What is sequence? | | 3) Error in how you call pbeta. The first argument is a vector, the | other | two are scalars. | | 4) Compiler error is pretty clear for once: it does not understand the | division, and you only have one so look there. | | | Here is a minimal working example: | | library(Rcpp) | foo-cppFunction('NumericVector foo(NumericVector q, double shape1, double | shape2){ | return pbeta(q, shape1, shape2); | | | } | ') | | for which I get | | R source('/tmp/foo.R') | R foo(seq(0.1, 0.5, by=0.1), 2, 3) | [1] 0.0523 0.1808 0.3483 0.5248 0.6875 | | Dirk | | -- | Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com | | -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] problem in add1's F statistic when data contains NAs?
Shouldn't the F statistic (and p value) for the x2 term in the following calls to anova() and add1() be the same? I think anova() gets it right and add1() does not. d - data.frame(y=1:10, x1=log(1:10), x2=replace(1/(1:10), 2:3, NA)) anova(lm(y ~ x1 + x2, data=d)) Analysis of Variance Table Response: y DfSum Sq Mean SqF value Pr(F) x1 1 52.905613 52.905613 1108.61455 4.5937e-07 *** x2 1 6.355775 6.355775 133.18256 8.5678e-05 *** Residuals 5 0.238611 0.047722 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 add1(lm(y ~ x1, data=d), y ~ x1 + x2, test=F) Single term additions Model: y ~ x1 Df Sum of Sq RSS AIC F value Pr(F) none 6.5943869 2.4542182 x2 1 6.3557755 0.2386114 -22.0988844 186.45559 2.6604e-06 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Warning message: In add1.lm(lm(y ~ x1, data = d), y ~ x1 + x2, test = F) : using the 8/10 rows from a combined fit It looks like add1 is using 7 instead of 5 for the denominator degrees of freedom, 7 being the value in the original fit, before the 2 rows containing NA's in x2 were omitted. (6.355775/1) / (0.238611/5) [1] 133.1827745 (6.355775/1) / (0.238611/7) [1] 186.4558843 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Documentation request Re: [R] recode categorial vars into binary data
Hi Martin, On 05/14/2013 08:44 AM, Martin Maechler wrote: [...] PS: Are there other suggestions to help people *stop* using ifelse(A, B, C) in those many places where they should use if(A) B else C ? Or to help people stop using if (... ...) if (... | ...) in those many places where they should use if (... ...) if (... || ...) Cheers, H. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel -- Hervé Pagès Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M1-B514 P.O. Box 19024 Seattle, WA 98109-1024 E-mail: hpa...@fhcrc.org Phone: (206) 667-5791 Fax:(206) 667-1319 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel