How to get and use tnet PDF Print E-mail

How to get tnet

First, you need to open R. If you do not have R, or you have a version older than 2.7.0, on your computer:

  1. Go to http://cran.r-project.org/
  2. Select your operating system
  3. Select base
  4. Select the installation file (for Windows users, this is the file ending with .exe)
  5. Click Run
  6. Follow the instructions on the screen when the programme has been downloaded.

Then, you need to download and install the package from CRAN:

Type the following in R: install.packages("tnet")

Select a server near you

How to use tnet

To activate the package, you need to type the following in R everytime you start R:

library(tnet)

Then, you should be able to use the functions available within tnet.

To calculate the degree of an edgelist, you use the function called degree_w, e.g.

## Define edgelist
Imagesample <- rbind(
c(1,2,4),
c(1,3,2),
c(2,1,4),
c(2,3,4),
c(2,4,1),
c(2,5,2),
c(3,1,2),
c(3,2,4),
c(4,2,1),
c(5,2,2),
c(5,6,1),
c(6,5,1))
## To calculate degree
degree_w(sample)
     vertex degree output 
[1,]      1      2      6
[2,]      2      4     11
[3,]      3      2      6
[4,]      4      1      1
[5,]      5      2      3
[6,]      6      1      1
Last Updated ( Saturday, 13 June 2009 )