my_convert <- function(col) {
  v <- grep("[0-9]{2}.[0-9]{2}.[0-9]{4}", col);
  w <- grep("[0-9]+,[0-9]+", col)
  col2 <- col
  if (length(v) == length(col)){
    col2 <- as.Date(col, format="%d.%m.%y")
  } else if (length(w) == length(col)) {
    col2 <- as.numeric(gsub(",", "", col))
  }
  col2
}

myDf <- as.data.frame(lapply(myDf, my_convert), stringsAsFactors = FALSE)


--
GG


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to