mardi 21 mai 2019

How can I switch values between columns for specific rows?

I was building my data set for some accounting work and accidentally made a mistake. I'd like to switch every instance of a Credit (column journalItemLine_creditAmount) in the account 3605 to a Debit (column journalItemLine_debitAmount) and every instance of a Debit to a Credit.

data<-read.csv(file.choose(),head=TRUE)  
fixed_data<-if(data$journalItemLine_account="3605"){journalItemLine_debitAmount==journalItemLine_creditAmount}
fixed_data<-if(data$journalItemLine_account="3605"){journalItemLine_creditAmount==journalItemLine_debitAmount}

Here's the error I'm getting. Error: unexpected '=' in " fixed_data<-if(data$journalItemLine_account="

Aucun commentaire:

Enregistrer un commentaire