[R] data.frame question
Stephan Kolassa
Stephan.Kolassa at gmx.de
Sun Mar 7 21:13:43 CET 2010
Hi,
data.frame(x=x,y=as.numeric(x%in%y))
HTH,
Stephan
joseph schrieb:
> 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