Displaying 3 results from an estimated 3 matches for "coltoadd".
2016 Apr 08
0
why data frame's logical index isnt working
...data frame
It is possible, but please execute this at a console line and then read ?"[" to see what is happening:
"CurrentColumnName" == "ConditionMet" # almost surely FALSE
Let's assume your dataframe were named 'dat'.
Perhaps you meant to write:
dat$colToAdd[ dat[["CurrentColumnName"]] == dat[["ConditionMet"]] ] <- 1
And do please stop naming your dataframes "data.frame".
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing lis...
2016 Apr 08
1
why data frame's logical index isnt working
...ecute this at a console line and then read
> ?"[" to see what is happening:
>
> "CurrentColumnName" == "ConditionMet" # almost surely FALSE
>
> Let's assume your dataframe were named 'dat'.
>
> Perhaps you meant to write:
>
> dat$colToAdd[ dat[["CurrentColumnName"]] == dat[["ConditionMet"]] ] <- 1
>
> And do please stop naming your dataframes "data.frame".
>
>
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________...
2016 Apr 08
3
why data frame's logical index isnt working
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]]