Re: [R] Subset command

2021-10-15 Thread Bert Gunter
I assume that prim, etc. are columns of your data frame, mydata. Ergo, the error message "prim not found" as 'prim' etc. does not exist in the Global environment. exclude <- with(mydata, prim == -9, etc. ) should get what you want to evaluate your second subset statement if I have understood corre

Re: [R] Subset command

2021-10-15 Thread Steven Yen
Thanks. YES the second call to subset is there, trying to use my failed definition of "exclude". Read on.. On 2021/10/16 上午 09:35, Jeff Newmiller wrote: I don't see a "second one". Looks like you forgot the subset function call? On October 15, 2021 6:23:56 PM PDT, Steven Yen wrote: The follo

Re: [R] Subset command

2021-10-15 Thread Jeff Newmiller
I don't see a "second one". Looks like you forgot the subset function call? On October 15, 2021 6:23:56 PM PDT, Steven Yen wrote: >The following "subset command works. I was hoping the second would as >well but it does not. > >My definition of exclude is rejected. > >Help please? Thanks. > > > m

[R] Subset command

2021-10-15 Thread Steven Yen
The following "subset command works. I was hoping the second would as well but it does not. My definition of exclude is rejected. Help please? Thanks. > mydata<-subset(mydata, +    prim>-9 & highsch>-9  & tert>-9 & +    govt>-9 & nongovt>-9  & +    m

Re: [R] Subset command and the : operator

2011-05-27 Thread jim holtman
What you are probably looking for is the %in% operator: with(mydata, sum(table(X1[X2 %in% 5:8]))) Read up on how operations are vectorized and how variables are recycled if not long enough > x <- 1:10 > x == 1:2 # compares first two fine [1] TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FAL

[R] Subset command and the : operator

2011-05-27 Thread Chris Beeley
Hello- I have some code that looks like this: with(mydatalocal, sum(table(Service[Time==5:8]))) This is designed to add up the numbers of responses between the Time codes 5 to 8 (which are integers and refer to quarters). Service is just one of the variables, I'm just trying to count the number