505 Quiz #1 questions
If I type a code line into the R command prompt and hit <ENTER>, what will happen? (And no other points, clicks, or keypresses; just the code and <ENTER>).
R will attempt to compile my code line
Suppose I have an array of data in R, with ten rows and two columns. The first column contains text information (perhaps: Names) and the second column contains numerical information (perhaps: Height). What is the best (most accurate, most complete, and most informative) term to describe the contents of the first column in R? Class Data-Frame Matrix Strings
Strings
Regarding the image below, what is the status of this code? (note that the vertical line to the right of the 8 is the cursor). > my_num=8 (cursor here)
The code has not yet been registered by R (i.e. not yet seen by R's compiler)
I typed a command into R and was presented with a clean command prompt. (No error, no other output displayed...) What do we know about the command that I entered?
The command involved a variable assignment
Suppose a vector x in R. Reminder that a vector is a collection of elements. This vector could have been created using the c() function, e.g. x=c(8,6,0,2,0,3), or could have been extracted from a data-frame via the dollar-sign, e.g. x=yale$Height, etcetera. What is the meaning of x[5]?
This is the fifth element of x (and x has at least 5 -and possibly more- elements)
When working in R, R will "point" to a folder on your machine. This is the default folder where R will be looking to read-in files (e.g. a .csv file containing a dataset) and write-out files (e.g. a .png file containing a graphical view of your analysis). Unless you specify some other filepath, R will look within this folder for reading and writing. What is the name for this folder in R? (Hint: two words).
Working Directory
In class, it was suggested that a good debugging step before transferring code to a collaborator (or uploading to Canvas as an assignment), you should: 1) save your .R file, 2) close- and reopen R, and 3) re-run your .R one last time, to make sure that it runs as intended. What is the reason for closing- and re-opening R?
You are clearing R's memory of all variables to ensure your code is self-contained
Without looking at R: If I type x="8" into the command prompt, and hit <ENTER> so that the command compiles. If my next line of code is y=x/2, what will be the result displayed at the command prompt?
an error
When writing an R file, we often place brief narratives alongside our code lines. For example, above a boxplot() command, we might write 'create a box plot of height broken out by sport'. This narrative is often in plain-text, so that anyone (including our collaborators, and also: ourselves!) can understand what is intended by the code-line. This plain-text description has a specific technical name. What is the name for the text that a code author will place alongside their code line, as an explanation of the code's intended action?
comment
Suppose I took a measurement of how long a patient could hold their breath, and the data were in time units (seconds). What data-type would best describe this dataset?
continuous
When working with functions in R, we will sometimes pass arguments into the function that are, themselves, functions. For example, max(c(1,5,2,4)) is a command that computes the maximum of the vector {1, 5, 2, 4}. The argument for the max function is c(1,5,2,4), which is, itself, a functional expression, using the collection function c(). What is the technical term for passing one functional expression as the argument for another function?
nesting
Without looking at R: If I type x=8 into the command prompt and hit <ENTER>, what will be the result displayed at the command prompt?
nothing
Nowadays, diabetes risk is measured by A1C, i.e. the amount of sugar bound to your hemoglobin. This data-point is measured by a machine and would be considered of Continuous type. If we "map" A1C values into designations of "No diabetes risk" (A1C less than 5.7%), versus "Pre-Diabetes" (A1C 5.7 - 6.4%), versus "Diabetes" (A1C 6.5% or more), what can we say of these designations?
they are now in ordinal nature