Skip to content

Merge two columns of a data frame

3 messages · Abraham Mathew, Ista Zahn, Ethan Brown

#
Hi Abraham,
Just take it step by step. Paste the values together, combine them,
and assign them to a data.frame column. Like this perhaps:

df.1.2.3 <- data.frame(Var1 =
	c(with(df1, paste(Var1, Var2, Var3)),
	  with(df2, paste(Var1, Var2)),
	  with(df3, paste(Var1, Var2))))

Best,
Ista
On Mon, Jun 6, 2011 at 12:22 PM, Abraham Mathew <abraham at thisorthat.com> wrote:

  
    
#
Another possibility:

dfs <- list(df1, df2, df3)
df.1.2.3 <- as.data.frame(unlist(sapply(dfs, function(x) do.call(paste, x))))
On Mon, Jun 6, 2011 at 2:37 PM, Ista Zahn <izahn at psych.rochester.edu> wrote: