I have a problem with using ggplot2 to generate histograms. I'm using the following function, which receives input, a data.frame. The function only has to create a data.frame as you can see. But I get an error indicating that the number of rows in each column is different. Any idea? I am using RStudio, Is it a problem of the library ggplot2? if so, is there any other library that serves to make histograms? I tested with barplot but I get an error margins ...
my function:
HIST_EPC_list<-function(DF_TAG_PHASE_EPC_counter){
require(ggplot2)
ggplot(DF_TAG_PHASE_EPC_counter, aes(x=DF_TAG_PHASE_EPC_counter$Tag_PHASE, y=DF_TAG_PHASE_EPC_counter$Num_EPC))+xlab("PHASE")+ylab("Number of EPC's")+ ggtitle("Histogram of Number of EPC/PHASE")+geom_histogram(stat="identity")
#barplot(DF_TAG_PHASE_EPC_counter$Num_EPC, names.arg = DF_TAG_PHASE_EPC_counter$Tag_PHASE, xlab = "Tag_PHASE", ylab = "Num_EPC", main="Histograma Num tags/PHASE:", width=10)
#par(mar=c(4,4,4,4))
}
example of data.frame DF_TAG_PHASE_EPC_counter
Tag_PHASE Num_EPC
1 101.0 1
2 120.0 1
3 146.0 1
4 16.0 1
5 163.0 1
6 25.0 1
7 42.0 1
8 53.0 2
9 56.0 1
10 61.0 1
11 64.0 3
12 75.0 1
THE ERROR:
Error in data.frame(x = 1:8, y = c(1L, 1L, 1L, 2L, 1L, 1L, 2L, 1L), PANEL = c(1L, : arguments imply differing number of rows: 8, 12