Menu

Functions, Data Import, and Packages in R

Functions, Data Import, and Packages

Creating and Using Functions

A function packs steps into one named tool so you can reuse it. You write one with the word function, a list of inputs, and the steps inside curly brackets.

This example turns an average mark into a grade.

Importing and Exporting Data

Real data usually lives in files. To read a CSV file into a data frame, use read.csv(). To save a data frame, use write.csv().

Keep your files in the data and output folders so your paths stay simple. Check your working folder first with getwd(), so R looks for files in the right place.

Installing and Using R Packages

A package is a bundle of ready-made functions. You install it once with install.packages() and load it in every new session with library().

In this guide, you will use dplyr, ggplot2, and a few others.

install.packages("dplyr")   # Run once

library(dplyr)              # Run in every new session


R for Data Science

HA

Harini A



Learn via Video Course

Data Analysis and Processing with Python using Pandas - Data Science Course Logo

Data Analysis and Processing with Python using Pandas - Data Science Course

5 hrs



Get in Touch For Details