Re: [R] remove multiple elements from vector

2008-09-27 Thread baptiste auguie
Hi, ?unique should work fine for this. I think the problem in your implementation is that you modify x in the loop, in particular its length may become shorter than the stopping condition. HTH, baptiste On 27 Sep 2008, at 14:30, Bastian Offermann wrote: Hello all, one brief question

Re: [R] remove low frequent rows

2008-08-31 Thread Jorge Ivan Velez
Dear jayuan2008, See ?subset. If I understand your description below, something like this could do the job: a1-data.frame(x=c(a,b,a,b,a),y=c(4,3,6,1,2)) subset(a1,y2) x y 1 a 4 2 b 3 3 a 6 BTW, I think that the final result you described in your post is incorrect. HTH, Jorge On Sun, Aug

Re: [R] remove low frequent rows

2008-08-31 Thread markleeds
DF-cbind(c(a,b,a),c(4,3,6)) DF[(DF[,1] %in% names(which(table(DF[,1]) = 2))),] On Sun, Aug 31, 2008 at 2:19 AM, Yuan Jian wrote: Hi, � I have a matrix. a-cbind(c(a,b,a),c(4,3,6)) [,1] [,2] [1,] a� 4 [2,] b� 3 [3,] a� 6 I want to remove rows in matrix a whose first column has

Re: [R] remove low frequent rows

2008-08-31 Thread Gabor Grothendieck
See ?ave and try this: a[as.numeric(ave(a[,1], a[,1], FUN = length)) 1, ] On Sun, Aug 31, 2008 at 2:19 AM, Yuan Jian [EMAIL PROTECTED] wrote: Hi, I have a matrix. a-cbind(c(a,b,a),c(4,3,6)) [,1] [,2] [1,] a 4 [2,] b 3 [3,] a 6 I want to remove rows in matrix a whose first

Re: [R] remove levels from a factor

2008-08-30 Thread Adrian Dusa
Yuan Jian jayuan2008 at yahoo.com writes: [...snip...] I want to remove level b because level b has less than 2. f [1] a a Levels: a f[which(f %in% names(table(f))[table(f) = 2]), drop=TRUE] [1] a a Levels: a HTH, Adrian __

Re: [R] remove levels from a factor

2008-08-30 Thread Frank E Harrell Jr
Adrian Dusa wrote: Adrian Dusa dusa.adrian at gmail.com writes: [...snip...] f[which(f %in% names(table(f))[table(f) = 2]), drop=TRUE] [1] a a Levels: a Or, more simple: f[f %in% names(table(f))[table(f) = 2], drop=TRUE] [1] a a Levels: a Adrian Also see the combine.levels function in

[R] remove levels from a factor

2008-08-29 Thread Yuan Jian
Hi,   how to remove levels that have less than a specific number such as 2. i.e..   f-as.factor(c(a,b,a)) f [1] a b a Levels: a b I want to remove level b because level b has less than 2. f [1] a a Levels: a   [[alternative HTML version deleted]]

Re: [R] remove levels from a factor

2008-08-29 Thread milton ruser
Hi Yuan, It is not ellegant, but may work for you.. f-as.factor(c(a,b,a)) f.freq-data.frame(table(f)) f.freq lower.freq-2 f.freq.subset-subset(f.freq,f.freq$Freq=lower.freq) f.freq.subset f.selected-f[f %in% f.freq.subset$f] f.selected-factor(f.selected) f.selected Best wishes, miltinho

Re: [R] Remove Even Number from A Vector

2008-08-01 Thread Paul Roebuck
On Fri, 1 Aug 2008, Gundala Viswanath wrote: How can I remove the even number from the following vector x [1] 4 5 6 8 17 20 21 22 23 25 26 31 35 36 38 40 41 42 43 [20] 44 50 74 75 82 84 89 90 91 95 96 97 100 101 102 118 119 121 122 [39] 123 135 136

Re: [R] Remove Even Number from A Vector

2008-08-01 Thread Ferry
x[!(x %% 2 == 0)] On Thu, Jul 31, 2008 at 10:01 PM, Gundala Viswanath [EMAIL PROTECTED]wrote: Dear all, How can I remove the even number from the following vector x [1] 4 5 6 8 17 20 21 22 23 25 26 31 35 36 38 40 41 42 43 [20] 44 50 74 75 82 84 89 90 91

