I'm new to R and R-Studio but have been watching lots of videos on how to get started and have picked up the main gist of how it works.
To practice I have assembled a sample data table in Numbers and exported it as a csv to R and the first image shows the table in R. It lists CoP values (and uncertainties) for 20 test events for two types of test, a regular and a control. I am just practicing showing the first column (CoP) against ID in a histogram.
When I use the code:
ggplot(aes(ID)) + geom_histogram(binwidth = 2, fill = "steelblue", alpha = 0.5) + labs(title = "CoP vs ID",
x = "ID", y = "CoP") + theme_bw()```
it produces a histogram as shown in the second image that does not seem to distinguish the various nuanced values (e.g. 2.12, 2.63, etc) but instead shows CoP values of 1, 2 or 3 against the test ID.
Is this because I have not specified a resolution to the mapping or something similar?
I have tried your code and it makes no difference. In this example, I want the test ID on the X axis and the CoP value on the Y axis. What I get is in the image link
It seems I need to specify the Y-axis variable and perhaps some resolution? The histogram blocks are all the same size indicating the frequency of occurrence instead of the CoP value (e.g. 2.14) for each test ID.
I showed the COP data table at the start. Here is the link again.
I know Histograms are usually categorical on the X-axis and then a count or value on the Y, and I can produce a scatter plot (Co-P-Scatter-plot hosted at ImgBB — ImgBB) but wanted a visual showing Test ID on the X and the COP value as the bar height (Y value). Is that not doable?
Sounds like a good idea but I can't see how to do this. I have put 'dput' into FAQ and it comes up with how to provide a subset of data that is already loaded into R.
Do you have a link on how to bring in a sample of external data?
All I am trying to do I give an alternative visualization to a scatter graph by showing the ID on the X-Axis and the value for CoP as the height of the histogram.
I think you are confusing histogram with a bar chart, a histogram is a very particular subset of the more general bar charts. Do you require binning ? (histogram) , or do you already have binned data (bar chart).
Your ID's to use on the x-axis strongly imply you have a bar chart to generate and therefore geom_histogram is not the approriate tool. if you want the bar to be as high as CoP then you would use geom_col, withaes using y=CoP