Re: [R] R grep question

2021-05-27 Thread Jim Lemon
Hi Kai, You may find %in% easier than grep when multiple matches are needed: match_strings<-c("MLH1","MSH2") CRC<-data.frame(gene.all=c("MLH1","MSL1","MSH2","MCC3")) CRC$MMR.gene<-ifelse(CRC$gene.all %in% match_strings,"Yes","No") Composing your match strings before applying %in% may be more

Re: [R] Testing optimization solvers with equality constraints

2021-05-27 Thread Gabor Grothendieck
In case it is of interest this problem can be solved with an unconstrained optimizer, here optim, like this: proj <- function(x) x / sqrt(sum(x * x)) opt <- optim(c(0, 0, 1), function(x) f(proj(x))) proj(opt$par) ## [1] 5.388907e-09 7.071068e-01 7.071068e-01 On Fri, May 21, 2021

Re: [R] multilabel classification XGBoost and hyperparameter tuning

2021-05-27 Thread Carlos Ortega
Hello Agnes, Yes, it is true, "xgboost" is not oriented for a "multi-label" classification. "xgboost" can handle "multi-class" but not "multi-label". Bue in "mlr", you can handle "multi-class" problems although not with "xgboost" a base learner algorithm. You can see here how you can handle that

[R] foreign package read.spss() and NA levels

2021-05-27 Thread Allen, Justin
Hi All, Wanted to report what may be a bug or possibly an oversight, but I am unsure, in the "foreign" packages in the read.spss() command, https://cran.r-project.org/web/packages/foreign/index.html. When running the following code, input <- read.spss("[.sav file location]", to.data.frame =

Re: [R] multilabel classification XGBoost and hyperparameter tuning

2021-05-27 Thread Agnes g2g
Thank you for your reply. As far as I can see xgboost package does not provide multilabel classification. The mlr package uses a wrapper for xgboost, so I have used the package xgboost. But I still have the problem with the hyperparameter tuning. Did I understand you correctly? Do you have any

Re: [R] multilabel classification XGBoost and hyperparameter tuning

2021-05-27 Thread Bert Gunter
One other suggestion. Per the posting guide linked below, statistical issues such as your query on "hyperparameter tuning" are off topic on this list, as are questions about specific nonstandard packages. You might try posting on stats.stackexchange.com instead for help on such matters. Bert

Re: [R] R grep question

2021-05-27 Thread Marc Schwartz via R-help
Hi, A quick clarification: The regular expression is a single quoted character vector, not a character vector on either side of the | operator: "MLH1|MSH2" not: "MLH1"|"MSH2" The | is treated as a special character within the regular expression. See ?regex. grep(), when value = FALSE,

Re: [R] R grep question

2021-05-27 Thread Kai Yang via R-help
Hi Rui,thank you for your suggestion.  but when I try the solution, I got message below: Error in "MLH1" | "MSH2" :   operations are possible only for numeric, logical or complex types does it mean, grepl can not work on character field? Thanks,KaiOn Thursday, May 27, 2021, 01:37:58 AM

Re: [R] multilabel classification XGBoost and hyperparameter tuning

2021-05-27 Thread Bert Gunter
1. A web search on "xgboost R" brought up R package "xgboost" which you did not mention. Did you not first try a web search or did you find that it did not meet your needs? 2. Have you looked here: https://cran.r-project.org/web/views/Cluster.html or here:

[R] multilabel classification XGBoost and hyperparameter tuning

2021-05-27 Thread Agnes g2g
Hi all, I want to do multilabel classification with XGBoost and tune hyperparameters. With the mlr package this does not seem possible, see

Re: [R] Decompose df1 into another df2 based on values in df1

2021-05-27 Thread Eik Vettorazzi
A tidyverse-ish solution would be library(dplyr) library(tidyr) library(tibble) # max cols to split values into seps<-max(stringr::str_count(unlist(d1),"[/|]"))+1 d1 %>% pivot_longer(S1:S5, names_to="S") %>% mutate(value=na_if(value,"w")) %>% separate(value,"[/|]", into=LETTERS[1:seps],

Re: [R] R grep question

2021-05-27 Thread Rui Barradas
Hello, ifelse needs a logical condition, not the value. Try grepl. CRC$MMR.gene <- ifelse(grepl("MLH1"|"MSH2",CRC$gene.all), "Yes", "No") Hope this helps, Rui Barradas Às 05:29 de 27/05/21, Kai Yang via R-help escreveu: Hi List, I wrote the code to create a new variable:

Re: [R] R grep question

2021-05-27 Thread Jeff Newmiller
Post in plain text Use grepl On May 26, 2021 9:29:10 PM PDT, Kai Yang via R-help wrote: >Hi List, >I wrote the code to create a new variable: >CRC$MMR.gene<-ifelse(grep("MLH1"|"MSH2",CRC$gene.all,value=T),"Yes","No") >  > >I need to create MMR.gene column in CRC data frame, ifgene.all column

Re: [R] Testing optimization solvers with equality constraints

2021-05-27 Thread Abby Spurdle
I meant: x0 = c (1, 1e-3, 0) Not: x0 = c (1, 1e6, 0) So, large intentional error may work too. Possibly, better...? On Thu, May 27, 2021 at 6:00 PM Abby Spurdle wrote: > > If I can re-answer the original post: > There's a relatively simple solution. > (For these problems, at least). > > #wrong

Re: [R] Testing optimization solvers with equality constraints

2021-05-27 Thread Abby Spurdle
If I can re-answer the original post: There's a relatively simple solution. (For these problems, at least). #wrong x0 = c (1, 0, 0) NlcOptim::solnl(x0, objfun = f, confun = conf)$par Rdonlp2::donlp2(x0, fn = f, nlin = list(heq), nlin.lower = 0, nlin.upper = 0)$par #right x0 = c (1, 1e6, 0)