March 2019
Beginner to intermediate
250 pages
6h 6m
English
When we joined the different text files into only one table per year, some columns were duplicated because they were included in several text files at the same time. For example, all the ratios included in text files named Summary ratios will be duplicated in the other text files. In those cases, R assigns a .x or .y suffix to the variables.
In the following code, we remove the variables with the suffix .x because they are duplicated in the database:
database[,grep(".x",colnames(database))]<-NULL
The grep function searches for the .x pattern among the columns names. If this pattern is detected in a column, this column will be removed. Additionally, the .y suffix is removed from the column names:
var_names<-names(database) ...
Read now
Unlock full access