Re: [R] Subseting a data.frame

2013-10-18 Thread Katherine Gobin
vel, NA generated > >    3: In `[<-.factor`(`*tmp*`, i, value = 1L) : > >      invalid factor level, NA generated > > but x=integer(length(group)) works in all cases: > >    > ave(integer(length(fac)), fac, FUN=length) > >    [1] 3 1 3 3 > >    > ave(in

Re: [R] Subseting a data.frame

2013-10-18 Thread S Ellison
> -Original Message- > > mydat >   basel_asset_class defa_frequency > 1                 2          0.150 > 2                 8          0.070 > 3                 8          0.030 > 4                 8          0.001 > > > I need to get the subset of this data.frame where no of records f

Re: [R] Subseting a data.frame

2013-10-18 Thread S Ellison
> -Original Message- > ... the kindest guide I can give is to > read an Introduction to R (ships with R) or a R web tutorial of your choice No quibble with the advice, but it prompted me to look again at the R Intro. Interestingly, the Intro doesn't mention subset() at all; the subsetting

Re: [R] Subseting a data.frame

2013-10-17 Thread William Dunlap
tfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: arun [mailto:smartpink...@yahoo.com] > Sent: Thursday, October 17, 2013 2:33 PM > To: R help > Cc: William Dunlap; Bert Gunter > Subject: Re: [R] Subseting a data.frame > > Hi Bill, > > #

Re: [R] Subseting a data.frame

2013-10-17 Thread arun
FUN=length)   [1] 3 1 3 3   > ave(integer(length(char)), char, FUN=length)       [1] 3 1 3 3 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com From: Bert Gunter [mailto:gunter.ber...@gene.com] Sent: Thursday, October 17, 2013 1:06 PM To: William Dunlap Cc: Katherine Gobin; r-help@r-proj

Re: [R] Subseting a data.frame

2013-10-17 Thread Bert Gunter
> >> ave(integer(length(fac)), fac, FUN=length) > >[1] 3 1 3 3 > > > ave(integer(length(char)), char, FUN=length) > > [1] 3 1 3 3 > > > > Bill Dunlap > > Spotfire, TIBCO Software > > wdunlap tibco.com > > > >

Re: [R] Subseting a data.frame

2013-10-17 Thread William Dunlap
ngth(group)) works in all cases: > ave(integer(length(fac)), fac, FUN=length) [1] 3 1 3 3 > ave(integer(length(char)), char, FUN=length) [1] 3 1 3 3 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com From: Bert Gunter [mailto:gunter.ber...@gene.com] Sent: Thursday, Octob

Re: [R] Subseting a data.frame

2013-10-17 Thread Bert Gunter
elp-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf > > Of Katherine Gobin > > Sent: Thursday, October 17, 2013 11:05 AM > > To: Bert Gunter > > Cc: r-help@r-project.org > > Subject: Re: [R] Subseting a data.frame > > > &g

Re: [R] Subseting a data.frame

2013-10-17 Thread William Dunlap
74 0.875 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Katherine Gobin > Sent: Thursday, October 17, 2013 11:05 AM > To: Bert Gun

Re: [R] Subseting a data.frame

2013-10-17 Thread arun
You may try: mydat[with(mydat,ave(seq_along(basel_asset_class),basel_asset_class,FUN=length)>2),] #  basel_asset_class defa_frequency #2 8  0.070 #3 8  0.030 #4 8  0.001 #or library(plyr) mydat[ddply(mydat,.(basel_asset_class

Re: [R] Subseting a data.frame

2013-10-17 Thread Katherine Gobin
Correction. (2nd para first three lines)   Pl read following line  What I need is to select only those records for which there are more than two default frequencies (defa_frequency), Thus, there is only one default frequency = 0.150 w.r.t basel_asset_class = 4 whereas there are default frequenci

Re: [R] Subseting a data.frame

