class_docstr: The `RBasePredictor` is a thin wrapper for calling R packages.
  In order to use it you need to install R and rpy2.
  
  Note that specific R packages need to be installed, depending
  on which wrapper one needs to run.
  See `RForecastPredictor` and `RHierarchicalForecastPredictor` to know
  which packages are needed.
  
  Parameters
  ----------
  freq
      The granularity of the time series (e.g. '1H')
  prediction_length
      Number of time points to be predicted.
  period
      The period to be used (this is called `frequency` in the R forecast
      package), result to a tentative reasonable default if not specified
      (for instance 24 for hourly freq '1H')
  trunc_length
      Maximum history length to feed to the model (some models become slow
      with very long series).
  r_file_prefix
      Prefix string of the R file(s) where our forecasting wrapper methods
      can be found.
      This is to avoid loading all R files potentially having different
      implementations of the same method, thereby making sure the
      expected R method is in fact used.
class_docstr_tok: ["The","`","RBasePredictor","`","is","a","thin","wrapper","for","calling","R","packages",".","In","order","to","use","it","you","need","to","install","R","and","rpy2",".","Note","that","specific","R","packages","need","to","be","installed",",","depending","on","which","wrapper","one","needs","to","run",".","See","`","RForecastPredictor","`","and","`","RHierarchicalForecastPredictor","`","to","know","which","packages","are","needed",".","Parameters","--","--","--","--","--","freq","The","granularity","of","the","time","series","(","e.g",".","'1H","'",")","prediction_length","Number","of","time","points","to","be","predicted",".","period","The","period","to","be","used","(","this","is","called","`","frequency","`","in","the","R","forecast","package",")",",","result","to","a","tentative","reasonable","default","if","not","specified","(","for","instance","24","for","hourly","freq","'1H","'",")","trunc_length","Maximum","history","length","to","feed","to","the","model","(","some","models","become","slow","with","very","long","series",")",".","r_file_prefix","Prefix","string","of","the","R","file","(","s",")","where","our","forecasting","wrapper","methods","can","be","found",".","This","is","to","avoid","loading","all","R","files","potentially","having","different","implementations","of","the","same","method",",","thereby","making","sure","the","expected","R","method","is","in","fact","used","."]
code: def __init__(
      self,
      freq: str,
      prediction_length: int,
      period: Optional[int] = None,
      trunc_length: Optional[int] = None,
      save_info: bool = False,
      r_file_prefix: str = "",
  ) -> None:
      super().__init__(prediction_length=prediction_length)
  
      if not R_IS_INSTALLED:
          raise ImportError("R is not Installed! \n " + USAGE_MESSAGE)
  
      if not RPY2_IS_INSTALLED:
          raise ImportError(rpy2_error_message + USAGE_MESSAGE)
  
      self._robjects = robjects
      self._rinterface = rinterface
      self._rcallbacks = callbacks
      self._rinterface.initr()
      self._rpackages = rpackages
  
      this_dir = Path(__file__).resolve().parent.absolute()
      this_dir = Path(f"{this_dir}".replace("\\", "/"))  # for windows
      r_files = this_dir.rglob(f"{r_file_prefix}*.R")
  
      for r_file in r_files:
          try:
              robjects.r(f'source("{r_file}")'.replace("\\", "\\\\"))
          except RRuntimeError as er:
              raise RRuntimeError(str(er) + USAGE_MESSAGE) from er
  
      self._stats_pkg = rpackages.importr("stats")
  
      self.prediction_length = prediction_length
      self.period = (
          period if period is not None else get_seasonality(freq)
      )
      self.trunc_length = trunc_length
      self.save_info = save_info
  
file_path: gluonts/src/gluonts/ext/r_forecast/_predictor.py
imports: from pathlib import Path
  from typing import Dict, Optional, List, Iterator, Tuple
  import pandas
  from gluonts.core.component import validated
  from gluonts.dataset.common import Dataset
  from gluonts.dataset.util import forecast_start
  from gluonts.model.forecast import Forecast
  from gluonts.model.predictor import RepresentablePredictor
  from gluonts.time_feature import get_seasonality
  from subprocess import Popen, PIPE
label_desc: Use image node_id 1 to create a new RBasePredictor object from inherited base classes: RepresentablePredictor with example: obj = RBasePredictor(freq, prediction_length, period, trunc_length, save_info, r_file_prefix)