plot - R: Graphing a table plan -
general goal
i placing guests around tables according set of rules. goal, in post, have handy function display names of these guests around respective tables on r
graphic.
input data
guests
describes position of each guest @ each table. note number of guests per table varies.
guests = list( table_1 = c("jack", "christelle", "frank", "john s.", "lucia"), table_2 = c("george", "amanda", "alice", "laura", "john h."), table_3 = c("jeanette", "elizabeth", "remi", "fabian", "urs", "emma"), table_5 = c("roger", "marry", "henrique", "claire", "julia"), table_6 = c("alphonse", "marie", "dani", "rachel") )
table_positions
indicate each table should positioned on graph. assume here each axis goes 0 10, point c(5,5)
@ center of graph.
table_positions = data.frame( y_position=c(3,2,3,7,8,7), x_position=c(3,5,7,3,5,7) )
details of graphic
i suggest tables represented circles centered @ position indicated data.frame table_positions
. names of each guest should written around these tables following list guests
.
placement of tables :
require(plotrix) plot(x = table_positions$x_position ,y= table_positions$y_position ,xlim=c(0,10),ylim=c(0,10),pch=".") draw.circle(table_positions$x_position, radius=0.5, table_positions$y_position)
guests positioning :
for(i in 1:length(guests)){ table<-as.vector(unlist(guests[i])) postable<-c(table_positions$x_position[i],table_positions$y_position[i]) nbguest<-length(table) for(j in 1:nbguest){ text(x=postable[1]+round(0.5*cos((2*j/nbguest)*pi),2), y=postable[2]+round(0.5*sin((2*j/nbguest)*pi),2), labels=guests[[i]][[j]], cex=0.5) } }
i added table4 1 pepole named "bla".
can specify text size cex
option (here 0.5).
Comments
Post a Comment