Counting toxicity character variables across multiple columns in R and maintaining that information in the dataset

I have a dataset that contains toxicity data for medications. The rows are the observations (patients) and the columns contain a type of toxicity (these are multiple columns eg. tox1, tox2, tox3...), the time it occurred, and severity.

eg.

enter image description here

focusing on say fatigue rows 4 and 5, 6,9 had fatigue listed in Tox 1 rows 7,8,10 had fatigue listed in Tox 2

I think the best way to gather this tox data will be to create a column for each toxicity

So I want to create a Fatigue column with Yes and No Response I have used this:

Dataset$Fatigue.any.grade <- ifelse(Dataset$Toxicity.1 == "Fatigue", "Yes","No")

which works fine for 1 column

but I can't do it for multiple columns,

Dataset$Fatigue.any.grade <- ifelse(Dataset$Toxicity.1|Dataset$Toxicity.2|Dataset$Toxicity.3|Dataset$Toxicity.4|Datase$Toxicity.4 == "Fatigue", "Yes","No")

Is there any way that I can create 1 toxicity column for fatigue incorporated from the 5 toxicity columns?

example of what I aim to achieve:

enter image description here



from Recent Questions - Stack Overflow https://ift.tt/3vQJirq
https://ift.tt/2ZFnVNY

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations