DAR lecture 8
DAR lecture 8
library(readxl)
data <- read_excel("file.xlsx")
data(package = "datasets")
Example: To load the famous iris dataset:
data(iris)
Explanation:
R provides many sample datasets in packages like datasets, which
are useful for learning.
4. Reading Data from Web/APIs
You can use the read.csv function to read data directly from a URL.
data <-
read.csv("https://people.sc.fsu.edu/~jburkardt/data/csv/airtravel.csv")
data<-read.csv("https://raw.githubusercontent.com/jbrownlee/Datasets/
master/iris.csv")
Example:
library(RODBC)
Explanation:
RODBC helps in connecting to different database systems
(like SQL Server) and running SQL queries.
MySQL and PostgreSQL
•
To work with these databases, we use the RMySQL or
RPostgreSQL packages.
library(RMySQL)
library(RPostgreSQL)
SQLite
SQLite databases are self-contained and easy to use with the RSQLite
package.
Command:
library(RSQLite)
Example:
Explanation:
MySQL, PostgreSQL, and SQLite are relational databases. You can run
SQL queries to retrieve data into R.
JasperDB and Pentaho
•
JasperDB and Pentaho are business intelligence tools that offer
reporting and analytics capabilities, typically connecting to
databases.