gdemin / excel.link

Convenient Data Exchange between R and Microsoft Excel
56 stars 16 forks source link

delete a range of data #9

Closed FelipeCarrillo closed 7 years ago

FelipeCarrillo commented 7 years ago

Hi; I am going through the excel.link pdf right now and have a question. I found a way to delete an existing excel sheet but can't find a way to delete a range of data within the spreadsheet. Say I want to delete old data from A1:C8 from the active sheet and then re-populate with most recent data. How can I accomplish that? Thanks for the great package by the way.

gdemin commented 7 years ago

Hi, Clearing range is rather simple (though not very obvious). Just fill range with NA's: xl[a1:c8] = NA

FelipeCarrillo commented 7 years ago

Thanks for the prompt reply. Unable to try it right now but if I don't want 'NA's and I only want to clear the cells, should this xl[a1:a8]="" would do it?

gdemin commented 7 years ago

In excel.link NA's by default are translated to empty cells in Excel. So range will be clear after xl[a1:c8] = NA. xl[a1:a8]="" also will do the job. Perhaps you may be interested in cr[a1] = NA - it will clear the current region (range that will be selected in Excel after pressing Ctrl+Shift+*).

FelipeCarrillo commented 7 years ago

That's great, thanks. cr[a1]=NA is what I was looking for so ranges can dynamically be deleted instead of hard-coding it.