7.2 Import / read in data

7.2.1 from CSV

Let’s now import the content of a first file in our environment:

geneexp <- read_csv("DataViz_source_files-main/files/expression_20genes.csv")

Because your working directory is /your_home_directory/DataViz_2023/, R can find the DataViz_source_files-main without requiring the whole path: this is a relative path as opposed to an absolute path .

The content of file expression_20genes.csv is now stored in the object named geneexp.

The function also outputs some information about the data you are importing:

import zip

Such as that:

  • The data contains 20 rows (observations), and 4 columns (variables).
  • Out of these 4 columns:
    • 2 contain characters (chr): Gene and DE.
    • 2 contain numbers (dbl for “double”): sample1 and sample2

Remember that you can find the objects that you create in the Environment tab in the upper-right panel.

Note that if you click on an object name in the Environment tab, it will open on the upper-left panel. Let’s try with geneexp:

import env