Thanks toy Jim and Michael for their response. The suggestion to use regular
if/else was spot on.
> From: tyler_rin...@hotmail.com
> To: r-help@r-project.org
> Date: Sat, 30 Jul 2011 01:48:21 -0400
> Subject: [R] ifelse returns
>
>
> Greetings R Community,
>
> I
So the thing is this, ifelse puts together a vector elementwise from two
other vectors (or other things, but vectors is vague enough for now) based
on a series of T/F values: you only put in one logical test, so you only get
a vector of length 1 back, here MODE1[1]=4. It seems like a regular if/els
You might want to breakdown some of the expressions you are using; for example:
> x<-c(2,3,4,4,5,5,6,6,8,10)
>
> df<-as.data.frame(table(x))
> df<-df[order(df$Freq),]
> m<-max(df$Freq)
> (MODE1<-as.vector(as.numeric(as.character(subset(df,Freq==m)[,1]
[1] 4 5 6
> ifelse(sum(df$Freq)/length(df$
Greetings R Community,
I am working with the ifelse function and it is returning something unexpected.
In the code the line with the MODE1 assignment the output is a vector [1] 4 5
6 but when I put the MODE1 object into the ifelse function [R}'s output for
MODE1 is the first number from the
4 matches
Mail list logo