R version 4.5.0 RC (2025-04-04 r88118 ucrt) -- "How About a Twenty-Six" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(CloneSeeker) > > new("WeightVector") An object of class "WeightVector" Slot "psi": [1] 1 > new("WeightVector", 1:3) An object of class "WeightVector" Slot "psi": [1] 0.1666667 0.3333333 0.5000000 > try( new("WeightVector", 0) ) Error in .local(.Object, ...) : At least one psi component must be larger than zero. > try( new("WeightVector", -1:3) ) Error in .local(.Object, ...) : Psi should not contain negative values. > > WeightVector(1:4) An object of class "WeightVector" Slot "psi": [1] 0.1 0.2 0.3 0.4 > try( WeightVector(0) ) Error in .local(.Object, ...) : At least one psi component must be larger than zero. > try( WeightVector(-1:3) ) Error in .local(.Object, ...) : Psi should not contain negative values. > try( WeightVector(LETTERS[1:3]) ) Error in sum(psi) : invalid 'type' (character) of argument > try( WeightVector(c(1, 2, 'a')) ) Error in sum(psi) : invalid 'type' (character) of argument > > wv <- WeightVector(4:1) > as(wv, "numeric") [1] 0.4 0.3 0.2 0.1 > > try( as.numeric(wv) ) # doesn't play well in the methods sandbox Error in as.numeric(wv) : cannot coerce type 'S4' to vector of type 'double' > > canCoerce(wv, "numeric") [1] TRUE > # bug in R core fixed in going from 3.5 to 3.6 > ifelse(getRversion() < "3.6.0", + !canCoerce(wv, "double"), # fails in older versions + canCoerce(wv, "double")) # works in newer versions [1] TRUE > > proc.time() user system elapsed 1.23 0.48 1.70