df <- data.frame(
name = c("UCLA", "Berkeley", "Jeroen"),
founded = c(1919, 1868, 2030),
website = xl_hyperlink(c("http://www.ucla.edu", "http://www.berkeley.edu", NA), "homepage")
)
df$age <- xl_formula('=(YEAR(TODAY()) - INDIRECT("B" & ROW()))')
write_xlsx(df, 'universities.xlsx')
# cleanup
unlink('universities.xlsx')
Run the code above in your browser using DataLab