[R] Remove Even Number from A Vector

2008-07-31 Thread Gundala Viswanath
Dear all, How can I remove the even number from the following vector x [1] 4 5 6 8 17 20 21 22 23 25 26 31 35 36 38 40 41 42 43 [20] 44 50 74 75 82 84 89 90 91 95 96 97 100 101 102 118 119 121 122 [39] 123 135 136 157 158 yielding 5, 17, 21, 23, 25, .

[R] Remove non-numerical columns from data frame

2008-07-26 Thread Markus Mühlbacher
Hello, My question sounds simple, but as I am desperatly searchin for a solution I am asking you all. :) I try to filter out all non-numeric columns of a data frame using a for loop to go through all columns. My if clause looks like this: for(j in 1:length(data)) {

Re: [R] Remove non-numerical columns from data frame

2008-07-26 Thread Henrique Dallazuanna
Try this: x - data.frame(A=c(10,20), B = c(a, b), C = c(20,30)) x[sapply(x, is.numeric)] On Sat, Jul 26, 2008 at 11:19 AM, Markus Mühlbacher [EMAIL PROTECTED] wrote: Hello, My question sounds simple, but as I am desperatly searchin for a solution I am asking you all. :) I try to filter out

Re: [R] Remove non-numerical columns from data frame

2008-07-26 Thread Peter Dalgaard
Henrique Dallazuanna wrote: Try this: x - data.frame(A=c(10,20), B = c(a, b), C = c(20,30)) x[sapply(x, is.numeric)] Yes, and read ?Extract to clear up the confusion between data$vol and data[257] and data[[257]] (Section on Recursive (list-like) objects:). Also, ?Extract.data.frame.

Re: [R] Remove non-numerical columns from data frame

2008-07-26 Thread Henrik Bengtsson
On Sat, Jul 26, 2008 at 9:35 AM, Peter Dalgaard [EMAIL PROTECTED] wrote: Henrique Dallazuanna wrote: Try this: x - data.frame(A=c(10,20), B = c(a, b), C = c(20,30)) x[sapply(x, is.numeric)] Yes, and read ?Extract to clear up the confusion between data$vol and data[257] and data[[257]]

[R] Remove an object by the reference

2008-05-13 Thread Shubha Vishwanath Karanth
Hi R, A simple question, but don't know the answer... x=a a=5 I need to remove the object a by using only x. something like rm(somefunction(x))...Is this possible? Shubha Karanth | Amba Research Ph +91 80 3980 8031 | Mob +91 94 4886 4510 Bangalore * Colombo * London * New York

Re: [R] Remove an object by the reference

2008-05-13 Thread Richard Pearson
How about rm(list=x)? Richard. Shubha Vishwanath Karanth wrote: Hi R, A simple question, but don't know the answer... x=a a=5 I need to remove the object a by using only x. something like rm(somefunction(x))...Is this possible? Shubha Karanth | Amba Research Ph +91 80

Re: [R] Remove an object by the reference

2008-05-13 Thread Gabor Csardi
a - 1 x - a rm(list=x) a Error: object a not found See ?rm for details. Gabor On Tue, May 13, 2008 at 05:13:41PM +0530, Shubha Vishwanath Karanth wrote: Hi R, A simple question, but don't know the answer... x=a a=5 I need to remove the object a by using only x.

Re: [R] remove column names from a data frame

2008-02-18 Thread Benilton Carvalho
apparently you want to check the Introduction to R document I found it very useful when I started working with R: http://cran.r-project.org/doc/manuals/R-intro.pdf try: names(df) - NULL b ps: df is the name of the function to get the density for an F distribution... On Feb 18,

Re: [R] remove column names from a data frame

