Questions tagged [coerce]

73 questions
0
votes
2 answers

In Ruby, can the coerce() method know what operator it is that requires the help to coerce?

In Ruby, it seems that a lot of coerce() help can be done by def coerce(something) [self, something] end that's is, when 3 + rational is needed, Fixnum 3 doesn't know how to handle adding a Rational, so it asks Rational#coerce for help by…
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
0
votes
1 answer

In Ruby, how to implement "20 - point" and "point - 20" using coerce()?

In Ruby, the operation of point - 20 # treating it as point - (20,20) 20 - point # treating it as (20,20) - point are to be implemented. But the following code: class Point attr_accessor :x, :y def initialize(x,y) @x, @y = x, y …
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
0
votes
1 answer

Error message with a priori function in R - can not coerce list with transactions

I am new to stackoverflow so please take that into consideration when reading my question... thank you for your help. I am trying to run the a priori function in R, but get the error: cannot coerce list with transactions with duplicated names I…
MDIS
  • 1
  • 1
0
votes
1 answer

coercing numeric and then graph from matrix in R

I have a symmetrix distance matrix (x): 0 2.6096 2.3601 5.6109 2.6096 0 1.7045 6.8441 2.3601 1.7045 0 6.5946 5.6109 6.8441 6.5946 0 which I would like to analyse as a graph, in order to compute its spectral density. In…
0
votes
1 answer

Error while using optim function on likelihood equation on R

I'm a beginner to R and ran into an error while trying to use the optim function. I have a likelihood equation that I'd like to maximize, so I've implemented the following code: >datafile=read.delim("clipboard") > log.lik=function(theta, x, mu){ +…
0
votes
0 answers

Getting column vectors from a data.frame built from rbind lists

Data.frames seem to keep the underlying structure of the data, which can be inconvenient at times. In particular, I have a data.frame constructed from two lists (combined using rbind). Because the underlying list structure is maintained, this…
0
votes
1 answer

Coerce being called later than expected

Why is it that when I enter text in the textbox, the Coerce function is called after MainWindow.Float.Set is called? Upon entering text, I would have expected : OnValueCoerce -> OnValueChanged -> MainWindow.Float.Set but I get : MainWindow.Float.Set…
pastillman
  • 1,104
  • 2
  • 16
  • 27
0
votes
1 answer

Coerce a value in SASS

I am trying to do the following statement in SASS: ($value * $ratio) + "em"; I am trying to get it to compile to a result like 16em but instead am getting "16em" There appears to be a coercion function coerce(num_units, den_units), but I don't…
McShaman
  • 3,627
  • 8
  • 33
  • 46
-1
votes
1 answer

Binding Slider.Value to property and setting Value to value above Slider.Maximum will coerce it to Maximum but the ViewModel will go out of sync

Before I start to explain my problem: The Slider is just an example for the following problem. I work on a custom control, that has to do a very similar thing like the slider does here: Scenario: I have bound a Slider.Value to my ViewModel property…
Jannik
  • 2,310
  • 6
  • 32
  • 61
-1
votes
1 answer

How R automatically coerces character input to numeric?

I am training a random forest model in the randomForest package for my data. Some variables are in the class of character. I am pretty sure that randomForest will only take factor and numeric classes as input. So I think R automatically coerces the…
Ian
  • 157
  • 1
  • 7
-1
votes
1 answer

Can not merge in DT as I got Coerced double RHS to logical to

I got this error while merging 1 column from 1 df called data.all to the my working dfcalled data setDT(data)[setDT(data.all), RX_HOSP_SURG_APPR_2010 := i.RX_HOSP_SURG_APPR_2010, on=c("PUF_CASE_ID","SR_ID" )] Warning message: In…
Mohamed Rahouma
  • 1,084
  • 9
  • 20
-1
votes
1 answer

calling __coerce__() method on derived classes results in an error

My trial was like below, but it didn't work. class MyNum: def __init__(self , n): self.n = n class MyNum2(MyNum): def __coerce__(self , y): return self, y def __radd__(self, y): print 'radd called' return self.n…
shinavro
  • 1
  • 2
-2
votes
1 answer

Excel VBA: coerce information into comma separated strings

I have two excel worksheets ("Sheet1" and "Sheet2"). Sheet2 contains rawdata that I want to group and present in "Sheet1" based on ID. That is, I want to coerce 'FEED' and 'NUMB' based on ID, and store 'FEED' and 'NUMB' as comma separated strings…
user09034
  • 15
  • 6
1 2 3 4
5