s-news
[Top] [All Lists]

Re: Translating characters

To: "'Stuart Luppescu'" <s-luppescu@uchicago.edu>, <s-news@lists.biostat.wustl.edu>
Subject: Re: Translating characters
From: "Vivek Satsangi" <vivek.satsangi@gmail.com>
Date: Mon, 9 Mar 2009 16:41:20 -0400
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date :message-id:mime-version:content-type:content-transfer-encoding :x-mailer:x-mimeole:in-reply-to:thread-index; bh=UnZQScy1pnq6ylSLDrorcjxPfhfI/hF/EqqnQu20UFg=; b=cz3/WD+UTSeVF4p2FDob3RTdUde/cJ2lGFscoZTFiolKfdSqWXtzAxcJNNDYYl6LeY mX84Eo13J2Bf+J+mnz58TvZFO74tdIEx5NrZH6oV6aUwVpKDbC70QfdFKS+uNFUi6XQ9 l44HPdYcjc37lZfH1uGyiT0rVLFEAvnv7bXhY=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:message-id:mime-version:content-type :content-transfer-encoding:x-mailer:x-mimeole:in-reply-to :thread-index; b=KJHNiEZyivRRLX3+6Lf7sgzgcsyxL+sEXuZVyz99xeaok27zM1KHI6XgFqC8jTTV4/ ibQXFSmXkFRR0d37y2e/rYVC1FmiCCl18sZdxv0Kbfxdm0aL7cCm/vuuk+A+mcJz43/Q Nob803mc+nT41bVWJphH+5tP2FUE7omKbaoT4=
In-reply-to: <1236631068.26105.9.camel@musuko.uchicago.edu>
Thread-index: Acmg9vWeoTrmdGP4Qy2XxZm32BgzbwAACZqg
Stuart,

Which returns the positions that meet your criteria. In the vector case, the
same things is happening, but it does not seem like that is what you want to
do-- you need something like a decode in SQL (the function name is escaping
me right now, but it is NOT which()).

Cheers,

Vivek

-----Original Message-----
From: s-news-owner@lists.biostat.wustl.edu
[mailto:s-news-owner@lists.biostat.wustl.edu] On Behalf Of Stuart Luppescu
Sent: Monday, March 09, 2009 4:38 PM
To: s-news@lists.biostat.wustl.edu
Subject: [S] Translating characters

Hello, I have a little problem that should be very easy. Actually, it
works at the atomic level, but not on vectors.

I want to translate course grades, c("F", "D", "C", "B", "A") to their
numerical equivalents: c(0, 1, 2, 3, 4). This code works:

> marks <- c("F", "D", "C", "B", "A")
> foo <- "B"
> which(marks==foo) - 1
[1] 3

But when I try to translate a vector of marks to a vector of points, it
fails:

> final.points <- which(marks == testing$final.mark)
> final.points
  [1]   4   9  16  31  33  38  49  53  56  57  68  69  73  90  97 101 106
113
 [19] 116 126 128 131 137 141 146 151 154 156 157 159 160 164 171 185 191
198
 [37] 200 206 207 208 231 243 251 252 253 257 261 267 272 277 279 282 286
287

If someone could explain this to me I'd be very appreciative.

-- 
Stuart Luppescu -=- slu .at. ccsr.uchicago.edu        
University of Chicago -=- CCSR 
???????? -=-    Kernel 2.6.25-gentoo-r7                
Xander: Well, I guess that makes it official.
 Everybody's paired off. Vampires get dates. Hell, 
 even the school librarian sees  more action than
 me.  
 
 
 
 
 
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news


<Prev in Thread] Current Thread [Next in Thread>