Tag: data visualization

  • 19. How to visualize data with RStudio (R programming language)

    #RStudio #R #R_Programming_language

    RStudio is an integrated development environment that allows you to create and manage projects using R language. R is a programming language for statistical computing and data visualization.

    Sign up for an account at the RStudio Cloud in https://posit.cloud/

    Create a New Project

    This will open the RStudio Cloud console.

    Then you need to install the packages to RStudio Cloud. Packages are units of reproducible R code.

    First install tidyverse: the tidyverse is a collection of packages in R for data manipulation, exploration, and visualization. To install the core tidyverse packages and load them: in the bottom of the console, type install.packages(“tidyverse”) and press Enter.

    To load the core tidyverse, type library(tidyverse) and press Enter

    Many of the `tidyverse` packages contain sample datasets to practice `R` skills, e.g.  the `diamonds` dataset (already loaded together with tidyverse package).

    To preview the data use the `head()` function, which displays the columns and the first several rows of data.

    Other useful functions to summarize or preview the data:

    • str() and glimpse() functions will both return summaries of each column in your data arranged horizontally.
    • the colnames() function returns a list of column names from your dataset
    • the summarize() function generates a wide range of summary statistics for your data. For example, to know what the mean for `carat` was in this dataset use summarize(diamonds, mean_carat = mean(carat))

    To clean data:

    • the function to rename the columns, or variables, in your data is rename(), e.g.rename(diamonds, carat_new = carat, cut_new = cut)

    To visualize data:

    The most commonly used visualization packages is ggplot2, automatically loaded together tidyverse.

    The code that takes the `diamonds` data, plots the carat column on the X-axis, the price column on the Y-axis, and represents the data as a scatter plot using the `geom_point()` command and changes the color of each point so that it represented another variable, such as the cut of the diamond is:

    To create a different plot for each type of cut use the `facet_wrap()` function:

  • 18. How to start visualizing data with Tableau

    #dataviz #Tableau

    Create a Tableau public profile in https://public.tableau.com/app/discover

    Click on your profile to create a new visualization.

    Click on Create a visualization.

    Tableau opens a window to Connect data.

    You can find sample data here -> https://public.tableau.com/app/learn/sample-data

    e.g. Download the Excel file with data for the Significant volcanic eruptions from (source https://www.ncei.noaa.gov/)

    Upload the data file in Tableau.

    Drag and drop the table to create a data model.

    When uploaded click on Update now to populate the table.

    Click on Sheet 1 (bottom left) to create a visualization.

    Double click or drag and drop the fields in the left Data pane to add data for the visualization.

    Selecting Country the canvas displays a map of the countries with points indicating which countries are represented in the data.

    The points are all the same size because, if there is no measure selected, Tableau defaults to scale each country equally.

    Double clicking on a measure (e.g. Volcano explosivity) the dot sizes change.