rexcelexport-to-excel

R: How can you freeze the top row in an exported Excel file using R code?


Solution must be in R. Related questions are providing solution for other languages. (e.g., here freeze top row using spreadsheetgear)

An Excel counterpart of

library(tidyverse)
mtcars %>% write_csv('IneedExcelNotCSV.csv')

with some part of code that freezez the top row.

Solution for similar format to .xls(x) (e.g., OpenOffice) would work too. (.sxc?)


Solution

  • If you use the XLSX R package to save as .xlsx file you can add

     createFreezePane(sheet, 2, 1, startRow = 2, startColumn = 1)
    

    and the first row is frozen.