[R] Subseting

Jessica Streicher j.streicher at micromata.de
Thu Aug 2 11:30:44 CEST 2012


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't explaining your problem well^^

On 02.08.2012, at 11:18, Akhil dua wrote:

> sry its not firms 
> its banks 
> 
> On Thu, Aug 2, 2012 at 2:42 PM, Jessica Streicher <j.streicher at micromata.de> wrote:
> 
> 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 data looks like
> >
> > Year  Name totalliabilties assets
> > 1990  a              90            10
> > 1991  a              89            48
> > 1992  a              87            34
> > 1993  a              56            05
> > 1990  b              90            11
> > 1991  b              69            43
> > 1992  b              37            34
> > 1993  b              46            17
> > 1990  c              55            10
> > 1991  c              67            18
> > 1992  c              34            24
> > 1993  c              53            35
> >
> > please keep in mind that I have 49 firms so I cant do
> > object<-data[,c("names of the banks I need the data")]
> 
> That would actually rather be
> data[data$Name %in% names, ]
> 
> wouldn't it? You want to extract the rows that belong to a bank you want to retain?
> 
> what are firms? what have the firms to do with the banks and their names?
> 
> > and then extract the data for these banks out of the whole sample
> >
> >       [[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.
> 
> 



More information about the R-help mailing list