teuder / rcpp4everyone_en Goto Github PK
View Code? Open in Web Editor NEWRcpp for everyone
Home Page: https://teuder.github.io/rcpp4everyone_en/
License: The Unlicense
Rcpp for everyone
Home Page: https://teuder.github.io/rcpp4everyone_en/
License: The Unlicense
Thanks for the book a nice read (although I am at the chapter 8)
I think that on chapter 8 Vector you misues titles member and static member functions should be list. It will make it easier to read and to navigate
push_back
in this line should be push_front
.
rcpp4everyone_en/170_string.Rmd
Line 55 in 4751b38
You say "I would greatly appreciate it if you kindly give me any feedback on this document."
I'm currently reading your document and I will use some part for my Advanced R course.
Where do you want to get some feedback?
Hello Masaki,
Thanks so much for your amazing book. It tells a R user to use Rcpp without a deep dive into the c++.
In my research, I need to implement some numerical algorithms to solve the optimization problems. Rcpp is a better choice than pure R due to its effictive performance. And your book makes the features of Rcpp easy to understand. It is really a great book for the R users even without much background knowledge of C++. Therefore, I wonder if it is possible to translate it into my native language(Chinese) for the sake of more potential R users. If you are willing to grant me the permission, I will try my best to translate the book into Chinese. By the way, the project will also be hosted on the github and organized by the bookdown package for the sake of reading. Some realted examples in Chapters (such as Vector, Matrix, Rcpp Suger) will be completed.
Please kindly let me know if it is possble.
Thanks for you patience and consideration.
Jiangyu
Thanks for this awesome book. It's been my go to reference for all things Rcpp. One thing that I think that could be clarified though is the section on logical operators (chapter 11). Coming from an R background, I expected &
and |
to take and return logical values, but my code wasn't working. After a bit of digging, I learned it was because &&
and ||
are the logical operators in C++ while &
and |
are bitwise (1 is interpreted as TRUE and everything else is interpreted as FALSE).
Most people from an R background would probably be looking for the logical operators so a clarification and a table like this could be useful.
Operator | Symbol | Form | Operation |
---|---|---|---|
Logical NOT | ! |
!x |
true if x is false, or false if x is true |
Logical AND | && |
x && y |
true if both x and y are true, false otherwise |
Logical OR | || |
x || y |
true if either x or y are true, false otherwise |
Logical Operators in C++ (Source: learnCpp.com)
In https://teuder.github.io/rcpp4everyone_en/190_datetime.html the titles of getDay, getMonth, getWeekday is not formatted well. There should be a space after "###".
Thank you for the great work to introduce Rcpp to us.
Just wanted to say I really like your book! It makes Rcpp a lot less intimidating for newbies. I also learned about C++11!
I tried to clone and build this book. I faced to minute issues.
First, google_analytics.txt
-file is required. Solution: I made an empty txt file with that name, and everything worked. Maybe the actual file contains some important line.
Second in _output.yml
it says
# ...
documentclass: bxjsbook
classoption: xelatex,ja=standard
geometry: no
This is a specific LaTeX document class. It is not available on MikTex, and I've found the repo here. Solution: I commented it out, as it is not strictly necessary (I think!).
Hello Masaki,
Thanks for the bookl, it looks so cool!.
While reading your book, I recall that some packages( i.e readxl or plogr) integrate/bind C++ libraries in R. They use RapidXML C++ library and plog c++ library respectively and then wrapp in r-package. Do you know how this work is performed? How Do they include the library in a Rpackage and then How Do they implemented? . If you may create a chapter with a simple c++ library binding in R, it will be awesome.
Thanks in advance.
Omar
I am writing an R package using C++ and it took me quite a long time to really get C++11 features working.
The usual advice found via web search is (Rcpp tutorials by Eddelbuettel, your book, elsewhere) is to include a line like: // [[Rcpp::plugins(cpp11)]]
in you cpp-file and be done.
I am not sure if this is a personal problem - me and my PC - or maybe a Windows problem. But. I had to include a Makevars
and a Makevars.win
file follwoing advice from here: https://kevinushey.github.io/blog/2016/09/14/pitfalls-in-writing-portable-c++98-code/ to make it work using Rtools version 3.5.0.4 (should be not too old, right?).
In "Writing R Extensions" they state https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Using-C_002b_002b11-code:
As from version 3.6.0, R selects a default C++ compiler with options that conform as far as possible42 to C++11: this might not be possible43 and packages which do not specify ‘R (>= 3.6)’ need to explicitly require C++11, hence the rest of this section.
... furthermore ...
In order to use C++11 code in a package, the package’s Makevars file (or Makevars.win on Windows) should include the line
CXX_STD = CXX11
Compilation and linking will then be done with the C++11 compiler.
Packages without a src/Makevars or src/Makefile file may specify that they require C++11 for code in the src directory by including ‘C++11’ in the ‘SystemRequirements’ field of the DESCRIPTION file, e.g.
SystemRequirements: C++11
So, I basically think that section 5.1 is incomplete and should also advise on either adding C++11 to DESCRIPTION or adding environment variables to the makevars files.
Hi,
On page:
https://teuder.github.io/rcpp4everyone_en/220_dpqr_functions.html#exponential-distribution the R namespace signatures for the xexp functions are not correct. The R namespace version are parameterised in terms of the scale (=1/rate), not the rate.
library(Rcpp)
cppFunction('Rcpp::NumericVector rcpp_rexp_1(int n, double rate){
Rcpp::NumericVector v(n);
v = Rcpp::rexp(n, rate);
return v;
}')
cppFunction('Rcpp::NumericVector rcpp_rexp_2(int n, double scale){
Rcpp::NumericVector v(n);
for(int i = 0; i < n; i++){
v[i] = R::rexp(scale);
}
return v;
}')
set.seed(3)
t1 <- rcpp_rexp_1(1000, 0.2)
set.seed(3)
t2 <- rcpp_rexp_2(1000, 0.2)
# returns false:
identical(t1, t2)
set.seed(3)
t2 <- rcpp_rexp_2(1000, 1/0.2)
# returns true:
identical(t1, t2)
Thanks.
Hello Tsuda,
I am impressed by your book Rcpp for everyone. Thank you very much! However, I have a little confusion during reading of the book. Some of the functions in Chapter 31 R Math Library have different arguments as their counterparts in R, such as
double R::bessel_i(double x, double al, double ex)
v.s. besselI(x, nu, expon.scaled = FALSE)
. As an user, how can I use them correctly in CPP? Would it possible to offer more explanations in Chapter 31 or reference links?
Many thanks
Yanfeng Wu
Hi, thanks so much for writing this book- I've recently been working on my first project with Rcpp and it's been extremely helpful.
There are two areas where I have run into problems in my work that aren't mentioned here: one is the slightly unusual behaviour of DateVector
s and the other is the fact that template programming doesn't work as I expected.
Specifically:
DateVector
s are not vectors of Date
s, but double
s (see related SO question). This caught me out and caused some confusion. I think it would be helpful to clarify this in Chapter 16 where it currently says "Date
is a scalar type corresponding to an element of DateVector
."I have some notes put together on the first point, and a very brief paragraph on the second point. If you think these could be good additions I'm happy to put together a PR and you can take a look. If so, let me know where you think this extra info would fit in the book.
Thanks!
I find it quite useful. Any plans of updating/expanding it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.