KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to return a data.frame from a function if TRUE, else return NA using return(ifelse(condition, mydf, NA)) However, ifelse strips the column names from the data.frame. Why are these results different? > data.frame(1) X1 1 1 > ifelse(TRUE, data.frame(1), NA) [[1]] [1] 1 Some additional insight from dput(): > dput(ifelse(TRUE, data.frame(1), 0)) list(1) > dput(data.frame(1)) structure(list(X1 = 1), .Names = "X1", row.names = c(NA, -1L), class = "data.frame")
Tags (comma-separated)
Save Edits
Cancel