read csv file into Rcpp

I am a beginner to use R to call C++ code for a fast computation. My toy.csv file has 3 rows and 2 columns with the same elements as in matrix(1:6, nrow=2, ncol=2) created by R. I want to create a toy.cpp file that reads data from toy.csv and assign it to x1 which is the same matrix as defined by matrix(1:6, nrow=2, ncol=2) in R, then perform the following calculation (I use R syntax):

y=c(0,0) #initial
for(i in 1:nrow(x1) {y[i]= sum(x[i, ] * x2)}

Could someone tell me how do I write the toy.cpp code to get result y? Thanks.

If you would like help in c++ programming this is probably not the ideal forum...

Thanks for letting me know.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.