[R] Putting referenced titles on plots

grr@grell.mailshell.com grr at grell.mailshell.com
Mon May 31 20:43:39 CEST 2004


Thank you both for the help. The below 1. works for me, too, both 
cases. I am not actually using "names" as an object name. I am writing:

	for (i in 2:nrow(ctxheadlogtrans)){hist(ctxheadlogtrans[,i], br=100, 
main=gene.names.head[i])}

which gives me histograms titled "1", "2", "3", etc. But:

	gene.names.head[1]

gives me "1007_s_at", and 	

	gene.names.head[2]

gives me "1053_at" and

	for (i in 2:5){print(gene.names.head[i])}

gives me a list of the titles I want.

I am using RAqua 1.8.1 on Mac OS X.

Is there something I am missing?

Thanks,

Graham

On May 31, 2004, at 10:37 AM, Spencer Graves wrote:

>      1.  That seems strange.  The following simplification of your 
> function produced sensible results for me:
>             hist(1:4, main= "1098_s_at")
>
>      I got similar results from your exact statement after first 
> defining names and ctx as follows:
>      names <- letters[1:3]
>      ctx <- data.frame(x=1:4, y=1:4, a=1:4)
>
>      In each case, I got a histogram with a standard text title at the 
> top.  What version of R are you running?  If it's NOT R 1.9.0pat, you 
> might try upgrading -- and then running "update.packages()".
>      2. "names" is that name of a function, and it is generally 
> considered bad practice to mask function names with names of other 
> objects, even though R can often (though not always) determine which 
> object you want from the context.  What do you get from "conflicts()"?
>      hope this helps.  spencer graves
>
> grr at grell.mailshell.com wrote:
>
>> I have a data frame "ctx" and an array "names", where names[i] is the 
>> column name for ctx[i], and am making histograms for each column of 
>> ctx:
>>
>> for (i in 2:ncol(ctx)){hist(ctx[,i], br=100, main=names[i])}
>>
>> The titles don't come out like I expect. Each names[i] is something 
>> like "1098_s_at" and R doesn't seem to like printing these. Instead, 
>> it prints "1" or "2" or "3" etc.
>>
>> I have also tried binding ctx and names into a single data frame and 
>> referencing the first row of each [i] as the title, but I get the 
>> same result.
>>
>> Can someone tell me how to get these titles attached?
>>
>> Thanks,
>>
>> Graham
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide! 
>> http://rd.mailshell.com/www.R-project.org/posting-guide.html
>
>
>




More information about the R-help mailing list