2013-10-17 Thread Katherine Gobin
 I am sorry perhaps  was not able to put the question properly. I am not looking for the subset of the data.frame where the basel_asset_class is > 2. I do agree that would have been a basic requirement. Let me try to put the question again.  I have a data frame as  mydat = data.frame(basel_ass

Re: [R] Subseting a data.frame

2013-10-17 Thread Bert Gunter
"Kindly guide" ... This is a very basic question, so the kindest guide I can give is to read an Introduction to R (ships with R) or a R web tutorial of your choice so that you can learn how R works instead of posting to this list. Cheers, Bert On Wed, Oct 16, 2013 at 11:55 PM, Katherine Gobin

Re: [R] Subseting a data.frame

2013-10-17 Thread Charles Determan Jr
Katherine, There are multiple ways to do this and I highly recommend you look into a basic R manual or search the forums. One quick example would be: mysub <- subset(mydat, basel_asset_class > 2) Cheers, Charles On Thu, Oct 17, 2013 at 1:55 AM, Katherine Gobin wrote: > Dear Forum, > > I have

Re: [R] Subseting

2012-08-02 Thread arun
Hi, Try this: Here, in the example dataset, you have 3 banks.  Suppose, I want to delete 2 banks randomly out of 3, (you can name your specific banks to delete), dat1<-read.table(text=" Year  Name totalliabilties assets 1990  a  90    10 1991  a  89    48 1

Re: [R] Subseting

2012-08-02 Thread Jessica Streicher
data[!(data$Name %in% names), ] then, and "names" having the 9 names you want to dismiss. Also please reply to the list as well if you answer, otherwise others won't know of the progress made. On 02.08.2012, at 11:48, Akhil dua wrote: > This is the only issue actually > I dotn want to take the

Re: [R] Subseting

2012-08-02 Thread Jessica Streicher
data[data$Name %in% names, ] should work then. You do know which 40 of your 49 banks you want, right? put their names in the "names" variable above. If you want random 40 banks you can do something like this: allNames<-unique(data$Name) names<-sample(allNames,40) Does that help? You really aren

Re: [R] Subseting

2012-08-02 Thread Jessica Streicher
On 02.08.2012, at 10:44, Akhil dua wrote: > Hi everyone > > I have banking data set in long format with 4 columns.One of these columns > is bank name which consist of 49 banks and I want the data for only 40 > banks out of these 49 > so can anyone help me on how to get this 40 banks data > > My

Re: [R] subseting a data frame

2012-03-02 Thread Rui Barradas
Hello, > HI, > this is my problem I want to subset this file df, using only unique > df$exon printing the line once even if df$exon appear several times: > > unique(df$exon) will show me the unique exons > If I try to print only the unique exon lines > with df[unique(df$exon),] -this doesn't pr

Re: [R] subseting a data frame

2012-03-02 Thread R. Michael Weylandt
Please always cc the list for archival/threading reasons. Sort answer is that unique() gives the unique elements rather than something you should subset by, like a set of logical indices or row numbers. Note that in general unique(x) == x[!duplicated(x)] I'd imagine there are cases where this

Re: [R] subseting a data frame

2012-03-02 Thread R. Michael Weylandt
I believe you want the duplicated() function. Michael On Mar 2, 2012, at 10:19 AM, nathalie wrote: > HI, > this is my problem I want to subset this file df, using only unique df$exon > printing the line once even if df$exon appear several times: > > unique(df$exon) will show me the unique e

Re: [R] subseting data

2011-05-02 Thread Steven Kennedy
You can use grepl: > dat<-data.frame(test=c("abc","cdf","dabc")) > d<-subset(dat,grepl(test,"abc")) > d test 1 abc 3 dabc On Mon, May 2, 2011 at 7:03 PM, Matevž Pavlič wrote: > Hi, > > > > Is it possible (i am sure it is) to subset data from a data.frame on the > basis of SQL >LIKE< oper

Re: [R] subseting data

2011-05-02 Thread Uwe Ligges
egation: d <- subset(dat, !grepl("abc", test)) Uwe Ligges Thanks, m From: Steven Kennedy [mailto:stevenkennedy2...@gmail.com] Sent: Monday, May 02, 2011 11:30 AM To: Matevž Pavlič Cc: r-help@r-project.org Subject: Re: [R] subseting data You can use grepl: dat<-data

Re: [R] subseting data

2011-05-02 Thread Matevž Pavlič
only the first element will be used > d test 1 abc 2 cdf 3 dabc I can't seem to make it work. Also how would i use the grepl() to select only those that are not like i.e. »GP«? Thanks, m From: Steven Kennedy [mailto:stevenkennedy2...@gmail.com] Sent: Monday, May 02,

Re: [R] subseting data

2011-05-02 Thread Andrew Robinson
I wonder if grep() will help you? Cheers Andrew On Mon, May 02, 2011 at 11:03:52AM +0200, Matev? Pavli? wrote: > Hi, > > > > Is it possible (i am sure it is) to subset data from a data.frame on the > basis of SQL >LIKE< operator. I.e., i would like to subset a data where only > values w