This brief survey session is intended to replicate most of the data analysis discussed in the preceding section using the R software. The section is self-contained in the sense that there is no dependency on any R package.
The functions available in the R default version suffice to perform the analysis done earlier in the chapter. The income_dist.csv
file needs to be present in the current working directory.
A step-by-step approach to perform the analysis related to the income_dist.csv
file can be easily carried out as shown in the next program.
- Load the dataset
income_dist.csv
using theread.csv
function and use the functionsnrow
,str
,length
,unique
, and so on to get the following results:
id <- read.csv("income_dist.csv",header=TRUE) nrow(id) str(names(id)) length(names(id)) ncol(id) # equivalent of previous line unique(id$Country) levels(id$Country) # alternatively min(id$Year) max(id$Year) id_us <- id[id$Country=...