Re: [R] if statement and for loop question

2021-05-30 Thread Jim Lemon
Hi Kai, You seem to be asking the same question again and again. This does not give us the warm feeling that you know what you want. testdf<-data.frame(a=c("Negative","Positive","Neutral","Random","VUS"), b=c("No","Yes","No","Maybe","Yes"), c=c("Off","On","Off","Off","On"),

Re: [R] if statement and for loop question

2021-05-30 Thread Rui Barradas
Hello, You don't need a loop, the R way is a vectorized solution and it's also clearer. Create a logical index (note only one &) and assign b, c, d where it's TRUE. i <- try$a != "Positive" & try$a != "VUS" try <- within(try, { b[i] <- '' c[i] <- '' d[i] <- '' }) Hope this helps,

Re: [R] About Pearson correlation functions

2021-05-30 Thread Mahmood Naderan-Tahan
Thanks. It seems that the differences I saw in some of my data points were related to the number of digits and rounding. Regards, Mahmood From: Bill Dunlap Sent: Sunday, May 30, 2021 7:00:52 PM To: Mahmood Naderan-Tahan Cc: r-help@r-project.org Subject: Re:

Re: [R] if statement and for loop question

2021-05-30 Thread Berry, Charles
Kai, You have made a simple mistake. And now you cannot see it. I believe this is not uncommon among programmers. It has happened to me more times than I want to recall. > On May 30, 2021, at 9:28 AM, Kai Yang via R-help wrote: > > Hello List,I have a data frame which having the character

Re: [R] About Pearson correlation functions

2021-05-30 Thread Bill Dunlap
You didn't say how the values differed. If one in the plot is a rounded version of the other then adding the ggpur::ggscatter() argument cor.coeff.args=list(digits=7) will fix things up. -Bill On Sun, May 30, 2021 at 9:18 AM Mahmood Naderan-Tahan < mahmood.nade...@ugent.be> wrote: > Hi > >

Re: [R] if statement and for loop question

2021-05-30 Thread Jeff Newmiller
Can you make R code that creates an actual sample data frame that looks like you want the answer to look? say, just using the data.frame function and literal strings. Oh, and read the Posting Guide... you need to send your email using plain text format or it may get garbled when the list strips

[R] if statement and for loop question

2021-05-30 Thread Kai Yang via R-help
Hello List,I have a data frame which having the character columns: | a1 | b1 | c1 | d1 | | a2 | b2 | c2 | d2 | | a3 | b3 | c3 | d3 | | a4 | b4 | c4 | d4 | | a5 | b5 | c5 | d5 | I need to do: if a1 not = "Positive" and not = "VUS" then values of  b1, c1 and d1 will be zero out. And do the same

[R] About Pearson correlation functions

2021-05-30 Thread Mahmood Naderan-Tahan
Hi Maybe this is not directly related to R, but I appreciate you can help me with an idea. I use the following ggscatter function to plot a Pearson correlation Coefficient and it works fine. In the chart I see both R-value and P-value. ggscatter(mydata, x = "V1", y = "V2", add =

Re: [R-es] Crear un data frame con las respuestas de texto a los exámenes... o similares

2021-05-30 Thread Emilio L. Cano
Hola Juan, Con el paquete exams puedes generar exámenes en pdf. Se puede usar para crear exámenes muy sencillos o muy complejos. Tendrás que pasar lo que tengas en texto a Rmd, pero después es muy automático. http://www.r-exams.org Emilio L. Cano