Perform the following t.test:
t.test(rnorm(100))
Make R get the ends of the confidence interval and subtract them to compute its length.
Adjust the following linear model:
lm(hp~cyl+disp, data=mtcars)
Get the names of the variables and their related p-values in a named vector or a data frame.
locale
function from readr
package produces
a list which includes, among other things, the names of the days and the
months in a given language (for example, locale("de")
produces the names in German).
Find the months in the list and produce a vector with the names of the months.
We are going to see how many times each word is used in a text. You may use any text of your interest or https://www.un.org/en/about-us/universal-declaration-of-human-rights.
At each point check the kind of data structure we are using. At one step we will need to use lists.
readLines
strsplit
to split the lines (or paragraphs) into
words. Argument split="[.,; ]"
may be useful.unlist
.table
, sort
(with
descending=TRUE
), tolower
,
head
.Extra exercise:
sapply
(or lapply
) and length
.Download mortality data in Catalonia from https://www.idescat.cat/indicadors/?id=aec&n=15270. Suggestion: select comma as separator.
Import the dataset in R. Suggestion: use “Import Dataset” button in RStudio (in Environment tab) to open the “text (readr)” assistant.
Download the list of place names in Catalonia in Excel format from https://www.icgc.cat/ca/Llibres-en-PDF/Toponimia/Nomenclator-oficial-de-toponimia-major-de-Catalunya-2009-2015 (see at the bottom of the page).
Upload it to R (the “Import Dataset” button is useful again).
Count how many municipalities names in Catalonia start with “Sant”.
Suggestions: unique
, grepl("^Sant", x)
.