R basename() Function

R basename() Function

The basename() is a base R function that extracts the last component (or the ‘base name’) of a file or directory path and returns the name of the file or directory. So, if you have a path like “/Users/krunallathiya/Desktop/Code/pypro/data.pdf,“ basename() would return “data.pdf.“ The opposite function of basename() is dirname(), which gives the directory part of the path. Syntax basename(path) … Read more

How to Transpose Data Frame in R

Transposing Data Frame in R

Transposing means switching rows to columns and columns to rows. It is a common operation in the matrix. However, data frames are a bit different because they can have different data types in different columns, whereas the matrix has the same type for each column. So, transposing a data frame is different from transposing a matrix. … Read more

How to Remove NA From Vector in R

Removing NA values from Vector in R

A vector is a data structure that holds the same type of data. When working with real-time data, it may contain missing data, and it can be represented by NA (not available). For a proper data analysis, we need to exclude NA values from the vector. Now, you may have one question in your mind. … Read more

How to Read Excel Files in R [3 Ways]

Featured Image of Reading Excel Files in R

No matter how much technology has improved over the years for storing and sharing data, one format is still widely used in the industry: Excelsheet, which has file extensions like “.xls” or “.xlsx.“ Here are three ways to import Excel files in R: Using the readxl package (Efficient way) Using xlsx package RStudio’s Import Dataset tool For this tutorial’s … Read more