Reputation: 103
The code below is my attempt at a function to change the data table in x. The data table x has columns named MutationStatus and disease. When I plug x as the data table and y as the string within the disease column manually, the function works, however plugging it as a function does not.
diseaseMutation <- function(x,y) {
x$MutationStatus[x$disease != y] = "WT"
x$disease[x$disease != y] = y
}
Upvotes: 1
Views: 41
Reputation: 887148
We need to return the 'x'
diseaseMutation <- function(x,y) {
x$MutationStatus[x$disease != y] = "WT"
x$disease[x$disease != y] = y
x
}
Upvotes: 1