Questions tagged [r-s4]

One of the methods of object oriented programming in the R language.

647 questions
0
votes
2 answers

R and RMySQL, how do I get the database name of the connection?

I am accessing MySQL connections from R via RMySQL. I found a MySQL command with which to get the database/schema name SELECT DATABASE(); So I can call this via dbGetQuery() to get it from within my R scripts. However, I also found that calling…
Diego-MX
  • 2,279
  • 2
  • 20
  • 35
0
votes
2 answers

How to patch an S4 method in an R package?

If you find a bug in a package, it's usually possible to patch the problem with fixInNamespace, e.g. fixInNamespace("mean.default", "base"). For S4 methods, I'm not sure how to do it though. The method I'm looking at is in the gWidgetstcltk…
Richie Cotton
  • 118,240
  • 47
  • 247
  • 360
0
votes
2 answers

Disabling default S4 class constructors

What's the best way to enforce that an S4 object is always created with arguments, meaning that the default constructor can never be called?
rimorob
  • 624
  • 1
  • 5
  • 16
0
votes
1 answer

R S4 best practice: slot with "vector of S4 objects"

How does one correctly do the following: I have a class SpectraSet with slots parentSpectrum, childSpectra, name (to keep it simple) name is character() parentSpectrum should contain one object of class ParentSpec (so it is of type…
meow
  • 925
  • 7
  • 22
0
votes
0 answers

Rcpp implicit construction of DataFrame from S4 slot

Rcpp::DataFrame pData =pheno.slot("data") This fails on clang++ but succeeds with g++ error: conversion from 'Rcpp::SlotProxyPolicy >::SlotProxy' to 'Rcpp::DataFrame' (aka 'DataFrame_Impl') is…
Mike Jiang
  • 209
  • 1
  • 2
  • 10
0
votes
2 answers

Setting an S4 slot to function and representing a neural network layer

I am attempting to write some classes in R. Here is the start of a neural network layer class. It is generating warnings and errors that I don't know how to correct. # Slot definitions setClass( Class="neuralNetworkLayer", …
user3969377
0
votes
1 answer

Transform getter value to data frame

How can i transform getter values to data frame for example : I have a simple class (person) and it has 2 objects (name and person),if i would like to get age values, i have to do run this simple instruction "person["age"]" and i get this result …
foboss
  • 430
  • 4
  • 14
0
votes
1 answer

Using fDISFIT objects

I obtained a fit for a stable distribution using the "fBasics" package: >lstab Title: Stable Parameter Estimation Call: .qStableFit(x = x, doplot = doplot, title = title, description = description) Model: Stable Distribution Estimated…
user3083324
  • 585
  • 8
  • 23
0
votes
1 answer

delayedAssign on an S4 object slot

I would like to use delayed assign to assign a new value to a slot of an S4 object. This assignment is basically a database query, and I only want the database query to be executed when the value is actually used. But for the sake of testing this…
wligtenberg
  • 7,695
  • 3
  • 22
  • 28
0
votes
1 answer

Using `lapply` with a S4 object and a custom function with 2 arguments

I'm trying to execute my own function named myfun(x,y) on a S4 object using lapply(), but don't know if it's the appropriate way to do it. My S4 object dblist contains 3 slots and I would like to fill the empty plot df.para using my function that…
Remssssss
  • 89
  • 1
  • 9
0
votes
1 answer

Writing an S4 generic method with two arguments

I am trying to define my own S4 class with a generic method. setClass("MultiplyObject", representation(the.factor = "numeric")) # Create a new instance of a class with the "new" method multobj <- new("MultiplyObject", the.factor = 3) # Create a new…
I Like to Code
  • 7,101
  • 13
  • 38
  • 48
0
votes
1 answer

How to make correct S4 Class declaration for a package

I am creating a personal package with some S4 classes. When I run the Build and Reload button in the Rstudio IDE I get the next message. in method for ‘checkNewItems’ with signature ‘"webSource"’: no definition for class "webSource" The Class…
Usobi
  • 1,816
  • 4
  • 18
  • 25
0
votes
1 answer

Substitute From Implicit `show` Call

I need to recover the expression implicitly used to invoke a call to show from within a show method, but this only works with an explicit show call: > setClass("test", representation(a="character")) > setMethod("show", "test", function(object)…
BrodieG
  • 51,669
  • 9
  • 93
  • 146
0
votes
1 answer

S4 method with a scalar(non vector) return value

I want to define an S4 method that return a scalar return value. Here I mean by scalar value , the contrary of a vector. setGeneric("getScalar", function(value, ...) standardGeneric("getScalar") ) setMethod("getScalar", …
agstudy
  • 119,832
  • 17
  • 199
  • 261
0
votes
1 answer

Create a S4 super class - with code example

Okay, it took me a while to create a snippet of code that replicates my problem. Here it is. Notice that if you run the command new("FirstSet", id = "Input", multiplier = 2) you will get the correct answer. However, if you try to create a class…
no name
  • 245
  • 2
  • 14