Python for R Users
Daniel Chen
Instructor
Whitespace and indentation is a fundamental part of writing python code and is not optional
if (5 == 5) {
print('TRUE')
}
"TRUE"
if 5 == 5:
print('True')
True
val <- 2
if (val == 1) {
print('snap')
} else if (val == 2) {
print('crackle')
} else {
print('pop')
}
"crackle"
val = 2
if val == 1:
print('snap')
elif val == 2:
print('crackle')
else:
print('pop')
crackle
num_val <- c(1, 2, 3, 4)
for (value in seq_along(num_val)){
print(value)
}
num_val = [1, 2, 3, 4]
for value in num_val:
print(value)
Python for R Users