Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I tried to preform a t.test on two group of factor with out the levels.
The data look lies this:
group x
0.4749584
0.5873566
0.5803553
0.5958644
0.5745614
0.562469
group y
0.5873566
0.5803553
0.5958644
0.5745614
0.5624696
Then I tried to perform a t.test between the groups:
x=process_tomas[2,1:5]
y=process_tomas[2,6:11]
z=droplevels.data.frame(x)
u=droplevels.data.frame(y)
# list_u<-as.list(u)
# list_z<-as.list(z)
t.test(z,u)
I got:
Error in if (stderr < 10 * .Machine$double.eps * max(abs(mx), abs(my))) stop("data are essentially constant") :
missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In mean.default(x) : argument is not numeric or logical: returning NA
2: In mean.default(y) : argument is not numeric or logical: returning NA
The list I got from the code looks like this:
list_u
It seems that the levels wasn't dropped.
I checked:
z[,3]
[1] 0.5706557
Levels: 0.5706557
How can I drop the levels and a preforming t.test?
Provided the data you are looking at converting appears as it does in the first chunk with
group x
0.4749584
0.5873566
0.5803553
0.5958644
0.5745614
0.562469
group y
0.5873566
0.5803553
0.5958644
0.5745614
0.5624696
he best way to get the values from those lists is to pass the factors through character strings and then to numerics as such:
z=as.numeric(as.character((group x))
u=as.numeric(as.character((group y))
From there you can simply run the t-test and it should be fine.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.