-----Original Message-----
From: Simone Gabbriellini [mailto:simone.gabbriellini at gmail.com]
Sent: Friday, February 01, 2013 2:29 PM
To: PIKAL Petr
Cc: r-help at r-project.org
Subject: Re: [R] how to
Hi,
Yes I know it works, but I'd like to assign the results like this:
V(g)$meanknn <- ONELINER
Where V(g) elencates all the nodes in my graph...
Thanks,
Simone
Sent from my iPhone. Please excuse brevity and odd typos
On 01/feb/2013, at 13:31, PIKAL Petr <petr.pikal at precheza.cz> wrote:
Hi
I do not see any problem with your code. *apply functions are also
hidden cycles and there shall not be substantial improvement in speed.
Why you do not want to use for cycle?
Petr
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
project.org] On Behalf Of Simone Gabbriellini
Sent: Friday, February 01, 2013 12:54 PM
To: r-help at r-project.org
Subject: [R] how to
Dear List,
I have a list of lists and on each list I want to apply a function
from the igraph package, graph.knn. I need to calculate graph.knn
each list on a graph g, then retrieve one of the result called $knn
and calculate its mean. The non-R style code looks like this:
for(i in listOfLists){
print(mean(graph.knn(g, i)$knn))
}
Is there any way to convert this in a one-liner? I have tried to
figure it out with lapply() or mapply() but with no success.
Thank you in advance for your help.
Simone
--
Simone Gabbriellini, PhD
PostDoc at DISI, University of Bologna
mobile: +39 340 39 75 626
email: simone.gabbriellini at unibo.it
home: www.digitaldust.it
DigitalBrains srl
Amministratore
mobile: +39 340 39 75 626
email: simone.gabbriellini at digitalbrains.it
home: www.digitalbrains.it