Class: Daru::IO::Importers::RDS

Inherits:
Base
  • Object
show all
Defined in:
lib/daru/io/importers/rds.rb

Overview

RDS Importer Class, that extends read_rds method to Daru::DataFrame

See Also:

Direct Known Subclasses

RData

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#optional_gem

Constructor Details

#initializeRDS

Checks for required gem dependencies of RDS Importer



13
14
15
# File 'lib/daru/io/importers/rds.rb', line 13

def initialize
  optional_gem 'rsruby'
end

Class Method Details

.read(path) ⇒ Daru::IO::Importers::RDS

Reads data from a rds file

Examples:

Reading from rds file

instance = Daru::IO::Importers::RDS.read('bc_sites.rds')

Parameters:

  • path (String)

    Path to rds file, where the dataframe is to be imported from.

Returns:



28
29
30
31
# File 'lib/daru/io/importers/rds.rb', line 28

def read(path)
  @instance = RSRuby.instance.eval_R("readRDS('#{path}')")
  self
end

Instance Method Details

#callDaru::DataFrame

Imports a Daru::DataFrame from a RDS Importer instance and rds file

Examples:

Reading from a RDS file

df = instance.call

#=> #<Daru::DataFrame(1113x25)>
#         area descriptio  epa_reach format_ver   latitude   location location_c ...
#  0      016  GSPTN             NaN        4.1       49.5    THOR IS 2MS22016 T ...
#  1      012  CSPT              NaN        4.1    50.6167    MITC BY 2MN26012 M ...
# ...     ...  ...               ...        ...       ...       ...       ...    ...

Returns:



45
46
47
# File 'lib/daru/io/importers/rds.rb', line 45

def call
  process_dataframe(@instance)
end

#read(path) ⇒ Daru::IO::Importers::RDS

Reads data from a rds file

Examples:

Reading from rds file

instance = Daru::IO::Importers::RDS.read('bc_sites.rds')

Parameters:

  • path (String)

    Path to rds file, where the dataframe is to be imported from.

Returns:



28
29
30
31
# File 'lib/daru/io/importers/rds.rb', line 28

def read(path)
  @instance = RSRuby.instance.eval_R("readRDS('#{path}')")
  self
end