Dear Kai
When you ask again it is best to tell us what your input is and what
output you were hoping for and what you actually got. If you can make a
small data-set which shows all that then your post will be much more
likely to get a helpful response. If you want to transfer the data-set
to
Hi Jim,
Sorry to post "same" question, because
1. I was asking to use plain text format. I have to post my question again. But
I don't know if it is working.
2. I'm a beginner for R (< 2 month). It may not easy for me to ask a "clear" R
question. My current work is to transfer my SAS code into
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"),
d=c("Bad","Good","Ba
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,
Rui
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 c
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
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
7 matches
Mail list logo