我正在尝试在ggplot中制作一个条形图,我在其中指定要显示哪些标签,通过强制执行其中一些长度为零的字符串,即"".但是,我得到了错误
Error in grid.Call("L_textBounds", as.graphicsAnnot(x$label), x$x, x$y,
: Polygon edge not found (zero-width or zero-height?)
Run Code Online (Sandbox Code Playgroud)
当试图这样做.
以下代码将重现错误.
希望有人能解释为什么我不能像我一样做.
library(ggplot2)
dataset<-matrix(ncol=3,nrow=12)
colnames(dataset)<-c("Score","Action","Bin")
dataset[1:9,1]<-c(1,2,3,-2,7,10,12,3,4)
dataset[1:9,2]<-rep(1,9)
dataset[10:12,1]<-c(-1,-2,-3)
dataset[10:12,2]<-rep(2,3)
dataset[1:12,3]<-as.character(cut(dataset[1:12,1:1],breaks=4))
myDataset<-as.data.frame(dataset)
chosenbreaks<-as.vector(unique(dataset[1:12,3]))
chosenlabels<-as.vector(c(chosenbreaks[1],"","",chosenbreaks[4]))
fullplot<-ggplot(myDataset, aes(Bin, fill=Action))
+ geom_bar(position="stack")
+ opts(axis.text.x = theme_text(angle = 45,size=8))
+ scale_x_discrete("test",breaks=chosenbreaks,labels=chosenlabels)
fullplot
Run Code Online (Sandbox Code Playgroud)
提前致谢,
基督教
我正在对银行业的非违约者和违约者进行一些研究.在这种情况下,我正在绘制他们的分布相对于条形图中的某些分数.分数越高,信用评级越高.
由于默认值的数量与非默认值的数量非常有限,因此在同一条形图上绘制默认值和非默认值并不是非常有用,因为您几乎看不到默认值.然后我根据违约者的得分制作第二个条形图,但是在与违约者和非违约者的得分的完整条形图相同的间隔尺度上.然后,我将垂直线添加到第一个条形图,指示最高和最低的违约者得分所在的位置.这是为了了解违约者的分布在违规者和非违约者的整体分布中的位置.
x轴容易变得非常"拥挤".我想删除一些刻度线的文本,但不是所有的刻度线.
下面是我使用的代码替换为(种子)随机数据.
关于刻度线上的文字我想要的第一个条形图,但是我错过了第二个条形图中的所有刻度.在第二个条形图中显示"拥挤"的性质!
library(ggplot2)
library(ggExtra)
#NDS represents non-defaults and DS defaults on the same scale
#although here being just some random normals for the sake of simplicity.
set.seed(10)
NDS<-rnorm(10000,sd=1)-2
DS<-rnorm(100,sd=2)-5
#Cutoffs are constructed such that intervals of size 0.3 contain all values
#of NDS & DS
minCutoff<--9.3
maxCutoff<-2.1
#Generate the actual interval "bins"
NDS_CUT<-cut(NDS,breaks=seq(minCutoff, maxCutoff, by = 0.3))
DS_CUT<-cut(DS,breaks=seq(minCutoff, maxCutoff, by = 0.3))
#Manually generate where to put the vertical lines for min(DS) and max(DS)
minDS_bar<-levels(cut(NDS,breaks=seq(minCutoff, maxCutoff, by …Run Code Online (Sandbox Code Playgroud) 我正在尝试设置RInside工作,我们被迫使用Windows环境.
我安装了RTools并从CRAN下载了一个RInside二进制文件.
我的R安装位于c:\ R\R-2.12.2,因此带有空格的文件夹没有问题.
我在R中安装了Rcpp和RInside软件包.
我执行以下makefile Makefile.win包含在下载的RInside二进制文件中
## -*- mode: makefile; tab-width: 8; -*-
##
## Simple Makefile
##
## TODO:
## proper configure for non-Debian file locations, [ Done ]
## allow RHOME to be set for non-default R etc
## comment this out if you need a different version of R,
## and set set R_HOME accordingly as an environment variable …Run Code Online (Sandbox Code Playgroud)