[R] newbie: new_data_frame <- selected set of rows

Neuro LeSuperHéros neuro3000 at hotmail.com
Sun Dec 3 17:16:18 CET 2006



#Mock df creation
my_dataframe <-data.frame(matrix(runif(14*5),14,5))
row.names(my_dataframe) <-paste("ENSP",1:14,sep="")
distances <-c(13,14,10 ,11,  2,  4,  6,  1,  3,  9,  8, 12,  7,  5)

head(my_dataframe[order(distances),],5)


>From: Darek Kedra <darked90 at yahoo.com>
>To: r-help at stat.math.ethz.ch
>Subject: Re: [R] newbie: new_data_frame <- selected set of rows
>Date: Fri, 1 Dec 2006 14:52:25 -0800 (PST)
>
>Two missing things:
>
> >distances
>  [1] 13 14 10 11  2  4  6  1  3  9  8 12  7  5
>
>#numbers correspond to rows in my_dataframe
>
> > my_dataframe
>                       V2         V3         V4
>V5         V6
>ENSP00000354687 35660.45 0.04794521 0.05479452
>0.06849315 0.07534247
>ENSP00000355046 38942.77 0.02967359 0.04451039
>0.04451039 0.06824926
>ENSP00000354499 57041.21 0.04700855 0.08760684
>0.11965812 0.06196581
>
>ENSP00000354687 etc are rownames.
>
>I am trying to get top five row names with smallest
>distances from a given vector as calculated by
>distancevector from hopach.
>
>
>
>Darek Kedra
>
>
>
>
>
>
>____________________________________________________________________________________
>Cheap talk?
>
>______________________________________________
>R-help at stat.math.ethz.ch 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.




More information about the R-help mailing list