MIS 446 Colorado State University Global Campus R Scrit to Explore Data Worksheet
ANSWER
Here’s an R script file that completes the steps you provided:
# Name: Your name
# Course: Your course
# Module: 2
# Step 2
# Read in the data set file cafe_ratings.csv
cafe_data <- read.csv("cafe_ratings.csv")
# Create price categories
cafe_data$Price_Category <- cut(cafe_data$Price,
breaks = c(0, 50, 100, 150, 600),
labels = c("$50 and under", "$50 to $100", "$100 to $150", "$150 to $600"))
# Create a cross-tabulation table
cross_tab <- table(cafe_data$Cuisine, cafe_data$Price_Category)
# Display the cross-tabulation table
print(cross_tab)
# Step 3
# Print current date and time
print(Sys.time())
# Print username
print(Sys.getenv("username"))
# Step 4
# Read in the data set file top20.csv
endowment_data <- read.csv("top20.csv")
# Create a box plot for university endowment
boxplot(endowment_data$Endowment, main = "University Endowment Box Plot", ylab = "Endowment (Billions USD)")
# Step 5
# Print current date and time
print(Sys.time())
# Print username
print(Sys.getenv("username"))
Make sure to replace “Your name” and “Your course” with your actual name and course. Also, ensure that you have the CSV files (“cafe_ratings.csv” and “top20.csv”) in your working directory before running the script.
To summarize:
- The script reads the “cafe_ratings.csv” file, creates price categories, and generates a cross-tabulation table showing the distribution of price across cuisine.
- It prints the current date, time, and username using
Sys.time()
andSys.getenv("username")
. - The script reads the “top20.csv” file and creates a box plot to display university endowment data.
- Finally, it prints the current date, time, and username again.
To submit your response, execute the script in RStudio, capture the required screenshots as specified in your assignment, and provide a summary, interpretation of results, and reflection based on your experience completing the assignment.
QUESTION
Description
Create an R script (*.R) file to explore two variables together from one *.csv data set file using cross tabulation and to explore a single quantitative variable from another *.csv data set file using box plot according to the steps given below. Give the script file a name that includes your first name and last name like this Solution-W1-FirstName-LastName.R.
Complete these steps:
Step 1
- Include these 3 lines of comments at the beginning of your R (*.R) script file to document the script:
# Name: Your name (e.g., Jane Doe)
# Course: Your course (e.g., MIS446)
# Module: 2
Step 2
Read in the data set file cafe_ratings.csv Download cafe_ratings.csvand organize its data into a cross-tabulation table showing the distribution of price across cuisine. Use four price categories of (1) $50 and under, (2) $50 to $100, (3) $100 to $150, and (4) $150 to $600.
Your R code should be well commented and well organized to explain what the code does.
Step 3
Enter this Sys.time() R function to print the current date and time and this Sys.getenv(“username”) R function to print your username as shown here:
Sys.time() [1] “2022-08-09 09:35:57 EDT” > Sys.getenv(“username”) [1] “omora” >”>
Step 4
Read in the data set file top20.csv and display the university endowment data in a box plot. Are the data presented well?
Your R code should be well commented and well organized to explain what the code does.
Step 5
Enter this Sys.time() R function to print current date and time and this Sys.getenv(“username”) R function to print your username as shown here:
Sys.time() [1] “2022-08-09 09:35:57 EDT” > Sys.getenv(“username”) [1] “omora” >”>
Save and execute your *.R script file and display the results of its execution in the RStudio console and/or the Plots tabs.
Take screenshots of your ordered steps to demonstrate successful completion of your work. The screenshot should show the R commands you applied and the results you obtained. Do not capture trial and error results. Only your final results should be captured. Your screenshot(s) should look something like this:
Summarize your work on this assignment as follows:
Explain how you completed this work and how you resolved the issues you faced, if any. Explanation of your work should be relevant and detailed.
Interpret the results you obtained from your work. Interpretation of results should be relevant and accurate.
Reflect on your experience with this assignment and the lessons you learned. Reflection on experience should be relevant and personalized.
To submit your response to this assignment:
Prepare all the required *.R script file and screenshots.
Prepare your summary of your work (what you did, interpretation of results, and reflection).
Use the Submission Template – Assignment Download Submission Template – Assignmentdocument and complete all its sections from your prepared screenshots and work summary.
Make sure your completed Submission Template – Assignment document
follows the order given in the submission template.