Skip to content

Commit 13c50fc

Browse files
committed
Merge branch 'production'
2 parents 7aef2a6 + d098ce3 commit 13c50fc

8 files changed

Lines changed: 175 additions & 114 deletions

File tree

flo_evals.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
floevals,,,,,,,,,,,,,,,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,01,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1

floattr.rds

87 Bytes
Binary file not shown.

floevals.rds

203 Bytes
Binary file not shown.

sW_access.Rmd

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: "Accessing statnetWeb"
3+
author: "Emily Beylerian"
4+
output: html_document
5+
---
6+
7+
### From the web
8+
9+
No installation of R or RStudio necessary.
10+
11+
https://ebey.shinyapps.io/statnetWeb/
12+
13+
Issues:
14+
15+
* Refreshing page results in loss of data/results
16+
* Page might timeout
17+
* Need internet access
18+
19+
### From RStudio
20+
#### On your own computer
21+
22+
Must have R and RStudio installed, as well as the following packages necessary for the app to run:
23+
24+
* statnet (ergm, network, sna)
25+
* shiny
26+
* shinythemes (necessary?)
27+
* RColorBrewer
28+
* lattice
29+
* latticeExtra
30+
31+
```
32+
install.packages(c("statnet","shiny","shinythemes","RColorBrewer","lattice","latticeExtra"))
33+
```
34+
35+
Session will not time-out,

server.R

