12.9 Exercise (to do at home)

1- Read in file ex6c_input.txt (that is in folder downloaded for exercice 6 “i_o_files”) in object “extra”

Warning: the file has a header !
Check the structure of extra (remember the str command).

correction

2- Read in the same file but, this time, set the argument as.is to TRUE.

Check again the structure: what has changed ?

correction

3- What are the column names of extra ?

correction

4- Change the name of the first column of extra from “State” to “Country”.

correction

5- How many countries are in the Eurozone, according to extra ?

Remember the table function. ?table

correction

6- In the Eurozone column: change “TRUE” with “yes” and “FALSE” with “no”.

correction

7- In the column Country: how many country names from the list contain the letter “c” (capital- or lower-case) ?

Remember the grep function. Check the help page.

correction

8- According to that data frame: how many people live: + in the European union (whole table) ? + in the Eurozone ?

correction

9- Write extra into file ex6c_output.txt

After each of the following steps, check the output file in the RStudio file browser (lower-right panel).

  • Try with the default arguments.

correction

  • Add the argument “row.names” set to FALSE.

correction

  • Add the argument “quote” set to FALSE.

correction

  • Add the argument “sep” set to “ or to”,"

correction