Questions tagged [coerce]

73 questions
0
votes
0 answers

Error in as.vector(x, mode) : cannot coerce type 'closure' to vector of type 'any'

library(dplyr) dend1 <- df %>% dist %>% hclust("complete") %>% as.dendrogram Error in as.vector(x, mode) : cannot coerce type 'closure' to vector of type 'any' Why is this error popping out? Thanks I have tried multiple ways but couldn't…
Nanda
  • 1
0
votes
3 answers

How to use replace function for setAs() in R?

I am trying to define a coerce method in R including a replace function. Unfortunately, neither the documentation of setAs() nor further discussions on the internet clarify the way how to use the parameter replace in this function. My target is to…
Miguel Alvarez
  • 314
  • 2
  • 11
0
votes
2 answers

Cannot coerce string to boolean in mule4

Getting cannot coerce string to boolean error when running the below expression in mule4 vars.userId != null and (vars.page != null and vars.page contains ('Redeem')) or (vars.actionName != null and vars.actionName contains ('Redeem')) This is the…
0
votes
1 answer

True isomorphisms in Haskell

Are the following assertions true: The only real isomorphism, accessible programatically to the user, verified by Haskell type system, and that the Haskell compiler is/can be made aware of, is between: the set of values of a Haskell datatype the…
nicolas
  • 9,549
  • 3
  • 39
  • 83
0
votes
1 answer

Python: Cerberus coerce field when not empty

I would like to allow a field to be empty, but when it is not empty I want it to be Integer and range checked. I will need to coerce the field, when not empty, to int because it comes in as string. Is there a way to do this? My approach is below but…
K Venner
  • 11
  • 2
0
votes
2 answers

how to regularize numeric/non-numeric entries in pandas dataframes

I want to control for non-numeric entries in my pandas dataframe. Say I have the following: >>> df col_1 col_2 col_3 0 0.01 NaN 0.1 1 NaN 0.9 0.2 2 0.01 NaN 0.3 3 0.01 0.9 0.4 I can take the row-means as…
Jabber1
  • 69
  • 5
0
votes
1 answer

Pandas: checking invalid values in to_datetime function

im trying to convert string into datetype using: df.apply(pd.to_datetime) that throws: ('month must be in 1..12', 'occurred at index 'my_column') Adding errors='coerce' fixes problem df.apply(pd.to_datetime, errors='coerce') But is there any way…
jabba
  • 503
  • 2
  • 6
  • 14
0
votes
1 answer

Cerberus coercion within nested list

I get unexpected behaviour for the following code: import cerberus v = cerberus.Validator() schema = {'list_of_values': {'type': 'list', 'schema': {'items': [{'type': 'string', 'coerce': str}, …
0
votes
1 answer

define R objects in a list based on column names in a dataframe

I have a data frame df with column names x1, x2, x3, etc. df <- data.frame(x1 = rnorm(100), x2=rnorm(100),x3=rnorm(100)) I would like to create an R object that is a list that looks like: my.list <- list(y, N = length(y), x1 = x1, …
colin
  • 2,606
  • 4
  • 27
  • 57
0
votes
2 answers

Is it possible to coerce NAs into logicals in R?

I'm trying to do sorting for something like this: State Value AK 1 WA 3 LA NA AK NA OR 1 DL 1 and then try to find say the state of rank 2. If I sort by the order of "Value", it'd…
Calvin Ku
  • 111
  • 2
  • 7
0
votes
0 answers

Prevent WPF local value coercion behavior

I created a slider WPF CustomControl and have been surprised about a coercion behavior. My Min DP coerces Max & Value My Max DP coerces Min & Value If my Min is 0, My Value 0 and Max is 100, if I change Min to 1 the Value also changes to 1. Ok,…
nkoniishvt
  • 2,442
  • 1
  • 14
  • 29
0
votes
1 answer

Coercing List of List Individual Elements to Vector Type

I'm using the permn function from CRAN package combinat to produce a list of lists composed of all the permutations of a range of numbers as follows x <- str(permn(3)) x List of 6 $ : int [1:3] 1 2 3 $ : int [1:3] 1 3 2 $ : int [1:3] 3 1 2 $ : int…
Zediiiii
  • 750
  • 1
  • 7
  • 21
0
votes
0 answers

coercing values in R

I have a text file with email id's which I am reading into R (example 1). Sometimes the field is blank (example 2). example 1: To: admin@naukrioverseas.com example 2: To: I am using the following code to read the data: to <- grep(a, pattern =…
Apricot
  • 2,925
  • 5
  • 42
  • 88
0
votes
2 answers

writing a ".rtest" output to file, using the R program (ex) via write.table?

I am using R to open up some saved .csv files in a particular pairwise manner and perform a statistical test (mantel.rtest, found in the package "ade4"). The .csv files are sequentially named as either "fileAX" or "fileBY", where X and Y are…
user393200
  • 43
  • 1
  • 6
0
votes
0 answers

override pandas datetime conversion where coerce=True does not

I must have a mistaken date in my data, but I would rather just proceed setting this to missing. However, my attempt at coercing this failed, and I see no other option. What is there to do? The relevant line is: all_treatments['date'] =…
László
  • 3,914
  • 8
  • 34
  • 49