Lines changed: 68 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -161,42 +161,32 @@ nwinit <- reactive({
161161
} else {
162162
filepath <- input$rawdatafile[1,4]
163163
filename <- input$rawdatafile[1,1]
164-
}
165-
if(input$filetype == 1){
166-
loadfile <- ''
167-
if(!is.null(input$rawdatafile)){
168-
nw_var <- tryCatch({
169-
obj <- load(paste(filepath))
170-
}, error = function(err){
171-
return("Chosen file is not an R object")
172-
}, finally = NULL
173-
)
174-
try(nw_var <- get(obj))
175-
}
176-
} else if(input$filetype == 2){
177-
if(!is.null(input$rawdatafile)){
164+
fileext <- substr(filename,nchar(filename)-3,nchar(filename))
165+
166+
if(input$filetype == 1){
167+
if(fileext %in% c(".rds", ".Rds", ".RDs", ".RDS")){
168+
nw_var <- readRDS(paste(filepath))
169+
} else {
170+
return("Upload a .rds file")
171+
}
172+
173+
} else if(input$filetype == 2){
178174
nw_var <- "Upload a .net file"
179-
if(substr(filename,nchar(filename)-3,nchar(filename))==".net" |
180-
substr(filename,nchar(filename)-3,nchar(filename))==".NET"){
175+
if(fileext %in% c(".net", ".NET")){
181176
nw_var <- read.paj(paste(filepath))
182177
}
183-
}
184-
} else if(input$filetype == 3){
185-
if(!is.null(input$rawdatafile)){
178+
} else if(input$filetype == 3){
186179
nw_var <- "Upload a .paj file"
187-
if(substr(filename,nchar(filename)-3,nchar(filename))==".paj" |
188-
substr(filename,nchar(filename)-3,nchar(filename))==".PAJ"){
180+
if(fileext %in% c(".paj",".PAJ")){
189181
nws <- read.paj(paste(filepath))
190182
if(!is.null(pajnws())){
191183
nw_var <- nws$networks[[as.numeric(input$choosepajnw)]]
192184
}
193185
}
194-
}
195-
} else if(input$filetype == 4){
196-
loadfile <- ''
197-
if(!is.null(input$rawdatafile)){
186+
187+
} else if(input$filetype == 4){
198188
nw_var <- "Input the specified type of matrix"
199-
if(substr(filename,nchar(filename)-3,nchar(filename))==".csv"){
189+
if(fileext %in% c(".csv",".CSV")){
200190
header <- TRUE
201191
row_names<-1
202192
if(input$matrixtype == "edgelist"){
@@ -210,24 +200,24 @@ nwinit <- reactive({
210200
ignore.eval=FALSE, names.eval='edgevalue')
211201
})
212202

213-
}
214-
try({
215-
newmx <- load(paste(filepath))
216-
nw_var <- network(get(newmx),
203+
} else if(fileext %in% c(".rds", ".Rds", ".RDs", ".RDS")){
204+
newmx <- readRDS(paste(filepath))
205+
nw_var <- network(newmx,
217206
directed=input$dir, loops=input$loops,
218207
multiple=input$multiple, bipartite=input$bipartite,
219208
matrix.type=input$matrixtype,
220209
ignore.eval=FALSE, names.eval='edgevalue')
221-
})
222-
}
210+
211+
}
223212

224-
} else if(input$filetype ==5){
225-
if(input$samplenet == "None"){
226-
nw_var <- NULL
227-
} else {
228-
nw_var <- eval(parse(text = input$samplenet))
229-
if(!is.element('bipartite',names(nw_var$gal))){
230-
set.network.attribute(nw_var,'bipartite',FALSE)
213+
} else if(input$filetype ==5){
214+
if(input$samplenet == "None"){
215+
nw_var <- NULL
216+
} else {
217+
nw_var <- eval(parse(text = input$samplenet))
218+
if(!is.element('bipartite',names(nw_var$gal))){
219+
set.network.attribute(nw_var,'bipartite',FALSE)
220+
}
231221
}
232222
}
233223
}
@@ -320,18 +310,24 @@ newattrnamereac <- reactive({
320310
try({
321311
path <- input$newattrvalue[1,4]
322312
filename <- input$newattrvalue[1,1]
313+
fileext <- substr(filename,nchar(filename)-3,nchar(filename))
323314

324-
if(substr(filename,nchar(filename)-3,nchar(filename))==".csv"){
315+
if(fileext %in% c(".csv", ".CSV") ){
325316
newattrs <- read.csv(paste(path), sep=",", header=TRUE, stringsAsFactors=FALSE)
326317
newname <- names(newattrs)
327-
} else {
328-
objname <- load(paste(path))
329-
newattrs <- get(objname)
318+
if(input$newattrtype == "edgevalue"){
319+
newname <- newname[1]
320+
}
321+
} else if(fileext %in% c(".rds",".Rds",".RDs",".RDS") ){
322+
newattrs <- readRDS(paste(path))
330323
newname <- names(newattrs)
331324
if(class(newattrs) != "list"){
332325
newname <- "Attribute is not compatible, see help buttons and try again"
333326
}
327+
} else {
328+
newname <- "Attribute is not compatible, see help buttons and try again"
334329
}
330+
335331
})
336332
if(is.null(newname)){
337333
newname <- "Attribute is not named, please fix and re-upload"
@@ -340,40 +336,33 @@ newattrnamereac <- reactive({
340336
})
341337

342338
#save new vertex names
343-
observe({
344-
if(input$newattrButton == 0) return()
345-
isolate({
346-
if(input$newattrtype == 'vertex names'){
339+
observeEvent(input$newattrButton, {
340+
if(input$newattrtype == "vertexnames"){
347341
path <- input$newattrvalue[1,4]
348342
filename <- input$newattrvalue[1,1]
349-
350-
if(substr(filename,nchar(filename)-3,nchar(filename))==".csv"){
343+
fileext <- substr(filename,nchar(filename)-3,nchar(filename))
344+
if(fileext %in% c(".csv", ".CSV")){
351345
newnames <- read.csv(paste(path), sep=",", header=TRUE, stringsAsFactors=FALSE)
352346
newnames <- newnames[[1]]
353-
} else {
354-
objname <- load(paste(path))
355-
newnames <- get(objname)
347+
} else if(fileext %in% c(".rds",".Rds",".RDs",".RDS")){
348+
newnames <- readRDS(paste(path))
356349
}
357350

358351
values$vertexnames <- newnames
359352
}
360-
})
361353
})
362354

363355
#add vertex attributes to list
364-
observe({
365-
if(input$newattrButton == 0) return()
366-
isolate({
367-
if(input$newattrtype == 'vertex attribute'){
356+
observeEvent(input$newattrButton, {
357+
if(input$newattrtype == "vertexattr"){
368358
path <- input$newattrvalue[1,4]
369359
filename <- input$newattrvalue[1,1]
370-
371-
if(substr(filename,nchar(filename)-3,nchar(filename))==".csv"){
360+
fileext <- substr(filename,nchar(filename)-3,nchar(filename))
361+
if(fileext %in% c(".csv", ".CSV")){
372362
newattrs <- read.csv(paste(path), sep=",", header=TRUE, stringsAsFactors=FALSE)
373363
newname <- names(newattrs)
374-
} else {
375-
objname <- load(paste(path))
376-
newattrs <- get(objname)
364+
} else if(fileext %in% c(".rds",".Rds",".RDs",".RDS")){
365+
newattrs <- readRDS(paste(path))
377366
newname <- names(newattrs)
378367
}
379368

@@ -387,23 +376,19 @@ observe({
387376
values$v_attrNamesToAdd <- namesofar
388377
values$v_attrValsToAdd <- valsofar
389378
}
390-
})
391379
})
392380

393381
#add edge attributes to list
394-
observe({
395-
if(input$newattrButton == 0) return()
396-
isolate({
397-
if(input$newattrtype == 'edge attribute'){
382+
observeEvent(input$newattrButton, {
383+
if(input$newattrtype == "edgeattr"){
398384
path <- input$newattrvalue[1,4]
399385
filename <- input$newattrvalue[1,1]
400-
401-
if(substr(filename,nchar(filename)-3,nchar(filename))==".csv"){
386+
fileext <- substr(filename,nchar(filename)-3,nchar(filename))
387+
if(fileext %in% c(".csv", ".CSV")){
402388
newattrs <- read.csv(paste(path), sep=",", header=TRUE, stringsAsFactors=FALSE)
403389
newname <- names(newattrs)
404-
} else {
405-
objname <- load(paste(path))
406-
newattrs <- get(objname)
390+
} else if(fileext %in% c(".rds",".Rds",".RDs",".RDS")){
391+
newattrs <- readRDS(paste(path))
407392
newname <- names(newattrs)
408393
}
409394

@@ -416,23 +401,20 @@ observe({
416401
values$e_attrNamesToAdd <- namesofar
417402
values$e_attrValsToAdd <- valsofar
418403
}
419-
})
420404
})
421405

422406
#add edge values to list
423-
observe({
424-
if(input$newattrButton == 0) return()
425-
isolate({
426-
if(input$newattrtype == 'edge value'){
407+
observeEvent(input$newattrButton, {
408+
if(input$newattrtype == "edgevalue"){
427409
path <- input$newattrvalue[1,4]
428410
filename <- input$newattrvalue[1,1]
429-
430-
if(substr(filename,nchar(filename)-3,nchar(filename))==".csv"){
411+
fileext <- substr(filename,nchar(filename)-3,nchar(filename))
412+
if(fileext %in% c(".csv", ".CSV")){
431413
newattrs <- read.csv(paste(path), sep=",", header=TRUE, stringsAsFactors=FALSE)
432-
newname <- names(newattrs)
433-
} else {
434-
objname <- load(paste(path))
435-
newattrs <- get(objname)
414+
newname <- names(newattrs)[1]
415+
newattrs <- data.matrix(newattrs, rownames.force=FALSE)
416+
} else if(fileext %in% c(".rds",".Rds",".RDs",".RDS")){
417+
newattrs <- readRDS(paste(path))
436418
newname <- names(newattrs)
437419
}
438420
namesofar <- values$ev_attrNamesToAdd
@@ -445,7 +427,6 @@ observe({
445427
values$ev_attrNamesToAdd <- namesofar
446428
values$ev_attrValsToAdd <- valsofar
447429
}
448-
})
449430
})
450431

451432
observeEvent(input$symmdir,{
@@ -2776,12 +2757,14 @@ output$gofplotcomp <- renderPlot({
27762757
if(is.directed(nw())){
27772758
cols <- isolate(4)
27782759
bottomtext <- c("idegree","odegree","espartners","distance")
2760+
bottommat <- c(0,(n*cols+1):(n*cols+4))
27792761
} else {
27802762
cols <- isolate(3)
27812763
bottomtext <- c("degree","espartners","distance")
2764+
bottommat <- c(0,(n*cols+1):(n*cols+3))
27822765
}
27832766
innermat <- matrix(1:(n*cols),ncol=cols, byrow=TRUE)
2784-
bottommat <- c(0,(n*cols+1):(n*cols+3))
2767+
27852768
} else {
27862769
cols <- isolate(1)
27872770
innermat <- matrix(1:n,ncol=1,nrow=n, byrow=TRUE)

0 commit comments

Comments
 (0)