At some point in its life, the data frame columns were renamed somehow to accommodate a data presentation table—that is, an attempt was made to make it look good. The work of data analysis benefits from being kept separate from the embellishments for presentation that can get in the way, as happened here.
The direct approach is to save the existing column names, replace them with a more useful set of names for analysis and then restore the original names when it comes time to decide on how to present results.
d <- data.frame(Company...Maker.if.known. = c(
"A. Morin", "A. Morin",
"A. Morin", "A. Morin", "A. Morin", "A. Morin"
), Specific.Bean.Origin.or.Bar.Name = c(
"Agua Grande",
"Kpime", "Atsane", "Akata", "Quilla", "Carenero"
), REF = c(
1876L,
1676L, 1676L, 1680L, 1704L, 1315L
), Review.Date = c(
2016L, 2015L,
2015L, 2015L, 2015L, 2014L
), Cocoa.Percent = c(
"63%", "70%",
"70%", "70%", "70%", "70%"
), Company.Location = c(
"France", "France",
"France", "France", "France", "France"
), Rating = c(
3.75, 2.75,
3, 3.5, 3.5, 2.75
), Bean.Type = c(
" ", " ", " ", " ", " ",
"Criollo"
), Broad.Bean.Origin = c(
"Sao Tome", "Togo", "Togo",
"Togo", "Peru", "Venezuela"
))
print_headers <- colnames(d)
colnames(d) <- c("maker","sp_orgin","ref","rev_date","pct_cocoa","location","rating","type","broad_origin")
head(d,2)
#> maker sp_orgin ref rev_date pct_cocoa location rating type
#> 1 A. Morin Agua Grande 1876 2016 63% France 3.75
#> 2 A. Morin Kpime 1676 2015 70% France 2.75
#> broad_origin
#> 1 Sao Tome
#> 2 Togo
colnames(d) <- print_headers
Created on 2023-02-01 with reprex v2.0.2