Hi, This is only a small portion of the Data i am working on I want to make a subset of this data set( Data Set=Claims) MemberID ProviderID Vendor PCP Year Specialty 1 42286978 8013252 172193 37796 Y1 Surgery 2 97903248 3316066 726296 5300 Y3 Internal 3 2759427 2997752 140343 91972 Y1 Internal 4 73570559 7053364 240043 70119 Y3 Laboratory I want to put all the rows containing Y1 into a subset. I tried this but it does not work sub <- subset(Claims, Year=Y1) I would greatly appreciate any help Kevin -- View this message in context: http://r.789695.n4.nabble.com/Rearanging-Data-tp4371717p4371717.html Sent from the R help mailing list archive at Nabble.com.
Hi Kevin, Try using ?dput for putting your code on the list, so people could easily import and play with it. I think you probably need to do this: sub <- subset(Claims, Year="Y1") This also should work: sub <- Claims [ Year="Y1",] ----------------Contact Details:------------------------------------------------------- Contact me: Tal.Galili@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) ---------------------------------------------------------------------------------------------- On Thu, Feb 9, 2012 at 4:48 AM, kevin123 <kevincorry123@gmail.com> wrote:> sub <- subset(Claims, Year=Y1) >[[alternative HTML version deleted]]
On Feb 8, 2012, at 9:48 PM, kevin123 wrote:> Hi, > > This is only a small portion of the Data i am working on > I want to make a subset of this data set( Data Set=Claims) > > MemberID ProviderID Vendor PCP Year Specialty > 1 42286978 8013252 172193 37796 Y1 Surgery > 2 97903248 3316066 726296 5300 Y3 Internal > 3 2759427 2997752 140343 91972 Y1 Internal > 4 73570559 7053364 240043 70119 Y3 Laboratory > > I want to put all the rows containing Y1 into a subset. I tried this > but it > does not work > > sub <- subset(Claims, Year=Y1)You (as well , apparently, as Tal) don't seem to have learned that "=" is an assignment function and the needed Comparison operator is "==" ?Comparison Try instead: sub <- subset(Claims, Year=="Y1") -- David Winsemius, MD West Hartford, CT
Try sub <- subset(Claims, Year==Y1) In R, the equality test is performed by two equal signs, not one. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spector at stat.berkeley.edu On Wed, 8 Feb 2012, kevin123 wrote:> Hi, > > This is only a small portion of the Data i am working on > I want to make a subset of this data set( Data Set=Claims) > > MemberID ProviderID Vendor PCP Year Specialty > 1 42286978 8013252 172193 37796 Y1 Surgery > 2 97903248 3316066 726296 5300 Y3 Internal > 3 2759427 2997752 140343 91972 Y1 Internal > 4 73570559 7053364 240043 70119 Y3 Laboratory > > I want to put all the rows containing Y1 into a subset. I tried this but it > does not work > > sub <- subset(Claims, Year=Y1) > > I would greatly appreciate any help > > Kevin > > -- > View this message in context: http://r.789695.n4.nabble.com/Rearanging-Data-tp4371717p4371717.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 > and provide commented, minimal, self-contained, reproducible code. >