Skip to content

(no subject)

2 messages · thanoon younis, Rui Barradas

#
Dear R - Users
I have a small problem when i generated two column with 200 rows and as
follows

Q1[i,1]=sample(4, 200, replace = TRUE); Q1[i,2]=rbinom(200,1,0.7)

the first vector is ordered categorical variable and the second vector is
dichotomous variable but when i run this code i found this error

Error in Q1[i, 2] = rbinom(200, 1, 0.7) :
  number of items to replace is not a multiple of replacement length


Any help would be appreciated.



Regards
#
Hello,

Try th following.

Q1 <- matrix(c(sample(4, 200, replace = TRUE), rbinom(200,1,0.7)), ncol = 2)
Q1


Hope this helps,

Rui Barradas

Em 17-09-2015 15:37, thanoon younis escreveu: