Page 263 - Data Science class 11
P. 263

set.seed(1234)
                # Give the chart a file name.
                png(file = "line_chartggplt.jpg")
                df <- data.frame(Country = c("Country1", "Country2", "Country3"),
                WC_win = c(1,2,5))
                p <- ggplot(data = df,
                aes(x = Country, y = WC_win, group = 1))+ geom_line() + geom_point()
                p
                # Save the file.
                dev.off()
            When you execute the above code, it produces the following result:


















            The following line graph is generated.




























            7.7 hIstograMs

            A histogram is a graphical representation that organises a group of data points into user-specified ranges. Similar in
            appearance to a bar graph, the histogram condenses a data series into an easily interpreted visual by taking many
            data points and grouping them into logical ranges or bins.
            A histogram is similar to a bar chart, but the difference is that it groups the values into continuous ranges. Each bar
            in the histogram represents the height of the number of values present in that range.
            The histogram is a popular graphing tool. It is used to summarise discrete or continuous data that are measured on an
            interval scale. It is often used to illustrate the major features of the distribution of the data in a convenient form.
            Histograms are used to show the distributions of variables, while bar charts are used to compare variables.

                                                           Coding for Data Science Visualisation using R-Studio  261
   258   259   260   261   262   263   264   265   266   267   268