r

Check which community a node belongs in louvain community detection

♀尐吖头ヾ 提交于 2021-02-10 15:48:26
问题 So I have run louvain detection on my dataset and returns a bunch of communities with nodes included. My question is, given a node, how do you find which community it belongs to? Thanks. 回答1: The community for each node is stored in the membership component of the result. library(igraph) set.seed(1234) G = erdos.renyi.game(16, 0.22) C = cluster_louvain(G) plot(G, vertex.color=rainbow(3,alpha=0.4)[C$membership]) 来源: https://stackoverflow.com/questions/52245816/check-which-community-a-node

Check which community a node belongs in louvain community detection

人盡茶涼 提交于 2021-02-10 15:47:52
问题 So I have run louvain detection on my dataset and returns a bunch of communities with nodes included. My question is, given a node, how do you find which community it belongs to? Thanks. 回答1: The community for each node is stored in the membership component of the result. library(igraph) set.seed(1234) G = erdos.renyi.game(16, 0.22) C = cluster_louvain(G) plot(G, vertex.color=rainbow(3,alpha=0.4)[C$membership]) 来源: https://stackoverflow.com/questions/52245816/check-which-community-a-node

automatically convert polynomial to expression in ggplot2 title

喜欢而已 提交于 2021-02-10 15:40:43
问题 Here is some code I am using to auto generate some regression fits; require(ggplot2) # Prep data nPts = 200 prepared=runif(nPts,0,10) rich=5-((prepared-5)^2)/5 + 5*runif(length(prepared)) df <- data.frame(rich=rich, prepared=prepared) deg = 1 # User variable lm <- lm(df$rich ~ poly(df$prepared, deg, raw=T)) # Create expression coefs <- lm$coefficients eq <- paste0(round(coefs,2),'*x^', 0:length(coefs), collapse='+') # (1) pl <- ggplot(df, aes(x=prepared, y=rich)) + geom_point() + geom_smooth

Biostrings gregexpr2 gives errors while gregexpr works fine

ε祈祈猫儿з 提交于 2021-02-10 15:38:43
问题 I'm replacing gregexpr with gregexpr2 to detect overlapping matches. When I try. >subSeq 3000-letter "DNAString" instance seq: ACACGTGTTCTATTTTCATTTGCTGACATTTTCTAGTGCATCATTTTTTATTTTATTTTCATT.... gregexpr2("TAAT|ATTA",subSeq) Error in matches[[i]] : subscript out of bounds whereas gregexpr("TAAT|ATTA",subSeq) works fine. What happened? 回答1: It is quite clear if you read gregexpr2 documentation: This is a replacement for the standard gregexpr function that does exact matching only. Standard

Biostrings gregexpr2 gives errors while gregexpr works fine

廉价感情. 提交于 2021-02-10 15:36:50
问题 I'm replacing gregexpr with gregexpr2 to detect overlapping matches. When I try. >subSeq 3000-letter "DNAString" instance seq: ACACGTGTTCTATTTTCATTTGCTGACATTTTCTAGTGCATCATTTTTTATTTTATTTTCATT.... gregexpr2("TAAT|ATTA",subSeq) Error in matches[[i]] : subscript out of bounds whereas gregexpr("TAAT|ATTA",subSeq) works fine. What happened? 回答1: It is quite clear if you read gregexpr2 documentation: This is a replacement for the standard gregexpr function that does exact matching only. Standard

Biostrings gregexpr2 gives errors while gregexpr works fine

萝らか妹 提交于 2021-02-10 15:36:15
问题 I'm replacing gregexpr with gregexpr2 to detect overlapping matches. When I try. >subSeq 3000-letter "DNAString" instance seq: ACACGTGTTCTATTTTCATTTGCTGACATTTTCTAGTGCATCATTTTTTATTTTATTTTCATT.... gregexpr2("TAAT|ATTA",subSeq) Error in matches[[i]] : subscript out of bounds whereas gregexpr("TAAT|ATTA",subSeq) works fine. What happened? 回答1: It is quite clear if you read gregexpr2 documentation: This is a replacement for the standard gregexpr function that does exact matching only. Standard

two column bipartite layout with igraph

China☆狼群 提交于 2021-02-10 15:28:35
问题 I'm trying to plot a bipartite graph, but with two columns; the function manual states that layout_as_bipartite() "Minimize[s] edge-crossings in a simple two-row (or column) layout for bipartite graphs." Trying with the example, I can only get two row graphs: library(igraph) library(dplyr) # Random bipartite graph inc <- matrix(sample(0:1, 50, replace = TRUE, prob=c(2,1)), 10, 5) g <- graph_from_incidence_matrix(inc) plot(g, layout = layout_as_bipartite, vertex.color=c("green","cyan")[V(g)

R/plotly: Dragging Sliders Instead of Autoplay

守給你的承諾、 提交于 2021-02-10 15:16:23
问题 I am working with the R programming language. Using this previously asked question on stackoverflow ( Slider for Plotly R), I was able to make a "slider animation" (using the "plotly" library) for different values of (a variable called) "var" within the data set: #load libraries library(plotly) library(dplyr) library(ggplot2) #generate data var = rnorm(731, 100,25) date= seq(as.Date("2014/1/1"), as.Date("2016/1/1"),by="day") data = data.frame(var,date) #aggregate data aggregate = data %>%

local image in shiny app without img(src())?

别说谁变了你拦得住时间么 提交于 2021-02-10 15:14:22
问题 I would like to include a local image file in my shiny app, following these instructions: Embedding Image in Shiny App However, my IT networks security, for some reason, prevents R from reading that image. I can confirm it is an IT security blockage, because the same exact code and file/directory structure works when I move to another computer. It is also strange, because I am able to read other files from that folder, because other commands like read.csv() are not blocked. I dont know what

How to get mean for all participants after selecting only a certain number of trials

♀尐吖头ヾ 提交于 2021-02-10 15:13:52
问题 I have a dataset of 500 trials per participant that I want to sample from in various quantities (i.e. I want to sample the same number of trials from each participant) and then compute the mean for each participant. Instead of doing so, it is creating a file with a one mean for each participant separately for each "num", e.g. if the mean for participant 1 with 125 trials is 426 that will be the whole file, then another file for participant 1 with 150 trials with a single value, and that is