How to write a function for the following script in R
The above code is working fine in R studio but seems to be like command line but i need to write a class with functions and objects like we do in java,c++ etc
> data1 <- read.csv("AllMetals.csv")
> sb <- subset(melt(data1, varnames = c("Gold", "Silver", "Bronze"), id.vars = 1:6, value.name = "Count", variable.name = "Metal"), Count > 0)
> write.xlsx(sb, "E:/Alteryxdataout.xlsx")