Re: [R] Select certain elements from dataframe

From: jim holtman <jholtman_at_gmail.com>
Date: Mon, 19 May 2008 05:32:20 -0400

'xx1' is a 'factor' and you have to convert to a character before selecting:

data.xx1<-data[ ,as.character(xx1)]

On Mon, May 19, 2008 at 5:20 AM, SebastianEck <sebastianeck_at_web.de> wrote:

>
> Hello,
>

> I have a specific problem, I have a large dataframe, and after clustering I
> want to select certain colums, the elements of a subcluster.
>

> My dataframe looks like this :
>
> > colnames(data)
> [1] "101KF4319097339" "102KF4319101170" "103KF4319047549"
> "104KF4319046389"
> [5] "105KF4319013260" "106KF4319025582" "107KF4319108763"
> "108KF4319047040"
> [9] "109KF4319060241" "110KF4319056658" "111KF4319036131"
> "112KF4319097194"
> .
> .
> .
> [701] "821KS4242126913" "822KS4242026026" "823KS4242003122" "824IHT06020"
> [705] "825IHT06020" "826IHT06005" "827IHT06005"
>
> My subcluster looks like this
>
> > xx1
> xx1
> [1] 101KF4319097339 102KF4319101170 103KF4319047549 104KF4319046389
> [5] 125KF4319063638 126KF4319102180 127KF4319107122 128KF4319019607
> [9] 135KF4319037854 138KF4319050003 140KF4319069150 152KF4319109279
> .
> .
> .
> [125] 795KS4242028634 797KS4242032582 798KS4242035374
> 127 Levels: 101KF4319097339 102KF4319101170 103KF4319047549 ...
> 798KS4242035374
>
> Now I want to select all elements from data that are in xx1, I tried
>
> >data.xx1<-data[ ,xx1]
>
> but that selects the just the first 127 (127 is the number of elements /
> length from xx1) elements from data.
>
> Any help would be very appreciated :)
>
> Sebastian
> --
> View this message in context:
> http://www.nabble.com/Select-certain-elements-from-dataframe-tp17314209p17314209.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help_at_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<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

	[[alternative HTML version deleted]]

______________________________________________
R-help_at_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.
Received on Mon 19 May 2008 - 09:41:17 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 20 May 2008 - 09:30:38 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive