![](/img/trans.png)
[英]How can I plot two variables from a rendered Data Table in r shiny where one is a newly made column?
[英]how to make a plot from table that i made
f1 <- c(AppliedSci[1, 27], AppliedSci[1, 28], AppliedSci[1, 29], AppliedSci[1, 30])
f2 <- c(Arts[1, 27], Arts[1, 28], Arts[1, 29], Arts[1, 30])
f3 <- c(Business[1, 27], Business[1, 28], Business[1, 29], Business[1, 30])
f4 <- c(Cmns[1, 27], Cmns[1, 28], Cmns[1, 29], Cmns[1, 30])
f5 <- c(Education[1, 27], Education[1, 28], Education[1, 29], Education[1, 30])
f6 <- c(Envir[1, 27], Envir[1, 28], Envir[1, 29], Envir[1, 30])
f7 <- c(Health[1, 27], Health[1, 28], Health[1, 29], Health[1, 30])
f8 <- c(Sci[1, 27], Sci[1, 28], Sci[1, 29], Sci[1, 30])
table1 <- matrix(c(f1, f2, f3, f4, f5, f6, f7, f8), nrow = 8)
dimnames(table1) <- list(c('Applied Sci', 'Arts', 'Business', 'Cmns', 'Education', 'Envir', 'Health', 'Sci'), c('2015', '2016', '2017', '2018'))
print(table1)
我制作了一個包含 8 個不同數據集的表格。
2015 2016 2017 2018
Applied Sci 2.738711 2.925577 3.337963 2.809579
Arts 2.799184 2.942416 3.302009 2.827511
Business 2.842297 2.947728 3.287924 2.847484
Cmns 2.858647 2.930016 3.30618 2.880631
Education 2.635278 2.896335 2.74187 2.905071
Envir 2.65874 2.881061 2.695469 2.929655
Health 2.671453 2.86696 2.704806 2.884058
Sci 2.689576 2.919287 2.787219 2.881914
這是我用 8 個不同的數據集制作的表格。 我想做一個 plot 在 x 軸上有年份,在 y 軸上有 GPA。
matplot(t(table1), type = "l", xlab = "Year", ylab = "GPA", ylim = c(2.50,3.50))
我使用“matplot”代碼制作了 plot。 但問題是 x 軸有點奇怪。
如您所見,x 軸顯示 1 到 4。當我使用xlim = c(2015,2018)將 x 軸從 2015 年更改為 2018 年時,它沒有顯示任何圖表。
有什么方法可以正確制作 plot 嗎?
謝謝你!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.