If p1982 is a data.frame:
p1982$Y <- ifelse(p1982$sc<90, 'inward', 'outward')
If it is a matrix
p1982 <- cbind(p1982, Y=ifelse(p1982[,'sc']<90, 'inward',
'outward'))
On 12/8/06, Aimin Yan <aiminy@iastate.edu> wrote:>
> I have a data set like this
> I want to assign "outward" to Y if sc <90 and assign
"inward" to Y if
> sc>=90.
> then cbind(p1982,Y) to get like these
>
> p aa as ms cur sc Y
> 1 154l_aa ARG 152.04 108.83 -0.1020140 92.10410 inward
> 2 154l_aa THR 15.86 28.32 0.2563560 103.67100 inward
> 3 154l_aa ASP 65.13 59.16 0.0312137 7.27311 outward
> 4 154l_aa CYS 57.20 49.85 -0.0549589 72.97930 outward
> 5 154l_aa TYR 28.87 31.75 0.0526457 96.11660 inward
> 6 154l_aa ASN 31.14 31.09 0.0632711 55.65980 outward
>
> does anyone know how to these?
>
> Aimin
>
> > head(p1982)
> p aa as ms cur sc
> 1 154l_aa ARG 152.04 108.83 -0.1020140 92.10410
> 2 154l_aa THR 15.86 28.32 0.2563560 103.67100
> 3 154l_aa ASP 65.13 59.16 0.0312137 7.27311
> 4 154l_aa CYS 57.20 49.85 -0.0549589 72.97930
> 5 154l_aa TYR 28.87 31.75 0.0526457 96.11660
> 6 154l_aa ASN 31.14 31.09 0.0632711 55.65980
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?
[[alternative HTML version deleted]]