Я обычно использую пакет data.table и функцию 'melt', чтобы получить формат значения ключа.
Этот формат намного лучше для ggplot2:
# Your test data: (notice that i transformed the rownames into a column)
test <- data.frame("0.99" = c(12, 15, 18), "0.98" = c(14, 15, 18), "0.90" = c(7, 22, 30))
test$rownames <- c("01370", "01332", "01442")
# melt and plot:
dt <- data.table::as.data.table(test)
melted <- data.table::melt(dt, measure = c("X0.99","X0.98","X0.90"))
ggplot2::ggplot(data = melted, mapping = aes(x = variable, y = value, group = rownames)) +
ggplot2::geom_line() +
ggplot2::facet_grid(rows = vars(rownames))
EDIT : на основе вашего отредактированного вопроса:
test <- data.frame("Site_No" = c("01370", "01332", "01442"),"0.99" = c(12, 15, 18), "0.98" = c(14, 15, 18), "0.90" = c(7, 22, 30))
dt <- as.data.table(test)
melted <- data.table::melt(dt, measure = c("X0.99","X0.98","X0.90"))
ggplot2::ggplot(data = melted, mapping = aes(x = variable, y = value, group = Site_No)) +
ggplot2::geom_line() +
ggplot2::facet_grid(rows = vars(Site_No))
EDIT2 : На основе вашего второго комментария: создайте новые графики для каждой группы:
test <- data.frame("Site_No" = c("01370", "01332", "01442"),"0.99" = c(12, 15, 18), "0.98" = c(14, 15, 18), "0.90" = c(7, 22, 30))
dt <- as.data.table(test)
melted <- data.table::melt(dt, measure = c("X0.99","X0.98","X0.90"))
for (i in unique(melted$Site_No)){
dev.new()
print(ggplot2::ggplot(data = melted[Site_No == i,], mapping = aes(x = variable, y = value, group = Site_No)) +
ggplot2::geom_line())
}