search for: catcolwise

Displaying 7 results from an estimated 7 matches for "catcolwise".

2008 Dec 16
3
Check if data frame column is numeric
Hi R-users, I want to apply a function to each column of a data frame that is numeric. Thus I tried to check it for each column first: > apply(df, 2, function(x) is.numeric(x)) A60 A64 A66a A67 A71 A75a A80 A85 A91 A95 A96 A97 A98 A99 FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
2008 Nov 03
4
How do you apply a function to each variable in a data frame?
I want to apply a more complicated function than what I use in my example, but the idea is the same: Suppose you have a data frame named x and you want to a function applied to each variable, we'll just use the quantile function for this example. I'm trying all sorts of apply functions, but not having luck. My best guess would be: sapply(x, FUN=quantile) -- View this message in
2012 Dec 18
0
R function for computing Simultaneous confidence intervals for multinomial proportions
...ata$pos<-replicate(n,sample(posl,1,prob=c(0.05,0.05,0.05,0.4,0.3,0.05,0.05,0.05)))#strong preference for z3 and z4 ##pre-treatment of the above row data, number of time (out of 21) each position was observed mydata2=ddply(mydata,.(sub,per,pos),summarize,nobs=length(pos),.drop=F) mydata2[,1:3]=catcolwise(function(x)as.factor(x))(mydata2) summary(mydata2) # boxplot of frequencies of occpupancy require(ggplot2) mydata2$fobs=mydata2$nobs/21 ggplot(mydata2)+geom_boxplot(aes(pos,fobs)) ###chi2 test nobsT=ddply(mydata,.(pos),summarize,T=length(pos)) nobsT=nobsT[,2] chisq.test(nobsT) ##################...
2012 Dec 06
1
Fitting a multinomial model to a multi-way factorial design with repeated measures: help on package and syntax
...te(n,sample(posl,1,prob=c(0.3,0.4,0.05,0.05,0.05,0.05,0.05,0.05)))#strong preference for z1 and z2 summary(mydata) # number of time (out of 21) each position was observed, given hab, pre, sub and per mydata2=ddply(mydata,.(hab,pre,sub,per,pos),summarize,nobs=length(pos),.drop=F) mydata2[,1:5]=catcolwise(function(x)as.factor(x))(mydata2) summary(mydata2) # boxplot of frequencies of occpupancy require(ggplot2) ggplot(mydata2)+geom_boxplot(aes(pos,I(100*nobs/21)))+facet_grid(pre~hab) [[alternative HTML version deleted]]
2013 Feb 16
6
Extracting Numeric Columns from Data Fram
Hello, I've got a data frame with a mix of numeric, integer and factor columns. I'd like to pull out (or just operate only on) the numeric/integer columns. Every thing I've found in searches is about how to subset by rows, or how to operate assuming you have the column names.  I'd like to pull by type. Thanks! Barry [[alternative HTML version deleted]]
2010 Jan 04
4
function in aggregate applied to specific columns only
I want to use aggregate with the mean function on specific columns gender <- factor(c("m", "m", "f", "f", "m")) student <- c(0001, 0002, 0003, 0003, 0001) score <- c(50, 60, 70, 65, 60) basicSub <- data.frame(student, gender, score) basicSubMean <- aggregate(basicSub, by=list(basicSub$student), FUN=mean, na.rm=TRUE) This
2009 Jun 23
4
Apply as.factor (or as.numeric etc) to multiple columns
Hi R-helpers, I have a dataframe with 60columns and I would like to convert several columns to factor, others to numeric, and yet others to dates. Rather than having 60 lines like this: data$Var1<-as.factor(data$Var1) I wonder if it's possible to write one line of code (per data type, e.g. factor) that would apply a function (e.g., as.factor) to several (non-contiguous) columns. So, I