[R] Combining dataframes with different row numbers and plotting with ggplot2

maryam moazam setareh227 at gmail.com
Fri Jan 8 22:44:55 CET 2016

Dear Sir / Madam,

I have just come to the amazing R software, so please be patient if my
question is basic for you. I have 2 text file (say 1.txt and 2.txt), each
file containing 2 columns and different row numbers, like below

case size
case1 120
case2 120
case3 121
case4 121
case5 121
case6 122
case7 122
case8 123

I would like to have a one plot for all text files, with x-axis shows the
size between 300-1200 with the interval of 200 (300,500,700,900,1200) and
size between 1201-1500 with the interval of 1000. For dataframes with the
equal row numbers, the following codes worked well,

df1 = data.frame("1.txt", header=T)
df2 = data.frame("2.txt", header=T)
*combining two dataframes with equal row number*

df = data.frame(df1$size,df2$size)
melted <- melt(df)

ggplot(data=melted, aes(value))+aes(fill=variable)+ geom_histogram
(binwidth =500)+


but I couldn't reproduce the plot with these codes for dataframes with
different row number. I think the problem is* how to combine datafrmaes
with the different row number*, could you please help me out on this issue?

Thank you in advance

	[[alternative HTML version deleted]]

More information about the R-help mailing list