Generating a histogram with R

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Generating a histogram with R

a217
Hello,

I have a sample file:
chr22	100	150	125	21	0.145	+
chr22	200	300	212	13	0.05	+
chr22	345	365	351	12	0.09	+
chr22	500	750	510	15	0.10	+
chr22	500	750	642	9	0.02	+
chr22	800	900	850	10	0.05	+

where I need to generate a histogram from the data in column 6 (i.e. 0.145, 0.05, etc.). To make it easier to read, I would plot the data as 1-0.05=0.95 for all of the data in column 6.

What I would like to know is how to generate a histogram with the data from one file? Also, would I be able to generate one histogram from multiple files as well (with the same format)?

For example, I have multiple files in the same format as the sample file above, and I would like to make one histogram for all column six data in all files.

Thank you,
a217
Reply | Threaded
Open this post in threaded view
|

Re: Generating a histogram with R

Bert Gunter
Hello:

R has an extensive Help system. Please learn to use it.

?histogram
?help

Also see the online manual tutorial "An Introduction to R"

-- Bert

On Tue, Jul 12, 2011 at 12:41 PM, a217 <[hidden email]> wrote:

> Hello,
>
> I have a sample file:
>
> chr22   100     150     125     21      0.145   +
> chr22   200     300     212     13      0.05    +
> chr22   345     365     351     12      0.09    +
> chr22   500     750     510     15      0.10    +
> chr22   500     750     642     9       0.02    +
> chr22   800     900     850     10      0.05    +
>
>
> where I need to generate a histogram from the data in column 6 (i.e. 0.145,
> 0.05, etc.). To make it easier to read, I would plot the data as 1-0.05=0.95
> for all of the data in column 6.
>
> What I would like to know is how to generate a histogram with the data from
> one file? Also, would I be able to generate one histogram from multiple
> files as well (with the same format)?
>
> For example, I have multiple files in the same format as the sample file
> above, and I would like to make one histogram for all column six data in all
> files.
>
> Thank you,
> a217
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Generating-a-histogram-with-R-tp3663350p3663350.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.
>



--
"Men by nature long to get on to the ultimate truths, and will often
be impatient with elementary studies or fight shy of them. If it were
possible to reach the ultimate truths without the elementary studies
usually prefixed to them, these would not be preparatory studies but
superfluous diversions."

-- Maimonides (1135-1204)

Bert Gunter
Genentech Nonclinical Biostatistics

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Generating a histogram with R

David Winsemius
In reply to this post by a217

On Jul 12, 2011, at 3:41 PM, a217 wrote:

> Hello,
>
> I have a sample file:
>
> chr22 100 150 125 21 0.145 +
> chr22 200 300 212 13 0.05 +
> chr22 345 365 351 12 0.09 +
> chr22 500 750 510 15 0.10 +
> chr22 500 750 642 9 0.02 +
> chr22 800 900 850 10 0.05 +
>
>
> where I need to generate a histogram from the data in column 6 (i.e.  
> 0.145,
> 0.05, etc.). To make it easier to read, I would plot the data as  
> 1-0.05=0.95
> for all of the data in column 6.

That makes no sense to me, unless  you want to pre-multiply all values  
by 0.95.

>
> What I would like to know is how to generate a histogram with the  
> data from
> one file? Also, would I be able to generate one histogram from  
> multiple
> files as well (with the same format)?

?hist
?histogram (# lattice

There are a ton of worked examples in the Archives. Learn to search.  
Reasonable search terms once you get to Barons site with RSiteSearch  
are (after setting the web interface to get r-help postings): "grouped  
histogram"

>
> For example, I have multiple files in the same format as the sample  
> file
> above, and I would like to make one histogram for all column six  
> data in all
> files.

Also there are a ton of worked examples in the archive dealing with  
accessing multiple files.

>
> Thank you,
> a217
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Generating-a-histogram-with-R-tp3663350p3663350.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.

David Winsemius, MD
West Hartford, CT

______________________________________________
[hidden email] 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.