This is a piece of Art called “Star Wars DNA”. Commissioned for a super fancy document.

library(ggplot2)
library(ggmap)

theme_set(theme_nothing())
S <- function(n = 25){
  s <- sample(x = c("g", "c", "t", "a"), size = n, 
              replace = TRUE, 
              prob = c(0.4, 0.4, 0.6, 0.6))
}
t <- ggplot() + scale_color_manual(values = c("red", "purple", "darkgreen", "orange")) + ylim(0, 2)
for(i in 1:10){
  s <- S()
  t <- t + geom_text(data = data.frame(s = s, x = 3*(seq(s) / i + length(s) - mean(seq(s)/i)), y = 1+i/(4+i)), 
                     aes(x = x, y = y, color = s, label = s), size = 11-i, alpha = 1-i/10)
}
t

plot of chunk unnamed-chunk-2

set.seed(1)
t <- ggplot() + scale_color_manual(values = c("red", "purple", "darkgreen", "orange")) + ylim(c(3,5))
for(i in 1:10){
  s <- S()
  t <- t + geom_text(data = data.frame(s = s, x = 5*(seq(s) /(i) + length(s) - mean(seq(s)/i)), y = 5-exp(0.85^(i*3))), 
                     aes(x = x, y = y, color = s, label = s), size = 12*exp(-i/5), alpha = 1-i/10)
}
t

plot of chunk unnamed-chunk-3

ggsave(file = "star-wars-dna.svg", plot = t, width = 8, height = 4)
library(RPostgreSQL)
dbcon <- dbConnect(drv = "PostgreSQL", 
                   dbname = "bety", 
                   user = "bety", 
                   host = "localhost", 
                   password = "bety")

result <- dbGetQuery(conn = dbcon, statement = "select * from traits_and_yields_view;")

head(result)

library(data.table)
R <- data.table(result)


library(lubridate)
table <- R[,list(variable = unique(trait), units = unique(units), mean = signif(mean(mean), 3), sd = signif(sd(mean), 3), n = length(mean), date = paste("2019-08-26")), by = trait_description][n>10][order(n, decreasing = TRUE)]


table$n <- 3
table <- table[!variable == "Ayield"]
library(pander)
panderOptions("table.style", "rmarkdown")
pander(table, split.tables = Inf)
s <- sample(x = c("g", "c", "t", "a"), size = 100, replace = TRUE)
s <- s[1:20]
ggplot() + geom_text(aes(1:20, 1, color = s, label = s))
library(data.table)
library(pander)
n <- 100
t <- data.table(accession = sample(x = 40000:70000, size = n),
           SLA = rnorm(n, 15, 2),
           leafN = rnorm(n, 2.5, 0.2),
           LAI = rnorm(n, 4,0.6),
           Rd = rnorm(n, 1.3, 0.3),
           Vmax = rnorm(n, 60, 5),
           ET = rnorm(n, 10,1),
           height = rnorm(n, 5,0.5),
           leaf_mass = rnorm(n, 60, 10),
           leaf_number = rpois(n, 15),
           stem_diameter = rnorm(n, 4, 1))
