[R] need help in igraph package of R
Steve Lianoglou
mailinglist.honeypot at gmail.com
Thu May 13 22:01:26 CEST 2010
Hi,
See comments in line.
On Thu, May 13, 2010 at 1:07 PM, bababasi <slounios at incognitomail.net> wrote:
>
> hi
>
> I am struck with a problem in igraph package of R. My problem is as follows
>
> I want to plot a power law fit for my data (in .net format --- pajek format)
>
> syntax for that in R is
>
> g <- read.graph("filename.net", "pajek")
> d <- degree (g, mode="in")
> power.law.fit (d+1, 2)
>
> it gives me desired out put if my if input a single file
>
> but I want to use a variable file name ( such as name1, name2 ) so that I
> can read all my 100 files at a single stretch if I put this entire code in a
> loop.
>
> names = "name1" "name2" "name3".....
This doesn't work, does it?
I guess you mean:
R> names <- c("name1", "name2", "name3", ...)
>
> while (i <= 100)
> g <- read.graph("names[i]", "pajek")
> d <- degree (g, mode="in")
> power.law.fit (d+1, 2)
> i <- i + 1
> }
>
> but names[i] does n't seem to work. Is there any alternative ?
names[i] in your quote is inside quotes -- so it's just a string "names[i]".
If you have a vector called "names", and each bin of the vector has a
separate name, then just remove the quotes:
R> g <- read.graph(names[i], "pajek")
Also, you'll probably get a lot of benefit out of reading some
intro/tutorials on the fundamentals of R programming.
A small invest of time now will help you get to work a lot faster later.
-steve
--
Steve Lianoglou
Graduate Student: Computational Systems Biology
| Memorial Sloan-Kettering Cancer Center
| Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact
More information about the R-help
mailing list