[R] Importing Data for a two sample t-test
arun
smartpink111 at yahoo.com
Thu Nov 15 14:05:37 CET 2012
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.
More information about the R-help
mailing list