[R] filter and add a column

Ana Marija @okov|c@@n@m@r|j@ @end|ng |rom gm@||@com
Tue Aug 6 20:42:29 CEST 2019


Hi Patrick,

yes both controls and tot have "eid" column, please see attached

Can you please tell em what means to post in "plain text" ?

Thanks
Ana

On Tue, Aug 6, 2019 at 1:33 PM Patrick (Malone Quantitative) <
malone using malonequantitative.com> wrote:

> Do you have some kind of ID variable? If so, it should be
> straightforward with the appropriate joining function.
>
> What have you tried?
>
> Also, please post in plain text.
>
>
> On Tue, Aug 6, 2019 at 2:16 PM Ana Marija <sokovic.anamarija using gmail.com>
> wrote:
> >
> > Hello,
> >
> > I am filtering my data frame "tot" via:
> >
> > controls=tot %>% filter_all(any_vars(. %in% c("E109", "E119","E149")))
> %>%
> > filter_all(any_vars(. %in% c("Caucasian"))) %>% filter_all(any_vars(.
> %in%
> > c("No kinship found","Ten or more third-degree relatives identified")))
> >
> > > dim(controls)
> > [1] 15381  1093
> > > dim(tot)
> > [1] 502536   1093
> >
> > how do I add in my data frame "tot" a new column called "controls" where
> > every of those filtered 15381 rows would have the value 1 and the rest
> > which can be found in tot have the value -9?
> >
> > Thanks
> > Ana
> >
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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.
>


More information about the R-help mailing list