Created
November 1, 2019 15:54
-
-
Save mhughes2k/065f7e02c5b29fde475e85f8f264c1fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<form> | |
<script type="text/javascript" src="http://cdn.datacamp.com/dcl-react.js.gz"></script> | |
The R session below has a data set called <span class="" style="font-family: "Courier New", Courier, mono;">bp</span> pre-loaded which contains information on the age (<span class="" style="font-family: "Courier New", Courier, mono;">Age</span>) | |
and systolic blood pressure (<span class="" style="font-family: "Courier New", Courier, mono;">BP</span>) of 30 individuals. | |
<p>Using the tool below fit a linear regression model called <span class="" style="font-family: "Courier New", Courier, mono;">BP_mod</span>, which takes <span class="" style="font-family: "Courier New", Courier, mono;">BP</span> as the | |
response using <span class="" style="font-family: "Courier New", Courier, mono;">Age</span> as the independent variable, then print the model results.<br> | |
<script type="text/javascript" src="//cdn.datacamp.com/dcl-react.js.gz"></script> | |
</p> | |
<div data-datacamp-exercise="" data-lang="r" style="width: 900px" data-height="400px" data-show-run-button="" data-no-lazy-load="" align="center"> | |
<code data-type="pre-exercise-code"> | |
# Pre-exercise code initialises the workspace for the example | |
bp <- read.csv("http://personal.strath.ac.uk/kate.pyper/Class_Data/Blood_Pressure.csv") | |
</code> | |
<code data-type="sample-code"> | |
# construct BP_mod | |
# Print the results of BP_mod | |
</code> | |
<code data-type="solution"> | |
# construct BP_mod | |
BP_mod <- lm(BP~Age, data=bp) | |
# Print the results of BP_mod | |
summary(BP_mod) | |
</code> | |
<code data-type="sct"> | |
ex() %>% { check_error(.) | |
check_function(.,"lm") %>% check_arg(., "data","Remember to use the 'data' argument to direct the function to your data") | |
check_object(., "BP_mod", undefined_msg="Did you call your model BP_mod? Remember that object names in R are case sensitive!") %>% check_equal(., incorrect_msg="Check the formula specified in the lm() function") | |
check_function(., "summary") } | |
success_msg("Excellent! You can now draw conclusions based on this model. Enter the code 219279 in the box below to continue.") | |
</code> | |
<div data-type="hint"> | |
Use the <code>data=</code> argument to <code> lm </code> and remember that <code>summary()</code> prints the results from a linear model. | |
</div> | |
</div> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment