Question
Homework 1 - ECON 6520 Fall 2017 Dr. Mariano Runco For the next exercises use the datet TeachingRatings.dta. You have to submit your answers in a word document to mruncoum.edu. Please specify the course name, semester and your first and last name at the beginning of the document. The due date is September 10th by Midnight. Late homework or hard copies will not be accepted. Data Management 1.1) Before doing this exercise please review the video: "How to label the values of categorical variables You will notice that the female variable can take the values 0 or 1 (just like minority). This is all good but when you create graphs (like in the next couple of exercises) it makes it difficult to understand them. Thus in this problem you are going to change the values of the female and minority variables from 0 or 1 to male or female and white or black, respectively. Copy the command used in this problem to your word document 1.2) Add the label "Beauty score normalized to 0to the beauty variable. Copy the command used in this problem to your word document 1.3) Change the display of the variable beauty so that it shows only three decimal places. Copy the command used in this problem to your word document 1.4) Add any note you want to the variable beauty. Copy the command used n this problem to your word document. 1.5) Generate a new variable called course-eval2 that is the square of course-eval. Copy the command used in this problem to your word document Graphs 2.1) (Scatter plot) Create a scatter plot using beauty in the X axis and course evaluation in the Y axis Change the numbers in the Y axis to horizontl, add a title to the graph and change the color of each point to black. Copy the graph and paste it to a Word document 2.2) (Histogram) Create a histogram of the variable age. Use 10 bins and show the frequency on the Y axis. Add a title and change the default fill color to gold with a black outline. Also add the corresponding frequency on top of each bar. Copy the graph and paste it to a Word document 2.3) (Bar Chart) Create a bar chart showing mean course evaluations by sex and race. Add a title and change the numbers in the Y axis to horizontal position. Also change the fill color of the bars to orange. Copy the graph and paste it to a Word document 2.4) (Box plot) Create a box plot showing mean course evaluations by sex and race. Add a title and
Explanation / Answer
The data is not given , however the R commands to perform the analysis are as follows
2.1 plot(beauty,course-evaluation,main="scatterplot")
2.2 hist(data$age,main="Histogram Age",col="blue",breaks=10)
2,3
# Grouped Bar Plot
counts <- table(data$sex, mtcars$race)
barplot(counts, main="Distribution",
xlab="Numbers")
2.4
boxplot(Course~ Sex*Race, data=data.df,ylab="Values",
main="Boxplots of the Data",col=colr,horizontal=TRUE)
Please note that you must replace the data with the actual data , these are examples on how you can create the needed graphs as no dataset is provided