<-
format_ods_data_frame function(dat,
colnames = TRUE,
type_definition = TRUE) {
<- dat
result
if (colnames) {
<- result[-1, ]
result colnames(result) <- dat[1, ]
}
if (type_definition) {
<- result[1, ]
type_defs <- result[-1, ]
result for (i in 1:ncol(dat)) {
if (type_defs[i] == 'Factor') {
== '', i] <- NA
result[result[, i] <- as.factor(result[, i])
result[, i]
}if (type_defs[i] == 'Numeric')
<- as.numeric(result[, i])
result[, i] if (type_defs[i] == 'Character')
<- as.character(result[, i])
result[, i]
}
}rownames(result) <- NULL
return(result)
}
<- function(label,
plot_timeline
begin,
end, group = NULL) {
<- length(label)
n if(is.null(group)) {
<- 1:n
group else {
} <- as.numeric(group)
group
}<- rainbow(max(group),
timeline_colors s = 0.1)
par(mar = c(3.1, 2.1, 2.1, 2.1))
plot(0, type = 'n',
ylab = '', xlab = '', yaxt = 'n',
ylim = c(n, 0),
xlim = range(begin, end))
grid()
rect(xleft = begin,
xright = end,
ybottom = 0:(n - 1) + 0.1,
ytop = 1:n - 0.1,
col = timeline_colors[group])
text((begin + end) / 2,
1:n - 0.5,
label) }
Timeline
library('readODS')
<- format_ods_data_frame(
Modernism read.ods('Art_Modernism.ods',
sheet = 1))
Warning in read.ods("Art_Modernism.ods", sheet = 1): read.ods will be
deprecated in the next version. Use read_ods instead.
par(mar = c(3.1, 2.1, 2.1, 2.1))
plot(0, type = 'n',
ylab = '', xlab = '', yaxt = 'n',
ylim = c(nrow(Modernism), 0),
xlim = range(Modernism$Begin, Modernism$End))
grid()
rect(xleft = Modernism$Begin,
xright = Modernism$End,
ybottom = 0:(nrow(Modernism) - 1) + 0.1,
ytop = 1:nrow(Modernism) - 0.1,
col = rainbow(nrow(Modernism),
s = 0.2))
text((Modernism$Begin + Modernism$End) / 2,
1:nrow(Modernism) - 0.5,
$Label) Modernism
<- format_ods_data_frame(
painters read.ods('Painters.ods', sheet = 1))
Warning in read.ods("Painters.ods", sheet = 1): read.ods will be deprecated in
the next version. Use read_ods instead.
with(painters,
plot_timeline(Label, Begin, End, group = Group))