2024-02-21
import()
Pythonlibrary()
RFUN(args)
Write code and debugging
import a library, call functions, data conversion, indexing
Observe from visualizing, printing and reading
Same function doesn’t work equivalently on different data structures length
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
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
Create a dataframe and read in data as a dataframe
We will get to know the essentials of programming/ creating your own function
Please read:
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
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