1

I have a two vectors of different sizes. say

x <- rnorm(50, 2, 0.8) 
y <- rnorm(35, 4, 0.5)

I want to create new vector zof size 100 which contains sample of size 75 observation from x and sample of size 25 from y.

I thinking to use sample() function of base package.

Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
Krishna Nevase
  • 95
  • 2
  • 5
  • 12

1 Answers1

2

Try this:

x <- rnorm(50, 2, 0.8)
y <- rnorm(35, 4, 0.5)
z<-c(sample(x = x,size = 75,replace = T),sample(x = y,size = 25,replace = T))
tushaR
  • 3,083
  • 1
  • 20
  • 33