Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9192137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:51:05+00:00 2026-06-17T20:51:05+00:00

I am trying to program a ranked set sampling using R . There are

  • 0

I am trying to program a ranked set sampling using R. There are 2*n^2 items and I want to randomly divide them into two equal sized groups with n^2 items in each group. Then I want to use a Ranked Set Sampling from each of these groups to form n RSS blocks with n items in each RSS block.

What I was trying is shown below:

n<-4
id<-1:(2*n^2)
s1<-sample(id,n^2)
s2<-id[-s1]

block<-rep(1:(2*n),each=n)
d<-data.frame(block)

Now I want a column in my data frame named rss that will show which id’s are selected in a particular RSS block.

I am not good at R. I was trying this:

for(i in 1:n){
d$rss<-ifelse(d$block==i,sample(s1,n),0)
#s1<-s1[-which(s1==d$rss)]
}

for(i in 1:n){
d$rss<-ifelse(d$block==i,sample(s2,n),0)
#s2<-s2[-which(s2==d$rss)]
}

which I know is very wrong! Can anyone help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:51:06+00:00Added an answer on June 17, 2026 at 8:51 pm

    You should give an example of the output you want, but giving it my best guess:

    d <- transform(d,rss = ifelse(d[,"block"]<=n, sample(s1), sample(s2)))
    

    Or, in a more organized manner:

    d <- transform(d,block.id = rep(1:n))
    d <- transform(d,rss = ifelse(d[,"block"]<=n, sample(s1), sample(s2)))
    
    library(reshape2)
    d <- dcast(d,block ~ block.id, value = rss)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to program my first GUI-class in Java, using the Window Builder. Ok,
I am trying to program a noise reduction algorithm that works with a set
I'm trying to program a graph class using an adjacent list from an example
I'm trying to program ARM using Eclipse + CDT + yagarto (gnu toolchain) +
I am trying a program with Swing. I am using a socket to connect
I've been writing a program trying to find itself using the procps library. But
I'm trying to program two buttons to imitate the up/down arrow key behavior, meaning
I am trying to program a simple employee registry and I want to use
I am trying to program in GWT (using Eclipse and the GWT Designer). I
I'm trying to program some tool and i want to simulate a network cable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.