Reproducible example not provided... try this -- it should generalize to multiple columns:
EU <- c("UK","FR","DE") # Yes, I know there are more.... countries <- data.frame( country1 = c("US","CH","UK","AU"), country2 = c( "CA", "MX", "FR", "DE"), stringsAsFactors = FALSE) cbind(countries, EU.Membership = Reduce(`&`, lapply(countries, function(x) x %in% EU))) Michael On Tue, Apr 17, 2012 at 1:24 PM, phillip03 <phillipbrig...@hotmail.com> wrote: > Hi Michael > > Sorry it is a data frame where to of the columns are 22 countries arranged > in random. I now want to add and ekstra column that is 1 if the country par > for the specific row is both european countries and 0 if not. > > Regards > > -- > View this message in context: > http://r.789695.n4.nabble.com/How-to-add-specific-column-to-data-set-tp4565341p4565466.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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. ______________________________________________ R-help@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.