Account T operation Value
o1 Cash Debit 100000
o2 Paid in Capital Credit 10000
o3 PP&E Debit 10000
o4 Cash Credit 10000
o5 Cash Debit 48000
o6 COGS Debit 24000
o7 Revenue wardrobes 1stY Credit 48000
o8 Inventory wardrobes 1stY Credit 24000
o9 Cash Debit 20000
o10 COGS Debit 10000
o11 Revenue bookcases 1stY Credit 20000
o12 Inventory bookcases 1stY Credit 10000
o13 Operating expenses Debit 30000
o14 Cash Credit 20000
o15 Accounts Payable Credit 10000
o16 Depreciation Expense Debit 1000
o17 Accumulated depreciation 1stY Credit 1000
但是我想用if和else对贷方和借方进行求和。我不会描述我的函数,因为可能会有很多错误,对于我的专家的兄弟们,我认为我可以得到大约三行代码。
答案 0 :(得分:0)
我不是我已经了解您想要什么,但我认为您想要这样做:
credits_indices <- as.character(data[["Credits"]]=="Credits" #indices to the credits
values <- values[["Value"]] #all the values
total <- sum(values) #total value
total_credits <- sum(values[credits_indices]) #total credits
total_debit <- total-total_credits # total debit
我希望这就是你想要的!如果是这样,请检查此内容以回答您的问题。