Hi --
I had a pretty quick R question since unfortunately I have not been able to
find an answer on Google. It shouldn't take much more than a minute to
answer.
I'm trying to add up the major gleason grade and minor gleason grade for an
analysis of patients with prostate cancer. One column has
If we assume that your data are in a data frame (which doesn't allow
spaces in column names, hence the periods in the call below):
df = data.frame(Major.Gleason = c(4,5,2,3), Minor.Gleason = c(3,2,4,3))
You can paste together the contents of the two columns with a plus
sign in between using the
On Jun 20, 2011, at 11:47 AM, Luke Miller wrote:
If we assume that your data are in a data frame (which doesn't allow
spaces in column names, hence the periods in the call below):
df = data.frame(Major.Gleason = c(4,5,2,3), Minor.Gleason =
c(3,2,4,3))
You can paste together the contents
Thanks! Very glad you pointed me to the paste function, it looks very
helpful.
I have a quick follow-up after reading through the online tutorial on the
paste function:
Why do we need quotation marks around Major Gleason and Minor Gleason
in: output = paste(df [,'Major.Gleason'], df[
The quotes around 'Major.Gleason' and 'Minor.Gleason' are required for
accessing data frame columns by name. You could alternately refer to
the columns by number if you're sure you know which column is which:
output = paste(df[ ,1], df[ ,2], sep = '+')
It's just a requirement for accessing
Ben:
1. One doesn't ask questions like this. Syntax is syntax.
2. This has nothing to do with paste; it's the syntax of [ ,
subscripting/extraction
3. But it does make sense:
a - b
z - data.frame(a=1:3, b=4:6)
z[ ,a] # the a column of z
z[ ,a] # the column of z with the value of the object
Sorry, I was unclear. The comment after the second should be:
z[ ,a] # the column of z whose name is the value of the object a
-- Bert
On Mon, Jun 20, 2011 at 9:38 AM, Bert Gunter bgun...@gene.com wrote:
Ben:
1. One doesn't ask questions like this. Syntax is syntax.
2. This has nothing
Thanks for the clarifications.
On Mon, Jun 20, 2011 at 12:40 PM, Bert Gunter gunter.ber...@gene.comwrote:
Sorry, I was unclear. The comment after the second should be:
z[ ,a] # the column of z whose name is the value of the object a
-- Bert
On Mon, Jun 20, 2011 at 9:38 AM, Bert Gunter
8 matches
Mail list logo