Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2019-pages-6-7 for upload.pdf /> I need thiss project answer in R code 3 deck52 Build a data.frame to represent a standard deck of 52 playing

2019-pages-6-7 for upload.pdf" /> I need thiss project answer in R code

image text in transcribed
3 deck52 Build a data.frame to represent a standard deck of 52 playing cards. It should have 52 rows and one column for each characteristic of a playing card: color {"black", "red"}, suit {"clubs", "spades", "diamonds", "hearts" }, name {"ace", "2", "3", ..., "king"}, rank {1,2,3, ..., 12,13}, value {1,2,3, ..., 9,10,10,10,10 }. Instructions: 1. Clean. Stylish. (10 points) 2. (25 points) Build a vector with 52 elements for each column: color, suit, name, rank, value. Useful commands are c() and rep(). Being an expert with rep() will help on the final exam. Use data.frame() to combine the columns into a single data.frame called deck52. Confirm that your data.frame has 52 rows and 5 columns. Run names(mydeck) and other comparison operators. Type help(Arithmetic) or help("+") for arithmetic operators like + and . We need %% for this assignment. Note the difference between %% and %/%. 4. (25 points) Calculate the probabilities below using R. The first one is an example. 6 (a) P (H) = It helps to work it out with a pencil first: P (H) = 13 hearts 52 cards = 14 . How do we get 13/52 in R? To get the 13 use dim(H)[1] or nrow(H). We already have event H from above, so this one is easier . On some you have to extract a new subset before counting the rows. To get the 52 use dim(deck52)[1] or nrow(deck52). Then divide 13/52 to get the answer .25. (b) P (F ) = (c) P (ODD) = (d) P (EV EN ) = This is one minus previous answer, but don't solve it that way. Extract the rows where value is even, count them, and divide by 52. (e) P (ODDC ) = Same as previous problem, but solve it explicitly: extract the rows that are NOT odd, count, divide. (f) P (D) = (g) P (D R) = Intersection means AND which is & in R. (h) P (D|R) = (i) P (D R) = Union means OR which is | in R. Note that this is unrelated to the | used in conditional probability. (j) P (F |EV EN ) = 5. (15 points) Package your results for part 4 in a 10x3 data.frame called myprobs. Run data.frame(question = '4(a)', probability = 'P(H)', answer = .25) to see the first row as an example. Attach new rows with rbind(). When the data.frame is complete, run myprobs to display it. Don't use View(). A-level instructions: Repeat parts 3 and 4 using sqldf() for subsetting and counting. Reuse your code from the previous step to package and display these new results in a data.frame called myprobsA. (15 points) 4 investors This is a story about two investors. They live in Alphaville, a small town with exactly one golf course and one Starbucks. They are strangers. 7

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Simulation

Authors: Sheldon M Ross

6th Edition

0323899617, 9780323899611

More Books

Students also viewed these Mathematics questions

Question

What does it mean when the explanatory variables are collinear?

Answered: 1 week ago

Question

1. Why do we trust one type of information more than another?

Answered: 1 week ago