Re: [R] Question concerning side effects of treating invalid factor levels

2022-09-20 Thread Ebert,Timothy Aaron
the numeric value to the numeric variable. Keeping in mind that a vector can only be of one class will save you many debugging hours later on. Tim -Original Message- From: Sarah Goslee Sent: Tuesday, September 20, 2022 9:02 AM To: tibor.k...@rub.de Cc: Ebert,Timothy Aaron ; r-help@r-projec

Re: [R] Question concerning side effects of treating invalid factor levels

2022-09-20 Thread Sarah Goslee
get data that has a new factor level, you need to tell R to > > expect a new factor level first. > > > > levels(f1) <- c(levels(f1),"New Level") > > levels(f1) <- c(levels(f1),c("NL1","NL2")) > > > > > > Tim > > -Or

Re: [R] Question concerning side effects of treating invalid factor levels

2022-09-20 Thread Tibor Kiss via R-help
,"New Level") > levels(f1) <- c(levels(f1),c("NL1","NL2")) > > > Tim > -Original Message- > From: R-help On Behalf Of Tibor Kiss via R-help > Sent: Monday, September 19, 2022 6:11 AM > To: r-help@r-project.org > Subject: [R] Question

Re: [R] Question concerning side effects of treating invalid factor levels

2022-09-20 Thread Tibor Kiss via R-help
Dear Eric, thank you very much. I wouldn’t have come to the idea to look up the help page for _c()_, which of course explains the coercion to the highest type. Best T. > Am 19.09.2022 um 13:31 schrieb Eric Berger : > > You are misinterpreting what is going on. > The rbind command includes

Re: [R] Question concerning side effects of treating invalid factor levels

2022-09-19 Thread Ebert,Timothy Aaron
level first. levels(f1) <- c(levels(f1),"New Level") levels(f1) <- c(levels(f1),c("NL1","NL2")) Tim -Original Message- From: R-help mailto:r-help-boun...@r-project.org>> On Behalf Of Tibor Kiss via R-help Sent: Monday, September 19, 2022 6:

Re: [R] Question concerning side effects of treating invalid factor levels

2022-09-19 Thread Ebert,Timothy Aaron
c(levels(f1),"New Level") levels(f1) <- c(levels(f1),c("NL1","NL2")) Tim -Original Message- From: R-help On Behalf Of Tibor Kiss via R-help Sent: Monday, September 19, 2022 6:11 AM To: r-help@r-project.org Subject: [R] Question concerning side effects of tre

Re: [R] Question concerning side effects of treating invalid factor levels

2022-09-19 Thread Eric Berger
You are misinterpreting what is going on. The rbind command includes c(char, char, int) which produces a character vector of length 3. This is what you are rbind-ing which changes the type of the RT column. If you do rbind(df, data.frame(P="in", ANSWER="V>N", RT=round(runif(1,7000,16000),0))) you

[R] Question concerning side effects of treating invalid factor levels

2022-09-19 Thread Tibor Kiss via R-help
Dear List members, I have tried now for several times to find out about a side effect of treating invalid factor levels, but did not find an answer. Various answers on stackexchange etc. produce the stuff that irritates me without even mentioning it. So I am asking the list (apologies if this