citationchaser
citationchaser copied to clipboard
Colour the edges and not the nodes in the network
https://twitter.com/aarontay/status/1361958669655531522?s=20
......linkColour = edges_col) # edge colors
Can we keep the node colour, but somehow highlight input nodes (diff symbol/emphasis/...)?
@nealhaddaway I have got this code running but I cant work out how to get the input_ids from the data in the shiny
` library(networkD3) library(tidyverse) library(here) network <- readRDS(paste0(here(),"/inst/shiny-examples/citationchaser/network.RDS")) head(network) input_ids=c("050-168-647-208-295", "109-839-221-635-410") # This needs to come from the data tmp1<-data.frame("IDs"=network$input_lensID, "Group"= network$type) tmp2<-data.frame("IDs"=network$reference_lensID, "Group"= network$type) tmp=rbind(tmp1,tmp2) Nodes=unique(tmp) Nodes=Nodes %>% mutate(Group2=ifelse(IDs%in%input_ids, 0, Group)) %>% mutate(Group2=as.character(Group2)) %>% mutate(Group2=dplyr::recode(Group2, "0"="input", "1"="reference", "2"="citation"))
make a links data frame using the indexes (0-based) of nodes in 'nodes'
links <- data.frame(source = match(network$input_lensID, Nodes$IDs) - 1,
target = match(network$reference_lensID,Nodes$IDs) - 1)
links<-links %>%
drop_na()
n_net<-forceNetwork(Links = links, Nodes = Nodes, Source = "source",
Target = "target", NodeID ="IDs", Group="Group2",
linkColour = "black", opacity = 1, opacityNoHover = 1, zoom=TRUE, legend=TRUE,colourScale = JS('d3.scaleOrdinal().range(["black", "#a50026","#4575b4"]);'))
n_net
`
Woot! It should be:
input$article_ids
Great I shall give that a go! Also for the hyperlink to the article can we use the lensID pasted at the end of a url or do they use another method? I can get all the nodes to link to my website....(not very useful I know!)
You can paste0()
it into the URL below - this should work:
link <- paste0('https://www.lens.org/lens/search/scholar/list?q=lens_id:', lens_id, '&p=0&n=10&s=_score&d=%2B&f=false&e=false&l=en&authorField=author&dateFilterField=publishedYear&orderBy=%2B_score&presentation=false&stemmed=true&useAuthorId=false')
@nealhaddaway Cool we have links!!!!!!!!!!!!!!!!!!!!!!! Woohoo!!! Minor problem is that input$article_ids gives me doi and not the lens_id. Where does that conversion happen?
@nealhaddaway Cool we have links!!!!!!!!!!!!!!!!!!!!!!! Woohoo!!! Minor problem is that input$article_ids gives me doi and not the lens_id. Where does that conversion happen?
Don't worry - turns out I am an idiot. Have a play with my new branch - I will push it up now and do pull request (maybe useful to wait to merge to see if this is working as expected for a bigger dataset).
#11 Add links to nodes solves this issue (hopefully)