I am trying to sort the following data frame by the values in the period column.enter image description here
the code that I am using is as follows :
data = read.csv("inputSample.csv")
datasub = subset(data,data$Period<41 & data$Period>0)
write.csv(datasub,"period+.csv")
new = read.csv("period+.csv")
sub = subset(new,new$NumberOfClaims>0)
sub1 = subset(new,new$NumberOfClaims==0)
opr <- function(set)
{
return((set$LossAmt * set$SimulationCount)/set$NumberOfClaims)
}
operated = data.frame( sub$LoanID,opr(sub), sub$EndingBalance, sub$BalanceInClaims, sub$Period)
operated = operated[order("sub.Period")]
print(operated)
however the code above simply returns the values of the first column in the dataframe that too in an unsorted order. I have tried using with() and other ways but none of them seem to work. Please help me out. Thanks