Please download the answer file and edit it on RStudio. Write your student number in the correct place at the beginning of the answer file. When you finish, send the answers.R file to the answers’ mailbox. All questions are independent and can be answered in any order.

1 Papers published by our University

The database PubMed contains a catalog of all papers published by our university in international journals of biological sciences. The following code will create a data frame with the number of publications for each year. If you knit the document, it will be automatically included. Do not delete it, do not duplicate it.

pubmed <- data.frame(year = c(2018, 2017, 2016, 2015, 2014, 2013,  2012, 2011,
2010, 2009, 2008, 2007, 2006, 2005, 2004,  2003, 2002, 2001, 2000, 1999, 1998,
1997, 1996, 1995,  1994, 1993, 1992, 1991, 1990, 1989, 1988, 1987, 1986,  1975,
1974, 1965, 1940), number = c(1001, 1194, 1328, 1154,  942, 681, 618, 534, 506,
510, 468, 524, 495, 493, 477,  400, 265, 168, 141, 127, 93, 74, 68, 61, 34, 43,
23,  14, 13, 10, 8, 2, 3, 2, 1, 1, 2))

1.1 Write an R command to plot the number of papers depending on the year

# write your answer here

1.2 Write the R commands to plot the number of papers depending on the year, using a semi-log transformation.

# write your answer here

1.3 Write an R command to plot the number of papers depending on the year in semi-log transformation, but only when year is greater than 1980 and year is less than 2016.

# write your answer here

1.4 Write an R command to build a linear model to predict the number of papers depending on the year. Assign the model to the variable model and show it

# write your answer here
## 
## Call:
## lm(formula = log(number) ~ year, data = pubmed, subset = year > 
##     1980 & year < 2016)
## 
## Coefficients:
## (Intercept)         year  
##   -386.2718       0.1955

1.5 Write an R command to plot the number of papers depending on the year, and the line of values predicted by model. Notice that we do not plot logarithms, but we use a logarithmic scale

# write your answer here

1.6 Write the code to print the growth rate (percentage) for each year. This growth rate is calculated from the values of the coefficients of the model.

# write your answer here
##     year 
## 21.58631

2 Circles

2.1 We want to draw circles, ellipses and spirals. Please create a vector t with numbers from 0 to 2*pi in steps of 0.1. Then draw this graphic with cos(t) on the horizontal axis, and sin(t) in the vertical axis

2.2 Now draw the same circle but with the symbol size proportional to 1-cos(t)

2.3 This time the radius should change with t. Please draw this graphic with t*cos(2*t) on the horizontal and t*sin(2*t) in the vertical axis

3 Kepler’s Law

For this question you must use the data frame defined by the following code.

planets <- data.frame(Name = c("Mercury", "Venus", "Earth", "Mars",  "Jupiter",
"Saturn", "Uranus", "Neptune"), Diameter = c(4879,  12104, 12742, 6779, 139822,
116464, 50724, 49244), Distance = c(57909227,  108209475, 149598262, 227943824,
778340821, 1426666422, 2870658186,  4498396441), Period = c(88, 225, 365.24,
687, 4346.356, 10774.58, 30680.16,  60191.552))

3.1 Draw three plots: normal, semi-log and log-log scales. Each plot must have Distance in the horizontal axis, Period in the vertical axis, and the symbol size must be proportional to Diameter/50000.

# write your answer here

3.2 Based on the 3 plots, decide which is the best approach to use a linear model. Build the model and show the coefficients

# write your answer here
##   (Intercept) log(Distance) 
##    -22.331471      1.499873

3.3 (bonus) Compare your result with Kepler’s third law

# write your answer here