I am interested in building a model with a subset of data from a column. The first 6 lines of my data look like this: QUAD YEAR SITE TREAT HERB TILL PLANT SEED Kweed 1 A4 2002 s 1 N N N N 55.00 2 A10 2002 s 1 N N N N 60.00 3 B2 2002 s 1 N N N N 35.00 4 C2 2002 s 1 N N N N 23.00 5 C9 2002 s 1 N N N N 70.00 6 11 2002 m 1 N N N N 22.00 I tried this command to get the subset I want:> knap.fit1<-(lm(Kweed~TREAT[41:60,81:100,101:120,121:140], data=knap))No luck. Can anyone tell me how to code for this subset. Thanks Lew Stringer M.S. Student- Land Rehabilitation Dept. of Land Resources and Environmental Sciences Montana State University 822 Leon Johnson Hall Bozeman, MT 59717 Lab:(406)994-6811 Fax:(406)994-3933
You might want to try subsetting the data frame first, and then fit the model. Something like knap.sub <- knap[c(41:60,81:100,101:120,121:140), ] knap.fit1 <- lm(Kweed ~ TREAT, data = knap.sub) might work for you. -roger _______________________________ UCLA Department of Statistics rpeng at stat.ucla.edu http://www.stat.ucla.edu/~rpeng On Fri, 7 Feb 2003, Lew wrote:> I am interested in building a model with a subset of data from a column. > > The first 6 lines of my data look like this: > QUAD YEAR SITE TREAT HERB TILL PLANT SEED Kweed > 1 A4 2002 s 1 N N N N 55.00 > 2 A10 2002 s 1 N N N N 60.00 > 3 B2 2002 s 1 N N N N 35.00 > 4 C2 2002 s 1 N N N N 23.00 > 5 C9 2002 s 1 N N N N 70.00 > 6 11 2002 m 1 N N N N 22.00 > > I tried this command to get the subset I want: > > > knap.fit1<-(lm(Kweed~TREAT[41:60,81:100,101:120,121:140], data=knap)) > No luck. > > Can anyone tell me how to code for this subset. > > Thanks > > Lew Stringer > M.S. Student- Land Rehabilitation > Dept. of Land Resources and Environmental Sciences > Montana State University > 822 Leon Johnson Hall > Bozeman, MT 59717 > Lab:(406)994-6811 > Fax:(406)994-3933 > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > http://www.stat.math.ethz.ch/mailman/listinfo/r-help >
Dear Lew, You could use the subset argument to lm: knap.fit1 <- lm(Kweed ~ TREAT, data=knap, subset=c(41:60,81:100,101:120,121:140)) (You could alternatively subscript both Kweed and TREAT, rather than just TREAT, but this is unnecessarily complicated; as well, you'd need to use c() within the subscript, as in Kweed[c(41:60,81:100,101:120,121:140)].) John At 03:36 PM 2/7/2003 -0700, Lew wrote:>I am interested in building a model with a subset of data from a column. > >The first 6 lines of my data look like this: > QUAD YEAR SITE TREAT HERB TILL PLANT SEED Kweed >1 A4 2002 s 1 N N N N 55.00 >2 A10 2002 s 1 N N N N 60.00 >3 B2 2002 s 1 N N N N 35.00 >4 C2 2002 s 1 N N N N 23.00 >5 C9 2002 s 1 N N N N 70.00 >6 11 2002 m 1 N N N N 22.00 > >I tried this command to get the subset I want: > > > knap.fit1<-(lm(Kweed~TREAT[41:60,81:100,101:120,121:140], data=knap)) >No luck. > >Can anyone tell me how to code for this subset.----------------------------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 email: jfox at mcmaster.ca phone: 905-525-9140x23604 web: www.socsci.mcmaster.ca/jfox -----------------------------------------------------
Maybe Matching Threads
- Problems with XP
- Problem with which function
- [LLVMdev] what is the Line number of Phi Node with addr2line
- [LLVMdev] what is the Line number of Phi Node with addr2line
- [LLVMdev] Use clang to generate LLVM IR with -O3, how to visit these load operations after -reg2mem