Hi, May be this helps: set.seed(445) dat1 <- as.data.frame(matrix(sample(seq(2,4,by=0.5),80,replace=TRUE),ncol=20),stringsAsFactors=FALSE) dat1[dat1==2] <- "" dat1[,sapply(dat1,is.character)] <- lapply(dat1[,sapply(dat1,is.character)] ,as.numeric) identical(sum(sapply(dat1,is.numeric)), ncol(dat1)) #[1] TRUE A.K.
Hi All, I have a dataframe with 100 columns. In some of the columns, the values are of type CHAR. I wanted to do type conversion for the whole table, wherever I find the values to be char into Num. Regards, Praveen ______________________________________________ R-help@r-project.org mailing list 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.