library(pacman) #p_load(colorout) options(width=200) df=read.csv('ebay.csv') df$Xt = df$Xq + df$Xp df$Zt = df$Zq + df$Zpe df$Zpf = ((df$Zt)*0.034)+0.2 df$Zef = df$Zt*0.1 df$Q = round((df$Zt)-(df$Zef)-(df$Zpf)-(df$Zpa)-(df$Xt),digits=2) df$cost = df$Xt + df$Zpf + df$Zef + df$Zpa df$profit = ((df$Zt / df$cost)-1)*100 #round(df$profit,digits=1) #round(df$cost,digits=1) #round(sum(df$Xt,na.rm=TRUE),digits=2) #sum(df$Q,na.rm=TRUE) #df2=df[order(df$profit, decreasing = TRUE), ] #df3=df2[,c("desc","Zt","cost","profit")] print(sum(df$Zt)) print(sum(df$cost)) print(round((sum(df$Zt))/(sum(df$cost)),digits=2))