XLConnect

# XLConnect is already available

# Build connection to urbanpop.xlsx

my_book <- loadWorkbook("urbanpop.xlsx")

# Import columns 3, 4, and 5 from second sheet in my_book: urbanpop_sel

urbanpop_sel <- readWorksheet(my_book, sheet = 2,startCol=3,endCol=5)

# Import first column from second sheet in my_book: countries

countries<-readWorksheet(my_book, sheet = 2,startCol=1,endCol=1)

# cbind() urbanpop_sel and countries together: selection

selection<-cbind(countries,urbanpop_sel)




# Load the XLConnect package

library(XLConnect)

# Build connection to renamed.xlsx: my_book

my_book<-loadWorkbook("renamed.xlsx")

# Remove the fourth sheet

removeSheet(my_book,"summary")

# Save workbook to "clean.xlsx"

saveWorkbook(my_book,"clean.xlsx")



# Build connection to urbanpop.xlsx

my_book <- loadWorkbook("urbanpop.xlsx")

# Add a worksheet to my_book, named "data_summary"

createSheet(my_book,name="data_summary")

# Use getSheets() on my_book

getSheets(my_book)

你可能感兴趣的:(XLConnect)