-1

I have a dataset set with 34 columns and 600+ rows.

I successfully managed to reshape it for my data to be predicted for 5 columns (5 years) using reshape2

Dataset_name <- melt(data=XYZ, id.vars=c("A", "B", "C",.... {so on minus 5 columns}))

Now I have the reshaped data and plotted the graph and since it has 600+ points in each column, I cant make sense of it.

Is it possible for me to plot the top Row 1 to Row 50 in one graph and in another Row 51 to Row 100 and so on?

Also, I want to connect the dots to see whether they varied over the years.

Thanks.

enter image description here Dataset

Zulu
  • 13
  • 4

1 Answers1

0

You can assign rows numbers (first 50 designated as 1, second 50 as 2...) and use that variable in facet_wrap. Each facet would thus hold 50 data points. Here's an example on the iris dataset which comes shipped with R.

library(ggplot2)

nrow(iris) # 150, let's do 50 obs. per facet
iris <- iris[sample(1:nrow(iris)), ] # shuffle the dataset
iris$desig <- rep(c("set1", "set2", "set3"), each = 50)

ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
  theme_bw() +
  geom_point() +
  facet_wrap(~ desig)

enter image description here

Roman Luštrik
  • 69,533
  • 24
  • 154
  • 197
  • Thanks for this, but I want to plot all the points and show them. Thats why I asked how to plot 50 rows in each graph along with line. Jitter or Boxplot, doesnt show the variation in rows that show the real difference. They show the entire data. – Zulu Aug 06 '17 at 15:12
  • @Zulu I've edited my answer. If you provide a reproducible example I can also offer some code. – Roman Luštrik Aug 06 '17 at 15:54
  • Lustrik I have added the dataset. I have uploaded the first rows of the data. These are the modeled results aka. Final results. Thanks a ton!! – Zulu Aug 07 '17 at 10:22