panderOptions("table.style", "rmarkdown")
pander(t, split.tables = Inf, signif = 2)
accession SLA leafN LAI Rd Vmax ET height leaf_mass leaf_number stem_diameter
62859 14.93 2.726 3.995 0.9044 64.93 8.567 4.51 61.86 11 3.656
67987 16.58 2.042 4.077 1.409 62.88 8.945 5.544 61.76 14 2.753
54119 19.15 2.648 3.912 1.37 70.12 9.267 5.07 69.16 12 4.843
58106 17.05 2.237 3.902 1.658 50.19 10.21 4.807 63.2 15 3.998
54548 17.42 2.684 5.058 1.292 54.18 9.001 5.562 56.33 16 4.492
43263 12.54 2.58 4.458 1.193 53.12 11.08 4.62 50.59 15 3.186
47430 16.97 2.418 4.667 0.956 60.84 8.801 5.574 66.35 13 3.57
54952 15.44 2.765 3.446 1.145 67.92 10.22 4.579 59.38 17 4.237
51183 12.07 2.36 4.099 1.191 68.39 10.14 5.196 61.83 16 2.246
68033 16.04 2.384 4.693 2.005 62.44 8.934 5.446 71.04 15 3.047
55714 14.68 2.3 3.966 2.034 64.39 9.571 4.332 77.52 11 3.371
49511 17.93 2.366 2.722 1.25 59.28 9.344 5.199 50.46 14 4.563
48335 13.47 2.689 4.207 0.9869 62.34 10.96 4.944 76.44 25 3.047
63616 14.14 2.587 2.857 0.7081 61.88 11.56 5.338 51.33 12 2.905
61064 13.15 2.701 3.513 1.454 56.19 8.959 4.606 62.66 14 4.412
44948 14.65 2.422 4.794 0.9728 58.53 10.93 4.957 62.22 15 3.234
41932 15.8 2.575 4.369 1.985 59.33 9.925 5.691 57.23 18 5.007
62629 13.54 2.549 4.655 1.034 66.97 8.033 5.084 73.94 11 2.301
58601 16.66 2.215 4.184 1.333 54.82 9.244 5.412 53.41 13 3.616
45084 12.58 2.856 3.934 2.443 49.43 10.46 4.89 66.61 9 3.191
41865 12.9 2.527 3.445 0.9673 63.84 10.15 4.485 59.87 13 3.475
43268 17.88 2.653 4.956 1.392 55.92 7.558 4.995 50.69 22 4.715
51443 12.97 2.691 4.027 0.9679 57.82 10.58 4.388 72.15 14 4.702
45075 15.82 2.49 3.571 1.404 64.52 10.66 3.702 39.12 21 3.231
48952 14.24 2.439 4.519 1.038 56.18 9.695 5.585 54.74 8 2.123
45761 15.82 2.679 4.645 1.323 58.29 9.292 4.457 44.59 15 3.229
47708 18.38 2.291 5.137 1.211 67.51 11.97 4.087 61.94 13 5.334
45432 18.17 2.894 3.638 0.945 62.64 9.91 5.498 62.64 25 3.98
54306 14.34 2.423 3.765 1.303 62.71 9.986 4.994 48.81 14 3.118
63100 10.43 2.831 3.75 1.597 59.32 8.877 4.7 66.51 16 4.009
40832 20 2.802 3.775 1.778 54.32 8.656 4.911 49.67 9 4.823
55803 16.33 2.517 3.78 0.8882 52.52 8.477 4.787 66.59 27 5.865
66382 16.08 2.613 3.823 1.225 58.88 9.578 5.498 62.38 19 4.541
51179 14.97 2.295 4.865 1.648 70.01 11.36 5.364 67.15 16 3.01
41437 16.02 2.565 3.581 0.9657 61.11 11.75 4.137 50.62 10 6.277
44154 14.67 2.709 3.767 0.5414 60.82 11.57 5.177 60.95 12 4.088
49633 15.84 2.52 4.392 1.019 61.66 11.3 5.363 55.37 9 5.421
44639 14.2 2.409 4.675 1.01 58.07 9.762 5.334 45.31 12 5.302
43961 12.26 2.369 3.537 1.314 53.01 8.776 3.788 61.53 13 1.962
46630 16.98 2.493 3.695 1.179 73.38 9.672 4.882 77.74 11 5.641
46782 18.04 2.714 4.314 1.369 57.88 7.588 5.99 53.52 15 3.89
43937 14.38 2.403 4.611 1.173 58.51 9.686 5.398 58 6 3.162
69406 12.49 2.476 3.849 1.412 51.04 11.66 4.145 66.89 14 4.075
49796 16.28 2.241 3.142 1.19 58.76 10.13 4.168 60.36 18 4.081
55186 14.91 2.599 5.025 1.657 58.76 11.1 5.246 79.44 21 4.026
60413 11.53 2.762 4.861 1.079 58.72 10.49 4.913 67.37 14 3.852
42970 15 2.799 3.574 1.387 51.07 9.221 5.481 83.21 16 5.503
43561 13.74 2.663 3.961 1.035 68.92 11.74 5.147 63.49 16 5.032
41510 14.32 2.126 2.944 1.362 68.82 9.922 5.04 48.66 11 4.337
67833 12.69 2.596 4.342 1.286 63.45 9.024 5.092 64.21 15 3.419
60178 18.61 2.591 4.967 0.7946 54.5 10.07 5.083 50.75 15 5.245
42840 14.34 2.429 3.018 1.257 63.57 8.481 4.365 49.93 16 4.691
54752 11.79 2.534 3.532 1.654 58.77 10.86 6.175 58.11 22 3.583
53822 15.39 2.327 3.615 1.504 58.4 10.5 4.294 69.34 15 3.51
51236 15.53 2.636 3.591 1.343 66.81 9.645 4.992 63.44 15 3.758
69679 13.03 2.435 2.78 0.9423 53.86 9.512 4.728 68.14 11 3.847
45280 9.222 2.186 4.301 1.651 57.44 10.94 5.9 69.15 12 4.39
64357 13.72 2.427 3.081 1.324 56.34 8.938 5.506 58.28 14 4.89
42049 16.14 2.773 3.985 1.164 60.1 9.016 4.718 35.98 19 4.225
51990 14.88 2.433 4.356 1.793 52.14 10.42 5.103 67.96 12 2.321
44226 14.8 2.647 3.881 1.069 56.48 9.549 5.583 81.69 18 4.36
45787 16.12 2.689 4.535 1.391 63.58 10.93 6.118 60.58 18 5.109
65189 12.63 2.501 3.985 1.685 62.33 9.801 5.151 46.45 11 2.694
61552 17.19 2.43 3.611 1.481 55.13 11.19 4.479 56.32 19 2.112
47999 14.99 2.394 4.388 1.208 62.8 10.5 4.508 50.65 12 4.794
54818 16.41 2.648 3.74 1.174 47.84 7.755 6.003 59.58 17 3.615
42488 17.07 2.287 5.064 1.407 58.3 8.665 3.965 66.76 17 4.515
50593 15.45 2.549 3.989 1.454 63.57 11.28 6.528 68.66 18 3.763
69011 13.24 2.442 4.512 1.306 56.7 10.69 4.869 62.35 13 5.742
58698 17.33 2.047 4.123 1.696 59.82 9.033 4.773 50.66 22 5.204
59892 11 2.218 2.195 1.28 52.03 8.654 5.079 68.13 14 4.656
49352 13.91 2.683 3.18 1.09 64.24 11.03 5.467 73.48 11 4.839
52141 14.49 2.462 3.746 1.461 50.75 9.188 5.151 82.52 14 4.959
69810 14.67 2.661 4.142 0.6395 58.38 11.8 4.022 55.06 15 5.136
65590 17.04 2.877 2.594 1.418 58.72 11.77 5.177 64.74 21 3.074
68535 15.27 2.795 4.577 1.449 60.3 8.545 5.225 71.94 11 5.594
64308 15.81 2.635 3.637 1.233 55.88 9.154 5.33 58.84 11 2.584
63406 14.86 2.576 3.548 0.9649 69.15 8.75 4.484 65.25 17 1.852
48015 14.5 2.461 3.067 1.182 52.85 10.67 3.814 62.14 14 3.815
62805 16.39 2.816 3.128 1.765 61.27 8.709 4.838 58.66 17 4.634
69511 17.29 2.619 4.034 1.077 45.3 7.965 4.528 61.69 14 4.402
48784 10.19 2.265 4.306 0.6005 60.01 12.02 4.617 69.65 16 4.589
51948 16.15 2.469 2.741 1.544 62.55 11.01 4.523 64.09 15 4.109
64297 15.75 2.116 3.397 1.15 54.58 10.82 4.801 55.34 15 3.402
42308 14.15 2.461 4.321 1.147 63.52 9.336 4.844 37.6 12 4.149
50880 16.9 1.982 3.728 0.9354 61.65 9.989 5.398 52.05 15 5.811
53240 14.22 2.763 5.299 1.293 64.88 10.62 5.493 59.8 12 3.729
44687 14.43 2.373 4.747 1.51 55.78 8.719 4.603 34.86 15 4.5
57415 16.71 2.414 4.357 1.124 55.15 9.876 4.846 82.11 21 4.497
69019 18.44 2.466 4.003 1.118 51.14 10.18 5.181 45.11 17 5.229
69596 15.54 2.622 4.168 1.629 58.39 11.69 5.699 48.39 13 2.911
45277 14.16 2.636 3.576 1.226 53.31 10.64 4.972 74.58 14 3.628
56214 12.62 2.614 4.377 1.252 63.44 11.28 4.151 38.1 14 4.292
51493 14.34 2.385 4.888 1.112 60.36 10.14 5.116 67.39 6 3.582
60222 13.12 2.227 4.65 1.57 70.95 8.887 4.94 56.56 19 4.185
48053 14.48 2.422 3.512 1.002 54.21 9.66 5.886 64.56 10 3.749
54032 15.79 2.556 3.029 1.555 65.91 8.335 5.172 68.78 16 3.041
45137 13.3 2.335 3.934 1.542 57.36 10.93 4.688 50.42 15 2.38
51039 20.3 2.486 4.265 1.16 52.72 11.42 4.78 52.94 10 4.823
61691 15.31 2.266 4.811 1.555 62.86 9.937 4.747 30.03 14 4.109