Conditionally creating a new column
问题 I am fairly certain this is a really obvious question, but I can't figure it out. Lets say I have the following dataset: test <- data.frame(A = c(1:10), B = c(1:10), C = c(1:10), P = c(1:10)) And I want to test, if there is a column called "P", create a new column called "Z" and put some content in it calculated from P. I wrote the following code (just to try and get it to conditionally create the column, I've not tried to get it to do anything with that yet!): Clean <- function(data) { if("P