Coding basics

Author

Jeffrey R. Stevens

Published

January 27, 2023

Let’s go to R’s console, which is the direct connection to the R engine. In the console, you give R a command, and it returns the output.

Assignment

Remember our text string with our names?

"My name is Jeff!"

It is repetitive to have to copy/paste text. We can assign things to objects, which store the contents in a variable. The assignment operator <- assigns the value of the right hand side to the object on the left hand side. Use the <- operator to assign the name text to an object called my_name.

# >

Now print the contents of my_name by just typing it into the console.

# >

Now apply the toupper() function to my_name rather than the actual character string.

# >

How do we find out all of the arguments for the toupper() function?

Let’s specify the argument names not just the value.

# >

Press the up arrow to navigate to the assignment command and change the object name to something different.

Names

Why did I assign the text to the object my_name and not, for example, names?

What all is wrong with the file name Qualtrics experiment 3 ~ 01/05/22 [final_FINAL].xlsx?

What would be a better name for this file?

Why is this date problematic? 01/05/22

What would be an ISO 8601 format for this date?

Why is it useful to include dates in files names?