-1

I have a data frame allData that has 3 columns,and a data frame userData with 1 column.that every row of all data refers to a row of user data.

now I want to add userData column to my allData data frame.but I cant.

I tried some codes Like :

allData$user <- userData$userId

or:

cbind(allData , userData)

but non of theme do not work correctly.they produce a data with lots of columns unexpectedly.

how can I add user column to my allData data frame?

thank you.

saleh sereshki
  • 2,402
  • 3
  • 17
  • 18
  • 2
    You can start by creating a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – nrussell Jan 06 '16 at 14:42
  • I am new in R.I think I asked my question in form of android questions.excuse me for wasting your time. – saleh sereshki Jan 06 '16 at 14:47
  • 1
    Your question should include at least types of objects or their `str(x)` output in order for us to help you better. Without this information we can only guess what structures you're using. – Roman Luštrik Jan 06 '16 at 19:43

1 Answers1

9

By guessing what you want, here is a possible code

> allData <- data.frame(x=c(1,1,0), y=c(2,1,0), z=c(5,2,5))
> userData <- data.frame(userId=c(1,2,5))

> allData <- cbind(allData, userID = userData$userId)

> allData
  x y z userID
1 1 2 5      1
2 1 1 2      2
3 0 0 5      5
Warren Shore
  • 206
  • 1
  • 6