1

I want to write R script class like java or c++ programming language. But, I didn't find any example. Here is the main structure of a class in java or c++:

Myclass{

  param1
  param2
  ...

  Constructor(...){
    .
    . 
    .
  }

  function1(...){
    .
    . 
    .
  }

  function2(...){
    .
    . 
    .
  }

  .
  . 
  .
}

Is it possible to create a class like the above? Can anyone show me an example?

mohammad
  • 175
  • 2
  • 13
  • 1
    Honestly R's object-oriented programming options are too involved for a simple answer to make sense in a forum like this. There are several "OOP" schemes in R, and they all work differently. I would read [Part III of Hadley Wickham's Advanced R](https://adv-r.hadley.nz/oo.html), then come back to Stack Overflow and ask a specific question if you're still having trouble after that. – duckmayr Oct 04 '19 at 12:06
  • See `?ReferenceClasses`. – nicola Oct 04 '19 at 12:16
  • Adding to the other comments. Reference classes or R6 classes are the way to go. – Oliver Oct 04 '19 at 14:58

0 Answers0