[R] Error using Rcpp under windows xp
Hi, I am a newbie to Rcpp packages, and got problems in having basic set-ups for Rcpp under windows xp. Here is the list I have done. 1) installed Rtools and have no problem in compiling .c file. 2) installed Rcpp packages 3) set enviroment variables 'path' to make C:\Program Files\R\R-2.12.0\library\Rcpp\include\ searchable The sample C++ code I used is from the original website: http://dirk.eddelbuettel.com/code/rcpp.examples.html #include RcppExport SEXP newRcppVectorExample(SEXP vector) { Rcpp::NumericVector orig(vector); // keep a copy (as the classic version does) Rcpp::NumericVector vec(orig.size()); // create a target vector of the same size // we could query size via // int n = vec.size(); // and loop over the vector, but using the STL is so much nicer // so we use a STL transform() algorithm on each element std::transform(orig.begin(), orig.end(), vec.begin(), sqrt); Rcpp::Pairlist res(Rcpp::Named( "result", vec), Rcpp::Named( "original", orig)); return res; } I got bunch of error messages like: test.o:test.cpp:(.test+0x141): undefined reference to 'RcppResultSet::RcppResultSet()' ... undefined reference to 'double* Rcpp::internal::r_vector_start<14,double>(SEXPREC*)' collect2: ld returned 1 exit status Can someone help me out? Thanks, -- View this message in context: http://r.789695.n4.nabble.com/Error-using-Rcpp-under-windows-xp-tp3070578p3070578.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] Pass an operator to function
Thanks, that helps. -- View this message in context: http://r.789695.n4.nabble.com/Pass-an-operator-to-function-tp3066627p3066696.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
[R] Pass an operator to function
Hi guys, How to pass an operator to a function. For example, test <- function(a, ">", b) { return(a>b) #the operator is passed as an argument } Thanks, -- View this message in context: http://r.789695.n4.nabble.com/Pass-an-operator-to-function-tp3066627p3066627.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
Re: [R] help: program efficiency
Thanks guys, the "rle" function works pretty well. Thank you all for the efforts. Zheng -- View this message in context: http://r.789695.n4.nabble.com/help-program-efficiency-tp3059079p3061103.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
[R] help: program efficiency
hey guys, I am working on a function to make a duplicated value unique. For example, the original vector would be like : a = c(2,1,1,3,3,3,4) I'll like to transform it into: a.nodup = 2, 1.01, 1.02, 3.01, 3.02, 3.03, 4 basically, find the duplicates and assign a unique value by adding a small amount and keep it in order. I come up with the following codes, but it runs slow if t is large. Is there a better way to do it? nodup = function(t) { t.index=0 t.dup=duplicated(t) for (i in 2:length(t)) { if (t.dup[i]==T) t.index=t.index+0.01 else t.index=0 t[i]=t[i]+t.index } return(t) } -- View this message in context: http://r.789695.n4.nabble.com/help-program-efficiency-tp3059079p3059079.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.