What would you do? If my heart was torn in two (More Than Words, Extreme)
Playing with rCharts
package I had the idea of representing the list of 100 best love songs as a connected set of points which forms a heart. Songs can be seen putting mouse cursor over each dot:
You can reproduce it with this simple code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | library (dplyr) library (rCharts) library (rvest) setwd ( "YOUR WORKING DIRECTORY HERE" ) heart <- function (r,x) { ifelse ( abs (x)<2, ifelse (r%%2==0, sqrt (1-( abs (x)-1)^2), acos (1- abs (x))- pi ), 0)} data.frame (x= seq (from=-3, to=3, length.out=100)) %>% mutate (y= jitter ( heart ( row_number (), x), amount=.1)) -> df html_nodes ( "table" ) %>% .[[2]] %>% html_table (header= TRUE , fill = TRUE ) %>% cbind (df) -> df m1= mPlot (x = "x" , y = "y" , data = df, type = "Line" ) m1$ set (pointSize = 5, lineColors = c ( 'red' , 'red' ), width = 850, height = 600, lineWidth = 2, hoverCallback = " #! function(index, options, content){ var row = options.data[index] return '<b>' + row.ARTIST + '</b>' + '<br/>' + row.TITLE} ! #", grid= FALSE , axes= FALSE ) m1$ save ( 'Top_100_Greatest_Love_Songs.html' , standalone = TRUE ) |