Jump to content

List of TRUES and FALSES

Featured Replies

Hello, I am doing a project in R and am interested in creating a list of vectors of TRUES and FALSES as follows:

FALSE FALSE FALSE FALSE FALSE
FALSE FALSE FALSE FALSE TRUE
FALSE FALSE FALSE TRUE FALSE
FALSE FALSE FALSE TRUE TRUE
...
TRUE TRUE TRUE TRUE TRUE

I have manually typed all 32 combinations; however, I am interested in doing this more elegantly. I imagine a loop and some sort of modulus operation are required. Any advice would be appreciated.

Thank you!

Edited by FancyJules

Yes, you can use logic test and assign the results to a vector:

 

a<- c()

a[1]<- 3>4

 

You can loop or use something like which() to do this more cleverly depending on your test.

Archived

This topic is now archived and is closed to further replies.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.