Hello everyone, Below is a metadata summary of raw data in a data frame (which itself is a data frame). I want to add 2 columns to the data frame below that will contain the min and max for integer and numeric class columns and NA for factors and character vectors. Can anyone suggestion the most succinct way of going about this?
Variable Class Mode 1 id integer numeric 2 x1 numeric numeric 3 x2 numeric numeric 4 x3 numeric numeric 5 y numeric numeric 6 gender factor numeric 7 char1 factor numeric I have the following, but it does not work: x.contents.3<-data.frame(id=1:ncol(x),Min=NA,Max=NA,row.names="id") x.contents.3[!(x.contents.2$Class("factor","character")),1]<-sapply(x,min) x.contents.3[!(x.contents.2$Class("factor","character")),2]<-sapply(x,max) === I receive the following: > x.contents.3<-data.frame(id=1:ncol(x),Min=NA,Max=NA,row.names="id") > x.contents.3[!(x.contents.2$Class("factor","character")),1]<-sapply(x,min) Error in Summary.factor(c(1L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, : min not meaningful for factors > x.contents.3[!(x.contents.2$Class("factor","character")),2]<-sapply(x,max) Error in Summary.factor(c(1L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, : max not meaningful for factors Thanks! Dan [[alternative HTML version deleted]] ______________________________________________ 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.