I am trying to do a two sample t-test with data that i received in a text document. one list has the slab weights and the second has the company it is associated with. here is an example. weights company 1 A 2 A 2 B 3 B I was able to import the data but i cannot figure out how separate the data. I want to put them in two separate sets, one being A and one being B. Any help would be appreciated. Thanks. -- View this message in context: http://r.789695.n4.nabble.com/Importing-Data-for-a-two-sample-t-test-tp4649565.html Sent from the R help mailing list archive at Nabble.com.
?subset --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. nilsonern <Nilsonern at gmail.com> wrote:>I am trying to do a two sample t-test with data that i received in a >text >document. one list has the slab weights and the second has the company >it >is associated with. here is an example. > >weights company >1 A >2 A >2 B >3 B > >I was able to import the data but i cannot figure out how separate the >data. >I want to put them in two separate sets, one being A and one being B. >Any >help would be appreciated. Thanks. > > > >-- >View this message in context: >http://r.789695.n4.nabble.com/Importing-Data-for-a-two-sample-t-test-tp4649565.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.
Hi, Not sure why you wanted to separate A and B for a two sample t-test. dat1<-read.table(text=" weights? company 1????????????????? A 2????????????????? A 2????????????????? B 3????????????????? B ",sep="",header=TRUE,stringsAsFactors=FALSE) ?t.test(weights~company,data=dat1) #??? Welch Two Sample t-test # #data:? weights by company #t = -1.4142, df = 2, p-value = 0.2929 #alternative hypothesis: true difference in means is not equal to 0 #95 percent confidence interval: ?#-4.042435? 2.042435 #sample estimates: #mean in group A mean in group B ? # ???????? 1.5???????????? 2.5 In case, you wanted to separate A and B: library(reshape2) dcast(dat1,weights~company,value.var="weights") #? weights? A? B #1?????? 1? 1 NA #2?????? 2? 2? 2 #3?????? 3 NA? 3 Hope it helps. A.K. ----- Original Message ----- From: nilsonern <Nilsonern at gmail.com> To: r-help at r-project.org Cc: Sent: Wednesday, November 14, 2012 11:52 PM Subject: [R] Importing Data for a two sample t-test I am trying to do a two sample t-test with data that i received in a text document.? one list has the slab weights and the second has the company it is associated with.? here is an example. weights? company 1? ? ? ? ? ? ? ? ? A 2? ? ? ? ? ? ? ? ? A? 2? ? ? ? ? ? ? ? ? B 3? ? ? ? ? ? ? ? ? B I was able to import the data but i cannot figure out how separate the data. I want to put them in two separate sets, one being A and one being B.? Any help would be appreciated.? Thanks. -- View this message in context: http://r.789695.n4.nabble.com/Importing-Data-for-a-two-sample-t-test-tp4649565.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.
HI, If you need to separate into two datasets, ?dat1[dat1$company=="A",] #? weights company #1?????? 1?????? A #2?????? 2?????? A #or ?dat1[dat1$company=="B",] #or split into a list ?split(dat1,dat1$company) A.K. ----- Original Message ----- From: nilsonern <Nilsonern at gmail.com> To: r-help at r-project.org Cc: Sent: Wednesday, November 14, 2012 11:52 PM Subject: [R] Importing Data for a two sample t-test I am trying to do a two sample t-test with data that i received in a text document.? one list has the slab weights and the second has the company it is associated with.? here is an example. weights? company 1? ? ? ? ? ? ? ? ? A 2? ? ? ? ? ? ? ? ? A? 2? ? ? ? ? ? ? ? ? B 3? ? ? ? ? ? ? ? ? B I was able to import the data but i cannot figure out how separate the data. I want to put them in two separate sets, one being A and one being B.? Any help would be appreciated.? Thanks. -- View this message in context: http://r.789695.n4.nabble.com/Importing-Data-for-a-two-sample-t-test-tp4649565.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.
On 2012-11-14 20:52, nilsonern wrote:> I am trying to do a two sample t-test with data that i received in a text > document. one list has the slab weights and the second has the company it > is associated with. here is an example. > > weights company > 1 A > 2 A > 2 B > 3 B > > I was able to import the data but i cannot figure out how separate the data. > I want to put them in two separate sets, one being A and one being B. Any > help would be appreciated. Thanks. >Why separate? The 'long' form is generally preferred in statistical analyses. Just use the formula version of t.test(). Peter Ehlers> > > -- > View this message in context: http://r.789695.n4.nabble.com/Importing-Data-for-a-two-sample-t-test-tp4649565.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. >