[R] Subseting

Jessica Streicher j.streicher at micromata.de
Thu Aug 2 11:12:33 CEST 2012


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