s-news
[Top] [All Lists]

Translating characters

To: s-news@lists.biostat.wustl.edu
Subject: Translating characters
From: Stuart Luppescu <s-luppescu@uchicago.edu>
Date: Mon, 09 Mar 2009 15:37:48 -0500
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.  
 
 
 
 
 

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