if(interactive()){
s <- Filter(function(df)nrow(df) > 1, split(UsAndThem, UsAndThem$Country))
sUaT <- Map(function(country){country[order(country$Year),]} , s)
xcoords <- Map(function(x)x$Year, sUaT)
ycoords <- Map(function(x)x$LifeExpectancy, sUaT)
region <- sapply(sUaT, function(x)as.character(x$Geographic.Region[1]))
p <- l_plot(showItemLabels=TRUE)
l <- l_layer_lines(p, xcoords, ycoords, itemLabel=names(sUaT), color=region)
l_scaleto_layer(l)
# Set groups
p <- l_plot(showItemLabels=TRUE)
l <- l_layer_lines(p,
x = c((0:4)/10, rep(.5, 5), (10:6)/10, rep(.5, 5)),
y = c(rep(.5, 5), (10:6/10), rep(.5, 5), (0:4)/10),
group = rep(1:5, 4),
linewidth = 4,
col = l_getColorList()[1:5])
l_scaleto_layer(l)
}
Run the code above in your browser using DataLab