[R] data.frame question
baptiste auguie
baptiste.auguie at googlemail.com
Sun Mar 7 21:13:54 CET 2010
Hi,
try this,
data.frame(x,as.numeric(x %in% y))
HTH,
baptiste
On 7 March 2010 21:06, joseph <jdsandjd at yahoo.com> wrote:
> hello
>
> can you show me how to create a data.frame from two factors x and y. column 1 should be equal to x and column 2 is 1 if it is common to y and 0 if it is not.
>
> x=factor(c("A","B","C","D","E","F","G"))
> y=factor(c("B","C","G"))
>
> the output should look like this:
> A 0
> B 1
> C 1
> D 0
> E 0
> F 0
> G 1
>
> Thanks
> Joseph Dhahbi
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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