Open In App

Read xlsb files in R

Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we are going to see how we can read XLSB files in the R programming language.

R is a programming language used for performing statistical computation and graphical purposes. It is an open-source programming language used as statistical software and data analysis tool. For data analysis and the creation of statistical software, R is used by statisticians, bioinformaticians, and data miners.

What is an XLSB file?

An XLSB file is an Excel binary worksheet file that was created by Microsoft. In contrast to the majority of other Excel files, they hold information in binary format. The fact that XLSB files are binary means that they can be read from and written much more quickly, which makes them incredibly helpful for large spreadsheets.

read_xlsb() method

We are going to use the read_xlsb() method to read xlsb files in R. It comes within the library readxlsb. To install the library type the following command in the R environment:

install.packages("readxlsb")

Syntax: read_xlsb(path, sheet = NULL, range = NULL, col_names = TRUE,  col_types = NULL, na = “”, trim_ws = TRUE, skip = 0, …)

Parameters:

  • path: The path of the file.
  • sheet: The name or the sheet’s index that should be read.
  • range: A named range or a string that represents an excel range
  • col_names: A boolean used to specify whether to use the first row as column name.
  • col_types: The type of the columns.
  • na: A single string or an array of strings to represent missing
  • trim_ws: A boolean to whether trim whitespaces
  • skip: The number of rows to skip.

Read xlsb files using the read_xlsb() method

In this example, firstly we are importing the readxlsb package and then storing the path of data.xlsb file in the “filePath” variable and then read that file using read_xlsb() method. 

R




# Importing required library
library(readxlsb)
  
# store file path in filePath
filePath<-"/home/aayussss2101/Desktop/geeksforgeeks/data.xlsb"
  
# Reading xlsb file
read_xlsb(filePath,range="data!A1:F5")


To run the file using the command:

Rscript file.R

Output:

 


Last Updated : 05 Feb, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads