[R] Variable names conflict

Giorgio Garziano giorgio.garziano at ericsson.com
Thu Oct 15 19:52:29 CEST 2015


May this be fine ?

foo <- function(df) {
  x <- df[, 1, drop = FALSE]
  available <- rev(letters[(letters %in% colnames(df)) == FALSE])
  colnames(x) <- available[1]
  dfOut <- data.frame(df, x)
  dfOut
}

Data <- data.frame(x = c(1, 2), y = c(3, 4))
foo(Data)

  x y z
1 1 3 1
2 2 4 2

--
GG



	[[alternative HTML version deleted]]



More information about the R-help mailing list