Here is how you can do it with data.table:

> x <- read.table(text = " author_id paper_id prob
+        731    24943    1
+        731    24943    1
+        731 688974 1
+        731   964345    .8
+        731  1201905    .9
+        731  1267992    1
+        736    249      .2
+        736   6889      1
+        736   94345    .7
+        736  1201905    .9
+        736  126992    .8", header = TRUE)
> require(data.table)
> x <- data.table(x)
> output <- x[
+     , list(paper_id = paste(paper_id[order(prob, decreasing = TRUE)],
collapse = ','))
+     , keyby = author_id
+     ]
> output
   author_id                                  paper_id
1:       731 24943,24943,688974,1267992,1201905,964345
2:       736             6889,1201905,126992,94345,249
>



Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.


On Thu, Mar 27, 2014 at 7:01 AM, Rohit Gupta <rhtgpt789@gmail.com> wrote:

> I have a data A which looks like
>
>
>     author_id paper_id prob
>        731    24943    1
>        731    24943    1
>        731 688974 1
>        731   964345    .8
>        731  1201905    .9
>        731  1267992    1
>        736    249      .2
>        736   6889      1
>        736   94345    .7
>        736  1201905    .9
>        736  126992    .8
>
> The output I am desiring is:
>
>     author_id    paper_id
>       731        24943,24943,688974,1201905,964345
>       736        6889,1201945,126992,94345,249
>
> That is paper_id are arranged according to decreasing order of
> probability.How could this be done?
>
> Thanks
>
>         [[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.
>

	[[alternative HTML version deleted]]


