Dear all,
Thank you so much for all the replies.
The following worked exactly as needed:
> library("HSAUR2", lib.loc="/home/liv/R/i686-pc-linux-gnu-library/3.0")
> library("reshape2", lib.loc="/usr/local/lib/R/site-library")
> data(womensrole)
> zzz <- melt(womensrole,id.var=c("education","gender"
Hi,
One way would be:
womensrole <- read.table(text="education gender agree disagree sexe
1 0 Male 4 2 0
2 1 Male 2 0 0
3 2 Male 4 0 0
4 3 Male 6 3 0
5 4 Male 5 5 0
6 5 Male 13
I do not think Carl's solution answers your question. Try this:
z <- textConnection(
"education gender agree disagree sexe
1 0 Male 420
2 1 Male 200
3 2 Male 400
4 3 Male 630
5 4 Male
@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Carl Witthoft
Sent: Monday, November 25, 2013 11:14 AM
To: r-help@r-project.org
Subject: Re: [R] convert data frame: two variables into _one_ binary variable
In R, as.logical() and other functions treat anything >0 as TRUE. Thu
In R, as.logical() and other functions treat anything >0 as TRUE. Thus:
Rgames> foo<-sample(0:5,10,rep=TRUE)
Rgames> foo
[1] 0 5 1 0 1 5 2 5 4 5
Rgames> as.logical(foo)
[1] FALSE TRUE TRUE FALSE TRUE TRUE TRUE TRUE TRUE TRUE
For your case, simply (womensrole$agree>womensrole$disagre
5 matches
Mail list logo