Time may have escaped you amidst your sudden change in position and hustle in preparing R. Conveniently, R provides us with a simple command to retrieve the current date and time:
> #use the date() command to get the current date and time
date()
command and press the Return key:> date()
date()
command, a message similar to [1] "Sun Aug 31 08:00:00 234
" will appear in the R console. In this case, the message indicates that it is 8:00 AM on Sunday, August 31 in the year 234.Congratulations, you have successfully issued your first R command (and reminded yourself of the current date and time in the process).
As you may have noticed, R commands, or functions, take on a similar form as in other programming languages. In the date()
command, for example, the word date
specifies the name of the function, while the parentheses ()
contain the function's arguments. In this case, it was not necessary to use any arguments in the date()
command. However, other functions, such as setwd(dir)
receive one or more arguments.