Question

Write code in R or Rstudio (Programming) You track your commute times for three weeks (15...

Write code in R or Rstudio (Programming)

You track your commute times for three weeks (15 days), recording the following times in minutes: 17, 16, 20, 24, 22, 15, 21, 25, 17, 90, 16, 17, 22, 20, 20. Enter the data into a 3-by-5 matrix, where rows are weeks and columns are weekdays. Please answer the following questions and provide the necessary code. (a) Name each column with the weekday abbreviations, i.e., Mon, Tue, Wed, Thu, and Fri (b) Find the shortest, the longest, the average, and the median commute time within those three weeks. (c) The 90 was a mistake. It should have been 19. How can you fix this? Do so, and then find the new average and median. (d) How many times was your commute 20 minutes or more? (e) What percent of your commutes are less than 18 minutes long? (f) In average, which weekday you spend the most commute time? 1 (g) In average, which weekday you spend the least commute time? (h) Summarize the matrix into a vector where each entry is the average commute time for the corresponding weekday in those three weeks. Find the differences from day to day. Are there any weekday where the amount dropped from the previous weekday?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

times = matrix(
c(17,16,20,24,22,15,21,25,17,90,16,17,22,20,20),
nrow = 3,
ncol = 5,
byrow = TRUE)

#a
weekdays <- c("Mon","Tue","Wed","Thu","Fri")
colnames(times)<-weekdays
print(times)

#b
print(min(times))#shortest
print(max(times))#longest
print(mean(times))#average
print(median(times))#median

#c
times[2,5] = 19
print(mean(times))#new average
print(median(times))#new median

#d
minutes20=0
for(i in times) {

        if( i>=20){
           minutes20 = minutes20 + 1
       }
}
print(minutes20)

#e
minutes18=0
for(i in times) {

        if( i<18){
           minutes18 = minutes18 + 1
       }
}
percent18=minutes18*100/15
print(percent18)

#f
A=colMeans(times)
print(names(A[A==max(A)]))

#g
A=colMeans(times)
print(names(A[A==min(A)]))

#h
AverageCommune=colMeans(times)
Difference=diff(AverageCommune)
print(Difference)

weekDayDrop = names(Difference[Difference<0])
print(weekDayDrop)

Add a comment
Know the answer?
Add Answer to:
Write code in R or Rstudio (Programming) You track your commute times for three weeks (15...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 3. Use R Studio: Include R Code A commuter records 20 commute times to gage her...

    3. Use R Studio: Include R Code A commuter records 20 commute times to gage her median commute time. The data has a sample median of 24 and is summarized in this stem-and-leaf diagram: stem(commutes) 2 | 111233444444 2 | 55569 3 | 113 If the data is appropriate for t.test, use that to compute a 90% confidence interval for the median. Otherwise use wilcox.test (perhaps after a transform) to compute a confidence interval for the median.

  • Compare the values for mean and median commute times that you calculated.What can you infer about...

    Compare the values for mean and median commute times that you calculated.What can you infer about this frequency distribution Help with question 12 and 13 Question 12 1 pts Compare the values for mean and median commute times that you calculated in questions 9 and 10. What can you infer about this frequency distribution It is bimodal. 0 It is symmetric. It is right (positive) skewed It is left (negative) skewed Question 13 1 pts Based on your answer in...

  • Your friend believes that he has found a route to work that would make your commute...

    Your friend believes that he has found a route to work that would make your commute faster than what it currently is, under similar conditions. To test this claim, you and your friend time the commute from your house to the building where you work over a random set of days, and you flip a coin each day to determine who takes which route. Each trip is done at the exact same time of day. Find the test statistic and...

  • Read the scenario given below. With your group, examine the data set (on page 2) and...

    Read the scenario given below. With your group, examine the data set (on page 2) and decide what analysis should be done. Perform this analysis. Record your results and submit this file on Blackboard by the end of the day. Each student must submit a copy of their results. Scenario: Students are often late to class. This is distracting to both students and teachers, and is quite annoying. The school and instructors realize that some students have long commutes, but...

  • 5. Use the propenties of the gamma function to t( poimts a. (a) r(S) (b) rz) 6 A long traffic light on your morning commute is green 20% of the time that you approach it. Assume that cach morning...

    5. Use the propenties of the gamma function to t( poimts a. (a) r(S) (b) rz) 6 A long traffic light on your morning commute is green 20% of the time that you approach it. Assume that cach morning represents an independent r [10 points (a) Over 5 morning, what is the probability that the light is green on exactly one day? (b) Over 20 mornings, what is the probability that the light is green on exactly four days? 7....

  • Ashley Miller has three major routes to commute to work: take RiverView Street the entire way,...

    Ashley Miller has three major routes to commute to work: take RiverView Street the entire way, take several back streets, or use the expressway. The traffic patterns are pretty complex. Under good conditions, RiverView Street is the fastest route; however, when it is congested, one of the other routes is usually preferable. Over the past two months, Ashley has tried each route several times under different traffic conditions. Her travel time to work (in minutes) is summarized in the following...

  • Write a code for a ride tracking app for Large Resort parks. In your app users...

    Write a code for a ride tracking app for Large Resort parks. In your app users are going to be able to track wait times for up to five attractions, find the shortest wait time, and find the average wait time. //-----------------------------Sample Program Behavior with five attractions entered--------------------- Welcome to Large Resort Parks! Please enter the attractions you plan to visit and their wait times Ride 1 info: Attraction Name: 80 ft drop Wait time (in minutes): 40 Enter another...

  • You have 15 minutes to solve the exam. Write down all your answers in the bluebooks,...

    You have 15 minutes to solve the exam. Write down all your answers in the bluebooks, and mark your answers properly. For callation questions, you need to show all major steps. Good Luck 1. Basie Game Theory 21 points) Consider the following game Player 2 2026 1833 22.18 A. (6 points) Does player I have a dominant strategy. If yes, describe it. B p oints) Can this game be solved by the elimination of dominated strategy? If yes, describe your...

  • General Requirements: • You should create your programs with good programming style and form using proper blank spaces, indentation and braces to make your code easy to read and understand; • You sho...

    General Requirements: • You should create your programs with good programming style and form using proper blank spaces, indentation and braces to make your code easy to read and understand; • You should create identifiers with sensible names; • You should make comments to describe your code segments where they are necessary for readers to understand what your code intends to achieve. • Logical structures and statements are properly used for specific purposes. Objectives This assignment requires you to write...

  • CAN SOMEONE COMPLETE THIS CODE PLEASE THNK YOU!! Question - Write a program in c++ that...

    CAN SOMEONE COMPLETE THIS CODE PLEASE THNK YOU!! Question - Write a program in c++ that keeps an appointment book. Make a class Appointment that stores a description of the appointment, the appointment day, the starting time, and the ending time. Your program should keep the appointments in a sorted vector. Users can add appointments and print out all appointments for a given day. When a new appointment is added, use binary search to find where it should be inserted...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT