This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT t.Country, t.Y1990 AS Metric, '1990' AS `Year` FROM tabular t | |
UNION | |
SELECT t.Country, t.Y1991 AS Metric, '1991' AS `Year` FROM tabular t | |
UNION | |
SELECT t.Country, t.Y1992 AS Metric, '1992' AS `Year` FROM tabular t | |
UNION | |
SELECT t.Country, t.Y1993 AS Metric, '1993' AS `Year` FROM tabular t | |
UNION | |
SELECT t.Country, t.Y1994 AS Metric, '1994' AS `Year` FROM tabular t | |
UNION |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rcode to turn tabular data to flat records | |
# method 1, loop | |
d <- read.csv("http://oyh.coolpage.biz/blog_raw_data/tabular_to_flat/heatmap_data_tabular.txt", sep = "\t", header = T) | |
names(d)[1] <- "Country" # the input may encounter error in the first character at times. rename it | |
names(d)[-1] <- "Metric" | |
head(d) # assign the same name for yearly columns, so as to rbind() later on | |
dd <- d[, c(1,2)] | |
dd$Year <- 1990 | |
j <- c(1991:1999) |
NewerOlder