User Tools

Site Tools


sna_eg_stanford:lab01

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
sna_eg_stanford:lab01 [2019/12/11 08:33] – [no pdf] hkimscilsna_eg_stanford:lab01 [2022/11/28 22:26] (current) hkimscil
Line 82: Line 82:
 # directly by referencing the URL in the read.table() function, # directly by referencing the URL in the read.table() function,
 # as follows:  # as follows: 
-advice_data_frame <- read.table('http://sna.stanford.edu/sna_R_labs/data/Krack-High-Tec-edgelist-Advice.txt'+advice_data_frame <- read.table('http://sna.stanford.edu/sna_R_labs/data/Krack-High-Tec-edgelist-Advice.txt'
-friendship_data_frame <- read.table('http://sna.stanford.edu/sna_R_labs/data/Krack-High-Tec-edgelist-Friendship.txt'+friendship_data_frame <- read.table('http://sna.stanford.edu/sna_R_labs/data/Krack-High-Tec-edgelist-Friendship.txt'
-reports_to_data_frame <- read.table('http://sna.stanford.edu/sna_R_labs/data/Krack-High-Tec-edgelist-ReportsTo.txt'+reports_to_data_frame <- read.table('http://sna.stanford.edu/sna_R_labs/data/Krack-High-Tec-edgelist-ReportsTo.txt') 
- + 
 +advice_data_frame <- read.table('https://www.stat.cmu.edu/~brian/780/stanford%20social%20network%20labs/00%20data/Krack-High-Tec-edgelist-Advice.txt'
 +friendship_data_frame <- read.table('https://www.stat.cmu.edu/~brian/780/stanford%20social%20network%20labs/00%20data/Krack-High-Tec-edgelist-Friendship.txt'
 +reports_to_data_frame <- read.table('https://www.stat.cmu.edu/~brian/780/stanford%20social%20network%20labs/00%20data/Krack-High-Tec-edgelist-ReportsTo.txt'
 + 
 + 
 + 
 # If the files you want to work with are on your local machine,  # If the files you want to work with are on your local machine, 
 # the easiest way to access them is to first set your working  # the easiest way to access them is to first set your working 
Line 114: Line 121:
 # header=T, which tells R that the first row of data contains # header=T, which tells R that the first row of data contains
 # column names. # column names.
-attributes <- read.csv('http://sna.stanford.edu/sna_R_labs/data/Krack-High-Tec-Attributes.csv', header=T)+attributes <- read.csv('http://sna.stanford.edu/sna_R_labs/data/Krack-High-Tec-Attributes.csv', header=T) 
 +attributes <- read.csv('https://www.stat.cmu.edu/~brian/780/stanford%20social%20network%20labs/00%20data/Krack-High-Tec-Attributes.csv', header=T)
 attributes attributes
- + 
 # Other commands may be used to load data from files in different  # Other commands may be used to load data from files in different 
 # formats. read.delim() is a general function for loading any # formats. read.delim() is a general function for loading any
Line 303: Line 312:
  
 # example: setwd("/Users/seanwestwood/Desktop/lab_1") # example: setwd("/Users/seanwestwood/Desktop/lab_1")
-setwd("")+setwd("")
      
 # First, let's plot the network with all possible ties. # First, let's plot the network with all possible ties.
 pdf("1.1_Krackhardt_Full.pdf") pdf("1.1_Krackhardt_Full.pdf")
-plot(krack_full)+plot(krack_full, main="krack_full")
 dev.off() dev.off()
    
Line 319: Line 328:
 summary(krack_advice_only) summary(krack_advice_only)
 pdf("1.2_Krackhardt_Advice.pdf") pdf("1.2_Krackhardt_Advice.pdf")
-plot(krack_advice_only)+plot(krack_advice_only, main="krack advice only")
 dev.off() dev.off()
    
Line 328: Line 337:
 summary(krack_friendship_only) summary(krack_friendship_only)
 pdf("1.3_Krackhardt_Friendship.pdf") pdf("1.3_Krackhardt_Friendship.pdf")
-plot(krack_friendship_only)+plot(krack_friendship_only, main="krack_friendship_only")
 dev.off() dev.off()
  
Line 337: Line 346:
 summary(krack_reports_to_only) summary(krack_reports_to_only)
 pdf("1.4_Krackhardt_Reports.pdf") pdf("1.4_Krackhardt_Reports.pdf")
-plot(krack_reports_to_only)+plot(krack_reports_to_only, main="krack_reports_to_only")
 dev.off() dev.off()
    
Line 559: Line 568:
  
 # To view your data in a spreadsheet-like window, use the command 'fix()' # To view your data in a spreadsheet-like window, use the command 'fix()'
-fix(reports_to_data_frame)+fix(reports_to_data_frame)
  
 # The attribute data for this lab is in a comma-separated-value # The attribute data for this lab is in a comma-separated-value
Line 608: Line 617:
 # Take a look at each data frame using the 'fix()" function. Note that you'll  # Take a look at each data frame using the 'fix()" function. Note that you'll 
 # need to close each fix window before R will evaluate the next line of code. # need to close each fix window before R will evaluate the next line of code.
-fix(advice_data_frame) + 
-fix(friendship_data_frame) +fix(advice_data_frame) 
-fix(reports_to_data_frame)+fix(friendship_data_frame) 
 +fix(reports_to_data_frame)
    
 # Before we merge these data, we need to make sure 'ego' and 'alter' are the # Before we merge these data, we need to make sure 'ego' and 'alter' are the
Line 759: Line 769:
 # First, let's plot the network with all possible ties. # First, let's plot the network with all possible ties.
 # pdf("1.1_Krackhardt_Full.pdf") # pdf("1.1_Krackhardt_Full.pdf")
-plot(krack_full)+plot(krack_full, main="krack_full")
 # dev.off() # dev.off()
    
Line 770: Line 780:
     name = "advice_tie") == 0])     name = "advice_tie") == 0])
 summary(krack_advice_only) summary(krack_advice_only)
 +
 # pdf("1.2_Krackhardt_Advice.pdf") # pdf("1.2_Krackhardt_Advice.pdf")
-plot(krack_advice_only)+plot(krack_advice_only, main="krack_advice_only")
 # dev.off() # dev.off()
    
Line 780: Line 791:
 summary(krack_friendship_only) summary(krack_friendship_only)
 # pdf("1.3_Krackhardt_Friendship.pdf") # pdf("1.3_Krackhardt_Friendship.pdf")
-plot(krack_friendship_only)+plot(krack_friendship_only, main="krack_friendship_only")
 # dev.off() # dev.off()
  
Line 789: Line 800:
 summary(krack_reports_to_only) summary(krack_reports_to_only)
 # pdf("1.4_Krackhardt_Reports.pdf") # pdf("1.4_Krackhardt_Reports.pdf")
-plot(krack_reports_to_only)+plot(krack_reports_to_only, main="krack_reports_to_only")
 # dev.off() # dev.off()
    
Line 804: Line 815:
 # pdf("1.5_Krackhardt_Reports_Fruchterman_Reingold.pdf") # pdf("1.5_Krackhardt_Reports_Fruchterman_Reingold.pdf")
 plot(krack_reports_to_only,  plot(krack_reports_to_only, 
-     layout=reports_to_layout)+     layout=reports_to_layout, main="krack_reports_to_only")
 # dev.off() # dev.off()
    
Line 822: Line 833:
     vertex.color=dept_vertex_colors,      vertex.color=dept_vertex_colors, 
     vertex.label=NA,      vertex.label=NA, 
-    edge.arrow.size=.5)+    edge.arrow.size=.5,  
 +    main="krack_reports_to_only")
 # dev.off()  # dev.off() 
 # Now let's set the vertex size by tenure. # Now let's set the vertex size by tenure.
Line 833: Line 845:
      vertex.label=NA,       vertex.label=NA, 
      edge.arrow.size=.5,      edge.arrow.size=.5,
-     vertex.size=tenure_vertex_sizes)+     vertex.size=tenure_vertex_sizes, main="krack_reports_to_only")
 # dev.off()  # dev.off() 
    
Line 854: Line 866:
      vertex.label=NA,       vertex.label=NA, 
      edge.arrow.size=.5,      edge.arrow.size=.5,
-     vertex.size=tenure_vertex_sizes)+     vertex.size=tenure_vertex_sizes, main="krack_full")
    
    
sna_eg_stanford/lab01.1576020811.txt.gz · Last modified: 2019/12/11 08:33 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki