---
title: "Code for Session 10"
author: "Dr. Richard M. Crowley"
date: ""
output:
  html_notebook
---

Note that the directories used to store data are likely different on your computer, and such references will need to be changed before using any such code.

```{r helpers, warning=FALSE, message=F}
library(knitr)
library(kableExtra)
html_df <- function(text, cols=NULL, col1=FALSE, full=F) {
  if(!length(cols)) {
    cols=colnames(text)
  }
  if(!col1) {
    kable(text,"html", col.names = cols, align = c("l",rep('c',length(cols)-1))) %>%
      kable_styling(bootstrap_options = c("striped","hover"), full_width=full)
  } else {
    kable(text,"html", col.names = cols, align = c("l",rep('c',length(cols)-1))) %>%
      kable_styling(bootstrap_options = c("striped","hover"), full_width=full) %>%
      column_spec(1,bold=T)
  }
}
```

```{r}
library(tidyverse)
```

```{r ending, warning = FALSE, message = FALSE}
library(visNetwork)
nodes <- list(id=list.files('../Figures/Logos/TensorFlow'))
nodes$group <- "TF"
nodes$id <- c(nodes$id,list.files('../Figures/Logos/PyTorch'))
nodes$group[nodes$group != 'TF'] = 'PT'
edges = list("to"=c(), "from"=c())
nodes <- as.data.frame(nodes,stringsAsFactors=FALSE)
edges <- as.data.frame(edges,stringsAsFactors=FALSE)
nodes$image.unselected <- paste('Icons-',nodes$group,'/',nodes$id,sep='')
nodes$shape <- "image"
visNetwork(nodes, edges, width="100%", height="600px")
```

```{r}
wv <- data.frame(words = c('dog', 'cat', 'Bill', 'turkey', 'Turkey', "Singapore"),
                 f_animal = c(0.5, 0.5, 0.1, 0.5, -0.5, -0.5),
                 f_people = c(0.3, 0.1, 0.9, -0.2, 0.1, 0.1),
                 f_location = c(-0.3, -0.3, -0.4, -0.3, 0.7, 0.8))
html_df(wv)
```

