Data Structure

2024-02-21

We Have Done

  • Data types
  • Using functions and Using Functions and Libraries
    • import() Python
    • library() R
    • FUN(args)

Homework3

  • Write code and debugging

    • import a library, call functions, data conversion, indexing

    • Observe from visualizing, printing and reading

We have read

Data Structures

Same function doesn’t work equivalently on different data structures length

Data Structures

  • List:

    • Different types in both R and Python

    • Nested in R, double bracket [[1]]

  • Vector:

    • Same data type

    • c() vs np.array(Not just 1d), pd.series

  • Indexing with row,column and logical vectors

    • Python starts at 0!
  • Matrices

    • “gathering of vectors” - same type, 2D

    • name the columns and row in R, not really in Python (can be done with another object in some other packages)

  • Dataframe

    • Like a table (what you see in excel): row, columns…

    • Commonly used functions: head(), tail(), summary(), dim(), nrow()… There are equivalents in pandas/numpy

      • Many more ways to manipulate data
    • Create a dataframe and read in data as a dataframe

Next Time

We will get to know the essentials of programming/ creating your own function

Please read:

Control Structures

Homework4

  • Download and save Homework4 raw content

    • Click the link

    • Copy the raw content

    • Save to a Quarto file under Source mode

    • Name the file as 04-Lastname-Firstname.qmd

    • Submit in .qmd file

Homework 4

  • Follow instructions to decode a secrete message

  • Take advantage of Google/Stack overflow… if errors are raised

  • No error raised doesn’t mean it’s correct, print the variable to make sure it is what you are looking for

  • Checkpoints make sure you are on the right track

  • Use functions/indexing techniques to do checkpoints