# Expand Observations in New Column Based on Two Columns

#### Morten

##### New Member
Hi

I have read a csv file using the read.table function into R. It contains a list of variables which are numeric in class.

I would like to create a new column based on two columns. Se example below, where C is my desired output.

A B C
1 4 4
2 3 3
3 4 3
2 5 4
- - 4
- - 4
- - 5
- - 5

Is there a clever way of doing this? I don't need to create any output for columns A and B, just a new columns C.
I can't seem to find a function that does this, but I did stumble across the reshape package.

#### Morten

##### New Member
I figured it out, it was just a
Code:
 rep(vector1, vector2)
formula that needed to be used.

#### Iñaki Viggers

##### New Member
Hi Morten,

Why not use cbind? It works with read.csv and maybe with read.table as well. That way you won't need the reshape package.

Regards.

#### trinker

##### ggplot2orBust
The poster answered their own question. The use of cbind does not address the poster's problem. Unless I misunderstand the problem here's an example to see what they were after:

Code:
dat <- data.frame(var1=LETTERS[1:3], var2=c(3, 5, 2))
with(dat, rep(var1, var2))