Re: [R] why data frame's logical index isnt working

2016-04-07 Thread David Winsemius
> On Apr 7, 2016, at 7:44 PM, Michael Artz wrote: > > I don't get it, I thought the double index was to indicate and individual > element within a column(vector)? Character values by themselves either quoted or not are not assumed to refer to column names unless you use `with` or `within`.

Re: [R] why data frame's logical index isnt working

2016-04-07 Thread Michael Artz
I don't get it, I thought the double index was to indicate and individual element within a column(vector)? I will stop using data.frame, thanks a lot! On Thu, Apr 7, 2016 at 9:29 PM, David Winsemius wrote: > > > On Apr 7, 2016, at 6:46 PM, Michael Artz wrote: > > > > data.frame.$columnToAdd["Cu

Re: [R] why data frame's logical index isnt working

2016-04-07 Thread David Winsemius
> On Apr 7, 2016, at 6:46 PM, Michael Artz wrote: > > data.frame.$columnToAdd["CurrentColumnName" == "ConditionMet"] <- 1 > > Can someone please explain to me why the above command gives all NAs to > columnToAdd? I thought this was possible in R to do logical expression in > the index of a dat

Re: [R] why data frame's logical index isnt working

2016-04-07 Thread Richard M. Heiberger
you probably mean something like this data.frame.$columnToAdd <- (data.frame.$CurrentColumnName == data.frame.$ConditionMet) what you did is compare two character strings. They are not the same. Therefore a new column is created with the default value NA. > tmp <- data.frame(A=1:4, B=c(1,3,4,5)

[R] why data frame's logical index isnt working

2016-04-07 Thread Michael Artz
data.frame.$columnToAdd["CurrentColumnName" == "ConditionMet"] <- 1 Can someone please explain to me why the above command gives all NAs to columnToAdd? I thought this was possible in R to do logical expression in the index of a data frame [[alternative HTML version deleted]] __