Advertisement
obernardovieira

(Excel xlsx Multiple Columns) Write,Read,Change,Write

Jan 8th, 2015
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.39 KB | None | 0 0
  1. require(gdata)
  2. require(xlsx)
  3.  
  4. n = c(2, 3, 5)
  5. s = c("aa", "bb", "cc")
  6. b = c(TRUE, FALSE, TRUE)
  7. df = data.frame(n, s, b)       # df is a data frame
  8.  
  9. write.xlsx(df, "file3.xlsx")
  10.  
  11.  
  12.  
  13. #read file and make changes
  14.  
  15. mydata = read.xls("file3.xlsx")
  16. mydata[2,2] <- mydata[2,2]+1 #in column n (with 2, 3, 5 as values) we will increase the value of 3
  17. write.xlsx(df, "file3.xlsx", row.names=FALSE)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement