Re: [R] help requested

2010-12-13 Thread profaar


hi
  thanks for your suggestion and reply. let me try it out.

With Warm Wishes and Regards
  
A. Abdul Rasheed, M.C.A., M.E., Ph.D.,
Assistant Professor,
Department of Computer Applications,
Valliammai Engineering College,
SRM Nagar, Kattankulathur - 603 203.
Kancheepuram District. Tamil Nadu. INDIA.
Contact: 91 - 44 - 27454784 Ext: 451 (O) / 996 23 000 55





Date: Sun, 12 Dec 2010 05:06:21 -0800
From: ml-node+3084270-787879815-204...@n4.nabble.com
To: prof...@live.com
Subject: Re: help requested



On Sat, Dec 11, 2010 at 05:11:37AM -0800, profaar wrote:

 hi

   thanks for your reply. there are around 2 nodes in my dataset. will it 
 work for conversion from edge list format to node list format? I am using R 
 under Windows XP.

 


Under Linux, with 20'000 nodes and 10 random edges from each of them, this

took abuot 108 sec (CPU 2.4 GHz). The advantage of this solution is that

there may be further functions in the package graph (see also class?graphNEL),

which could be used in your application. If not, then the conversion itself

may be done more efficiently, for example


  edges - read.table(file=stdin())

1 2

1 3

1 4

1 5

2 3

2 4

3 2

4 1

4 3

4 5

5 2

5 4


  out1 - split(edges$V2, edges$V1)

  out1


  $`1`

  [1] 2 3 4 5

  

  $`2`

  [1] 3 4

  

  $`3`

  [1] 2

  

  $`4`

  [1] 1 3 5

  

  $`5`

  [1] 2 4


For the example with 20'000 nodes and 10 random edges from each, this 

took about 0.2 sec.


The output out1 is a list of vectors. This may be transformed to

a vector of strings, for example


  out2 - sapply(out1, paste, collapse= )

  cbind(out2) # cbind() is only for a column output


  out2 

1 2 3 4 5

2 3 4

3 2  

4 1 3 5  

5 2 4


and to a text (with a possible file= argument)


  cat(paste(names(out2), out2), sep=\n)


  1 2 3 4 5

  2 3 4

  3 2

  4 1 3 5

  5 2 4


Petr Savicky.


__

[hidden email] mailing list

https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.








View message @ 
http://r.789695.n4.nabble.com/help-requested-tp3082147p3084270.html


To unsubscribe from help requested, click here.
  
-- 
View this message in context: 
http://r.789695.n4.nabble.com/help-requested-tp3082147p3085414.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] help requested

2010-12-12 Thread Petr Savicky
On Sat, Dec 11, 2010 at 05:11:37AM -0800, profaar wrote:
 hi
   thanks for your reply. there are around 2 nodes in my dataset. will it 
 work for conversion from edge list format to node list format? I am using R 
 under Windows XP.
 

Under Linux, with 20'000 nodes and 10 random edges from each of them, this
took abuot 108 sec (CPU 2.4 GHz). The advantage of this solution is that
there may be further functions in the package graph (see also class?graphNEL),
which could be used in your application. If not, then the conversion itself
may be done more efficiently, for example

  edges - read.table(file=stdin())
1 2
1 3
1 4
1 5
2 3
2 4
3 2
4 1
4 3
4 5
5 2
5 4

  out1 - split(edges$V2, edges$V1)
  out1

  $`1`
  [1] 2 3 4 5
  
  $`2`
  [1] 3 4
  
  $`3`
  [1] 2
  
  $`4`
  [1] 1 3 5
  
  $`5`
  [1] 2 4

For the example with 20'000 nodes and 10 random edges from each, this 
took about 0.2 sec.

The output out1 is a list of vectors. This may be transformed to
a vector of strings, for example

  out2 - sapply(out1, paste, collapse= )
  cbind(out2) # cbind() is only for a column output

  out2 
1 2 3 4 5
2 3 4
3 2  
4 1 3 5  
5 2 4

and to a text (with a possible file= argument)

  cat(paste(names(out2), out2), sep=\n)

  1 2 3 4 5
  2 3 4
  3 2
  4 1 3 5
  5 2 4

Petr Savicky.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] help requested

2010-12-11 Thread profaar


hi
  thanks for your reply. there are around 2 nodes in my dataset. will it 
work for conversion from edge list format to node list format? I am using R 
under Windows XP.

With Warm Wishes and Regards
  
A. Abdul Rasheed, M.C.A., M.E., Ph.D.,
Assistant Professor,
Department of Computer Applications,
Valliammai Engineering College,
SRM Nagar, Kattankulathur - 603 203.
Kancheepuram District. Tamil Nadu. INDIA.
Contact: 91 - 44 - 27454784 Ext: 451 (O) / 996 23 000 55





Date: Fri, 10 Dec 2010 10:33:30 -0800
From: ml-node+3082496-762697967-204...@n4.nabble.com
To: prof...@live.com
Subject: Re: help requested



On Fri, Dec 10, 2010 at 07:20:55AM -0800, profaar wrote:

 

 HI friends,

   I have very lengthy graph data in edge list format. I want to convert it

 into node list format. 

 

 example:

 EDGE LIST FORMAT

 1 2 

 1 3 

 1 4 

 1 5

 2 3 

 2 4

 3 2 

 4 1

 4 3

 4  5

 5 2

 5 4

 

 ITS NODE LIST FORMAT SHOULD BE LIKE:

 1 2 3  4 5

 2 3 4

 3 2

 4 1 3

 5 2 4

 

   Kindly suggest me which package in R provides the support to do my task.

How long the list of egdes is? For not too large lists, consider also


  library(graph)

  G - new(graphNEL, edgemode=directed)

  G - addNode(as.character(1:5), G)

  edges - read.table(file=stdin(), colClasses=character)

1 2

1 3

1 4

1 5

2 3

2 4

3 2

4 1

4 3

4 5

5 2

5 4


  G - addEdge(from=edges[, 1], to=edges[, 2], G)

  edgeL(G)


  $`1`

  $`1`$edges

  [1] 2 3 4 5

  

  

  $`2`

  $`2`$edges

  [1] 3 4

  

  

  $`3`

  $`3`$edges

  [1] 2

  

  

  $`4`

  $`4`$edges

  [1] 1 3 5

  

  

  $`5`

  $`5`$edges

  [1] 2 4


Very large lists can be handled by unix/linux sort command (if not sorted

already) and by extracting the end-nodes of the edges starting in each node.

In a sorted file, they form blocks of consecutive lines, so a simple text

processing with perl is sufficient.


Petr Savicky.


__

[hidden email] mailing list

https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.








View message @ 
http://r.789695.n4.nabble.com/help-requested-tp3082147p3082496.html


To unsubscribe from help requested, click here.
  
-- 
View this message in context: 
http://r.789695.n4.nabble.com/help-requested-tp3082147p3083278.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] help requested

2010-12-11 Thread jim holtman
try this:

 x
   X1 X2
1   1  3
2   1  4
3   1  5
4   2  3
5   2  4
6   3  2
7   4  1
8   4  3
9   4  5
10  5  2
11  5  4
 sapply(split(x, x$X1), function(.grp){
+ paste(.grp[[1]][1], paste(.grp[[2]], collapse = ','))
+ })
1 2 3 4 5
1 3,4,5   2 3,4 3 2 4 1,3,5   5 2,4



On Fri, Dec 10, 2010 at 11:20 AM, Jinyan Huang jinyan...@gmail.com wrote:
 awk '{arr[$1]=arr[$1]   $2}END{for( i in arr){print i,arr[i]}}'
 edgelist.txt | sort -k1



 On Fri, Dec 10, 2010 at 4:20 PM, profaar prof...@live.com wrote:
 1 2
 1 3
 1 4
 1 5
 2 3
 2 4
 3 2
 4 1
 4 3
 4  5
 5 2
 5 4

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] help requested

2010-12-10 Thread profaar

HI friends,
  I have very lengthy graph data in edge list format. I want to convert it
into node list format. 

example:
EDGE LIST FORMAT
1 2 
1 3 
1 4 
1 5
2 3 
2 4
3 2 
4 1
4 3
4  5
5 2
5 4

ITS NODE LIST FORMAT SHOULD BE LIKE:
1 2 3  4 5
2 3 4
3 2
4 1 3
5 2 4

  Kindly suggest me which package in R provides the support to do my task.
Thank u friends in advance.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/help-requested-tp3082147p3082147.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] help requested

2010-12-10 Thread Jinyan Huang
awk '{arr[$1]=arr[$1]   $2}END{for( i in arr){print i,arr[i]}}'
edgelist.txt | sort -k1



On Fri, Dec 10, 2010 at 4:20 PM, profaar prof...@live.com wrote:
 1 2
 1 3
 1 4
 1 5
 2 3
 2 4
 3 2
 4 1
 4 3
 4  5
 5 2
 5 4

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] help requested

2010-12-10 Thread Henrique Dallazuanna
Try this:

 DF
   V1 V2
1   1  2
2   1  3
3   1  4
4   1  5
5   2  3
6   2  4
7   3  2
8   4  1
9   4  3
10  4  5
11  5  2
12  5  4

 aggregate(V2 ~ V1, DF, paste, collapse = ' ')
  V1  V2
1  1 2 3 4 5
2  2 3 4
3  3   2
4  4   1 3 5
5  5 2 4

On Fri, Dec 10, 2010 at 1:20 PM, profaar prof...@live.com wrote:


 HI friends,
  I have very lengthy graph data in edge list format. I want to convert it
 into node list format.

 example:
 EDGE LIST FORMAT
 1 2
 1 3
 1 4
 1 5
 2 3
 2 4
 3 2
 4 1
 4 3
 4  5
 5 2
 5 4

 ITS NODE LIST FORMAT SHOULD BE LIKE:
 1 2 3  4 5
 2 3 4
 3 2
 4 1 3
 5 2 4

  Kindly suggest me which package in R provides the support to do my task.
 Thank u friends in advance.
 --
 View this message in context:
 http://r.789695.n4.nabble.com/help-requested-tp3082147p3082147.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] help requested

2010-12-10 Thread Mike Marchywka










 From: jinyan...@gmail.com
 Date: Fri, 10 Dec 2010 17:20:00 +0100
 To: prof...@live.com
 CC: r-help@r-project.org
 Subject: Re: [R] help requested

 awk '{arr[$1]=arr[$1]   $2}END{for( i in arr){print i,arr[i]}}'
 edgelist.txt | sort -k1

My first thought PERL hash but I guess my answer would
still be to consider any R hash-like structures. I guess any array
that accepts arbitrary subscripts amounts to a hash.






 On Fri, Dec 10, 2010 at 4:20 PM, profaar  wrote:
  1 2
  1 3
  1 4
  1 5
  2 3
  2 4
  3 2
  4 1
  4 3
  4  5
  5 2
  5 4

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
  
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] help requested

2010-12-10 Thread Petr Savicky
On Fri, Dec 10, 2010 at 07:20:55AM -0800, profaar wrote:
 
 HI friends,
   I have very lengthy graph data in edge list format. I want to convert it
 into node list format. 
 
 example:
 EDGE LIST FORMAT
 1 2 
 1 3 
 1 4 
 1 5
 2 3 
 2 4
 3 2 
 4 1
 4 3
 4  5
 5 2
 5 4
 
 ITS NODE LIST FORMAT SHOULD BE LIKE:
 1 2 3  4 5
 2 3 4
 3 2
 4 1 3
 5 2 4
 
   Kindly suggest me which package in R provides the support to do my task.

How long the list of egdes is? For not too large lists, consider also

  library(graph)
  G - new(graphNEL, edgemode=directed)
  G - addNode(as.character(1:5), G)
  edges - read.table(file=stdin(), colClasses=character)
1 2
1 3
1 4
1 5
2 3
2 4
3 2
4 1
4 3
4 5
5 2
5 4

  G - addEdge(from=edges[, 1], to=edges[, 2], G)
  edgeL(G)

  $`1`
  $`1`$edges
  [1] 2 3 4 5
  
  
  $`2`
  $`2`$edges
  [1] 3 4
  
  
  $`3`
  $`3`$edges
  [1] 2
  
  
  $`4`
  $`4`$edges
  [1] 1 3 5
  
  
  $`5`
  $`5`$edges
  [1] 2 4

Very large lists can be handled by unix/linux sort command (if not sorted
already) and by extracting the end-nodes of the edges starting in each node.
In a sorted file, they form blocks of consecutive lines, so a simple text
processing with perl is sufficient.

Petr Savicky.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.