Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't know of any function doing that but here is one from scratch:</p> <pre><code>my1 &lt;- data.frame (company = rep(c("A", "B", "C"), each = 7), skillsDg = rep(c("Basic", "HighSc", "Undgd", "MAST", "PHD", "EXPD", "EXECT"), 3), number = c(200, 100, 40, 30, 10, 0, 0, 220, 110, 35, 10, 0, 4, 1, 140, 80, 120, 50, 52, 52, 3) ) my2 &lt;- split(my1,my1$company) #split your dataframe into a list where each element is a company # The next line create the layout layout(matrix(1:(length(my2)+1), nrow=1), width=c(1,rep(4,length(my2)))) # Then we draw the x-axis: par(mar=c(3,0,3,0)) plot(NA,axes=F, xlim=c(0,1),ylim=c(1,nlevels(my1$skillsDg))) axis(side=4,tick=F,labels=unique(my1$skillsDg), at=seq_along(unique(my1$skillsDg)), las=2, line=-4) # Then we apply a graphing function to each company: lapply(my2,function(x){ par(mar=c(3,0,3,0)) plot(NA, xlim=c(-max(my1$number),max(my1$number)), ylim=c(1,nlevels(my1$skillsDg)),axes=F) title(sub=x$company[1],line=1) abline(h=seq_along(x$skillsDg), col="grey80") polygon(x=c(x$number,rev(-1*x$number)), y=c(seq_along(x$skillsDg),rev(seq_along(x$skillsDg))), col=as.numeric(x$company)) }) </code></pre> <p><img src="https://i.stack.imgur.com/vH8Vz.png" alt="enter image description here"></p> <p><strong>Edit</strong>: You can of course add whatever you want inside the graphing function in <code>lapply</code> (but in some case it might mean changing a little the dimensions of the graph):</p> <pre><code>layout(matrix(1:(length(my2)+1), nrow=1), width=c(1,rep(4,length(my2)))) par(mar=c(3,0,3,0)) plot(NA,axes=F, xlim=c(0,1),ylim=c(1,nlevels(my1$skillsDg))) axis(side=4,tick=F,labels=unique(my1$skillsDg), at=seq_along(unique(my1$skillsDg)), las=2, line=-4) lapply(my2,function(x){ par(mar=c(3,0,3,0)) plot(NA, xlim=c(-max(my1$number)-50,max(my1$number)+50), ylim=c(1,nlevels(my1$skillsDg)),axes=F) title(sub=x$company[1],line=1) abline(h=seq_along(x$skillsDg), col="grey80") text(x=x$number+5, y=seq_along(x$skillsDg)+.1, label=x$number, pos=4) polygon(x=c(x$number,rev(-1*x$number)), y=c(seq_along(x$skillsDg),rev(seq_along(x$skillsDg))), col=as.numeric(x$company)) }) </code></pre> <p><img src="https://i.stack.imgur.com/21K0a.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload