Running GO code from R

just like Rcpp. is there any way I can integrate golang with R. I started learning it a few months ago and I found it very easy and very fast. I don't want to reinvent the wheel by learning c++. is there a way like Rcpp by which I can call go code from R and create functions or something similar.

Please if anybody has every used anything similar let me know. and If there is any such packge I would surely appreciate that.

1 Like

I know that @romain has done a series of blog posts about Go and R:

https://romain.rbind.io/blog/2017/05/14/calling-go-from-r/

https://romain.rbind.io/blog/2017/06/09/go-packages-in-r-packages/

https://romain.rbind.io/blog/2017/07/03/go-slices/

5 Likes

The intention is eventually to make something like Rcpp for go. I need to find some way of resourcing myself to that.

In addition to the blog posts @Aurele mentioned , there are bits and pieces in that gh org. It's very basic and proofofconcepty so far, but I do believe there is space for go in R.

6 Likes

I learned programming though VBA where for loops are bad and now i am in R again for loops are bad. FIRST time in my life i found for loops so easy and fast. I loved the language. If you could implement something like rcpp many people would love it.

Go is easier thann c++ that's what everybody said. I will look into the blogs and thanks for suggestion.

@romain is there any package that can do the heavy work i mean this stuff looked too difficult to me. I haven't read it yet cause i am surei won't get it. But just as curiosity is there any

I am not aware of any. For sure, these posts explore how i might eventually tackle the internals of such a thing.

As a user, you would not typically have to know any of that.

Some day, when i get time or funding or both, Iā€™d like to make that package.

And please at least do read the articles before declaring they are too difficult. It was more difficult and time consuming to write them.

4 Likes

I am a commerce student. MBA in finance. I don't understand much about programming as the things go more technical I have tendancy to avoid it because I know I am never going to be a full fledged programmer. that's not something I meant to go into. but I understand your point as well.

Sure I will read them. I am sorry to say it was hard I could understand finding how to do it would have been a lot harder.

I think I got the answer. so far there is no direct way to write Go inside R like rcpp. In future there may be not write now for sure. thanks for your time @romain I surely appreciate that. just let us know if ever you can accomplish this thing. Golang is the future and I would surely take time to read your blogs.

From this and your other post about for loops I'd consider using data.table end to end.

fread the .csv (not xlsx), do your processing using data.table objects which I'm pretty sure execute fast because underneath the package is using either c or c++ (I'm not sure, it's one of those), and has a fast write function. All the syntax will hold together nicely through the whole process.

You could alternatively use the tidyverse stuff (which is really good), but I think a large, but still local to your desktop machine, scale processing, it is faster.

1 Like

@DaveRGP I understand that and I already use data.table but these are all xlsb files and there is nothing I can do about it. They come in mails from different people and we arrange that In a folder. and they are not perticulary in order. So before i compile them into one big file I have check the column names and column types and other stuff like that so that I can arrange it.

I am sure many people can do it much better than I do but I just wanted to know 2 things. are there any fast readymade package for for loops and if I can use my knowledge of basic golang with R.

That's all I wanted to know nothing much.

And I really appreciate you taking time to read and answer my question. Thanks a lot. We can grow together as a community if we answer each other like this. Till we are active and open R will grow exponentially. I have full faith in the Language.

I just sometime doubt my own caliber and knowledge so I ask such stupid question just to see if there is any answer to it.

but thanks for responding. R studio should create the same sort of package for at least top languages like java, c, python, ruby, rust and golang. It will help people from different background adopt the R style and write new and advance packages in different languages. I feel just being a subset of c++ is not good. But then again they have their own economics of time and resources. I don't criticize it.

I just found 2 answers there is no package for writing faster for loops in R and for integrating R with Go.

But my takeaway is also that it has a good community.

1 Like