- Home
- Interview Questions
- R Programming
POSIXct classes must be used. Dates don’t store the time information, and POS IXlt dates store their data as lists, which won’t fit inside a data frame.
Midnight at the start of January 1, 1970.
"%B %Y"
Add 3,600 seconds to it. For example:
x <- Sys.time()
x + 3600
## [1] "2013-07-17 22:44:55 BST"
The period will be longer, because 2016 is a leap year. A duration is always exactly 60 * 60 * 24 * 365 seconds. A period of one year will be 366 days in a leap year.
Call the data function with no arguments.
read.csv assumes that a decimal place is represented by a full stop (period) and that each item is separated by a comma, whereas read.csv2 assumes that a decimal place is represented by a comma and that each item is separated by a semicolon. read.csv is used for data created in locales where a period is used as a decimal place (most English-speaking locales, for example). read.csv2 is for data created in locales where a comma is used (most European locales, for example). If you are unsure, simply open your data file in a text editor.
read.xlsx2 from the xlsx package is a good first choice, but there is also read.xlsx in the same package, and different functions in several other packages.
You can simply pass the URL to read.csv, or use download.file to get a local copy.
Currently SQLite, MySQL, PostgreSQL, and Oracle databases are supported.