- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create sample space of throwing two dices in R?
When we through two dices the sample space has thirty-six outcomes as shown below −
(1,1),(1,2),(1,3),(1,4),(1,5),(1,6) (2,1),(2,2),(2,3),(2,4),(2,5),(2,6) (3,1),(3,2),(3,3),(3,4),(3,5),(3,6) (4,1),(4,2),(4,3),(4,4),(4,5),(4,6) (5,1),(5,2),(5,3),(5,4),(5,5),(5,6) (6,1),(6,2),(6,3),(6,4),(6,5),(6,6)
Now, to create the sample space of throwing two dices in R, we can use the below mentioned command −
expand.grid(1:6,1:6)
Example
To create sample space of throwing two dices in R, use the command given below −
expand.grid(1:6,1:6)
Output
If you execute the above given command, it generates the following output −
Var1 Var2 1 1 1 2 2 1 3 3 1 4 4 1 5 5 1 6 6 1 7 1 2 8 2 2 9 3 2 10 4 2 11 5 2 12 6 2 13 1 3 14 2 3 15 3 3 16 4 3 17 5 3 18 6 3 19 1 4 20 2 4 21 3 4 22 4 4 23 5 4 24 6 4 25 1 5 26 2 5 27 3 5 28 4 5 29 5 5 30 6 5 31 1 6 32 2 6 33 3 6 34 4 6 35 5 6 36 6 6
- Related Articles
- How to create a random sample of months in R?
- Probability of getting a sum on throwing 2 Dices N times in C++
- How to create a random sample of week days in R?
- How to create sample of rows using ID column in R?
- How to find the sample size for two sample proportion tests with given power in R?
- How to create a sample or samples using probability distribution in R?
- How to create random sample based on group columns of a data.table in R?
- How to create a random sample of values between 0 and 1 in R?
- How to create a random sample with values 0 and 1 in R?
- Create a sample of data frame column by excluding NAs in R
- How to create the random sample by defining the probabilities for each unit in R?
- How to repeat a random sample in R?
- How to apply two sample t test using a categorical column in R data frame?
- Create a random sample by ignoring missing values in an R vector.
- How to create a column with ratio of two columns in R?

Advertisements