0

我正在使用plotrix生成梯形图。我想在每条线上显示相关百分比。谁能帮忙。非常感谢。

这是我的代码:

library(plotrix) 
args <- commandArgs(TRUE) 
pdfname <- args[1] 
datafile <- args[2] 
pdf(pdfname, width=12,height=12) 
eqdata = read.csv(datafile , header = T,sep=",") 
educattn <- as.matrix(eqdata[2:3]) 
rownames(educattn) <- eqdata$ques 
colnames(educattn) <- c('Cummulative','Current') 
p <- bumpchart(educattn,main="Percentile ranking correlation plot",rank=TRUE,col=rainbow(17),mar=c(5,20,5,20)) 
print(p) 
dev.off()

这是输出梯形图

4

1 回答 1

0

首先,我将停止将其作为脚本运行,并在与 R 的交互式会话中使用代码。然后您可以看到代码在做什么并调整不同的步骤。所以打开命令行参数捕获,然后创建 pdf 并尝试以交互方式工作。未经测试:

library(plotrix) 
## define this appropriately
datafile <- "..."

## header is TRUE and sep is "," by default
eqdata = read.csv(datafile) 
educattn <- as.matrix(eqdata[2:3]) 
rownames(educattn) <- eqdata$ques 
colnames(educattn) <- c('Cummulative','Current') 
p <- bumpchart(educattn,main="Percentile ranking correlation plot",rank=TRUE,col=rainbow(17),mar=c(5,20,5,20)) 
print(p)
于 2012-07-18T04:09:13.907 回答