2008-02-18 Thread Henrique Dallazuanna
Try this: names(df) - NA or names(df) - make.names(seq(ncol(df))) On 18/02/2008, joseph [EMAIL PROTECTED] wrote: I want to remove the column names from a data frame. I do it the long way, can any body show me a better way ? df= data.frame(chrN= c(chr1, chr2, chr3), start= c(1, 2, 3),

[R] remove column names from a data frame

2008-02-18 Thread joseph
I want to remove the column names from a data frame. I do it the long way, can any body show me a better way ? df= data.frame(chrN= c(“chr1”, “chr2”, “chr3”), start= c(1, 2, 3), end= c(4, 5, 6), score= c(7, 8, 9)) df #I write a txt file without row or column names

Re: [R] remove column names from a data frame

2008-02-18 Thread Benilton Carvalho
6 9 - Original Message From: Benilton Carvalho [EMAIL PROTECTED] To: joseph [EMAIL PROTECTED] Cc: r-help@r-project.org Sent: Monday, February 18, 2008 11:47:50 AM Subject: Re: [R] remove column names from a data frame

Re: [R] remove column names from a data frame

2008-02-18 Thread joseph
: Benilton Carvalho [EMAIL PROTECTED] To: joseph [EMAIL PROTECTED] Cc: r-help@r-project.org Sent: Monday, February 18, 2008 11:47:50 AM Subject: Re: [R] remove column names from a data frame apparently you want to check the Introduction to R document I found it very useful when

Re: [R] remove column names from a data frame

2008-02-18 Thread Charilaos Skiadas
] To: joseph [EMAIL PROTECTED] Cc: r-help@r-project.org Sent: Monday, February 18, 2008 11:47:50 AM Subject: Re: [R] remove column names from a data frame apparently you want to check the Introduction to R document I found it very useful when I started working with R: http://cran.r-project.org

[R] Remove rows with NA across all columns

2008-02-14 Thread joseph
Hi I have a data frame df with 3 columns. Some rows are NA across all 3 columns. How can I remove rows with NA across all columns? df=data.frame(col1=c(1:3,NA,NA,4),col2=c(7:9,NA,NA,NA),col3=c(2:4,NA,NA,4)) Thanks Joseph

Re: [R] Remove rows with NA across all columns

2008-02-14 Thread Bert Gunter
, Bert Gunter Genentech -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of joseph Sent: Thursday, February 14, 2008 8:53 PM To: r-help@r-project.org Cc: r-help@r-project.org Subject: [R] Remove rows with NA across all columns Hi I have a data frame df with 3

Re: [R] remove the missing value,NA

2008-02-08 Thread Jorge Iván Vélez
Hi Mohamed, May be it's not the best way, but you can try w=c(1,4,5,2,NA,4,5,1,NA) w[-which(is.na(w))] [1] 1 4 5 2 4 5 1 I hope this helps. Jorge On 2/8/08, mohamed nur anisah [EMAIL PROTECTED] wrote: I have two sets of interval data.Below are my two dataset. In these dataset, there

[R] remove the missing value,NA

2008-02-08 Thread mohamed nur anisah
I have two sets of interval data.Below are my two dataset. In these dataset, there is a missing values in each of the data. I want to find the non-overlapping interval values. Here is my code: mysetdiff=function(x,y){ m=length(x) n=length(y) bx = logical(m) by = logical(n)

Re: [R] remove similar values

2008-01-29 Thread Romain Francois
Hi, Not sure I understand the question, but maybe you need ?unique or ?duplicated Cheers, Romain mohamed nur anisah wrote: hello!! say that i have the values of x1 and x2. my x1 has longer length than x2. how am i going to remove the similar values of x1 and x2. Any suggestion??

Re: [R] remove similar values

2008-01-29 Thread Peter Dalgaard
Romain Francois wrote: Hi, Not sure I understand the question, but maybe you need ?unique or ?duplicated Or maybe ?union, ?setdiff, ?intersection. Or ?merge. Cheers, Romain mohamed nur anisah wrote: hello!! say that i have the values of x1 and x2. my x1 has longer

[R] Remove zero row from data.frame

2007-10-05 Thread Rees, David
Hi, Sorry that this is such a basic question, but I am having trouble with the following. I would like to remove all rows where the data is all zeros in a data.frame such as the following x dateabc 1 2007.09.25 99.89844 100.0586 100.0840 4 2007.09.26 99.89844

Re: [R] Remove zero row from data.frame

2007-10-05 Thread Uwe Ligges
Rees, David wrote: Hi, Sorry that this is such a basic question, but I am having trouble with the following. I would like to remove all rows where the data is all zeros in a data.frame such as the following x dateabc 1 2007.09.25 99.89844 100.0586

<    2   3   4   5   6   7