Code Monkey home page Code Monkey logo

rcpp4everyone_en's People

Contributors

ben519 avatar chrismuir avatar cove avatar dmedri avatar lewinfox avatar marimeireles avatar pegeler avatar renkun-ken avatar teuder avatar zauster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rcpp4everyone_en's Issues

Use lists instead of titles on chapter 8

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

Where to give feedback?

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?

Translation permission

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

Logical Operator Clarification

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)

This is a great book!

Just wanted to say I really like your book! It makes Rcpp a lot less intimidating for newbies. I also learned about C++11!

Issues when rendering the book

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!).

Example of integrate a c++ library in R

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

Enabling C++11 (chapter 5.1)

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.

Incorrect specification for parameterisation of R::rexp

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.

Requesting further explanation of functions in Chapter 31 R Math Library

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

Add additional material discussing DateVectors and C++ templates?

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 DateVectors and the other is the fact that template programming doesn't work as I expected.

Specifically:

  • DateVectors are not vectors of Dates, but doubles (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."
  • Template programming requires some extra boilerplate in Rcpp, as per this Rcpp Gallery example.

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.