Ich habe einen DTL-Tabelle und eine Lookup-Tabelle (GLMap)Fehler anwenden Funktion
DTL:
DEAL_TYPE DN_DIRECTION key COMPANY_CODE GLAccount
POWER SALE 1 AFFL_CO 1702
POWER PURCHASE 2 AFFL_CO 3702
MISC SALE 3 AFFL_CO 5717
MISC PURCHASE 4 AFFL_CO 5718
POWER SALE 5 AFFL_CO 1702
POWER SALE 6 MAIN
POWER PURCHASE 7 MAIN
MISC SALE 8 MAIN
MISC PURCHASE 9 MAIN
POWER SALE 10 MAIN
Lookup-Tabelle (GLAcctMap):
DealType DR_CR GLAccount Customer
POWER P 3702 AFFL_CO
POWER S 1702 AFFL_CO
MISC P 5718 AFFL_CO
MISC S 5717 AFFL_CO
POWER P 6702 STD
POWER S 6712 STD
MISC P 5312 STD
MISC S 5313 STD
Erwartete Ausgabe: DEAL_TYPE DN_DIRECTION Taste COMPANY_CODE GLAccount GLACCT POWER S 1 AFFL_CO 1702 1702 LEISTUNG P 2 AFFL_CO 3702 3702 MISC S 3 AF FL_CO 5717 5717 MISC P 4 AFFL_CO 5718 5718 Leistung S 5 AFFL_CO 1702 1702 Leistung S 6 MAIN 6712 Leistung P 7 MAIN 6702 MISC S 8 MAIN 5313 MISC P 9 MAIN 5312 Leistung S 10 MAIN 6712
Ich möchte eine Ausgabe-Tabelle erstellen, die eine Kopie der dtl-Tabelle ist, aber mit einer zusätzlichen GLACCT-Spalte, die basierend auf einer Übereinstimmung mehrerer Spalten aus der Nachschlagetabelle hinzugefügt wurde.
Logik ist: Wenn GLAccount Spalte ist Null dann gehen Sie holen Sie sich das passende Konto aus der Nachschlagetabelle (GLacctMap), sonst legen Sie die GLAccount Nummer in der neuen Spalte.
Hier ist eine Funktion, die ich versucht:
load_details <- function(dld) {
phys_fin = 0
findgl <- function(x){
if(is.na(x$GLAccount) ) {
GLACCT <- GLacctMap[ match(paste(x$DEAL_TYPE, x$DN_DIRECTION, sep=":"),
paste(GLacctMap$DealType,GLacctMap$DR_CR,sep=":")), "GLAccount"]
} else {
GLACCT <- x$GLAccount
}
GLACCT
}
dld $ GLACCT < - gelten (currdld, 1, Funktion (x) findgl)
}
PEDLD < - lade_details (currld)
bekomme ich folgende Fehler: IBCO Spotfire Statistics Dienstleistungen hat einen Fehler zurückgegeben: ‚Fehler in as.data.frame.default (passed.args [[i]], stringsAsFactors = s: kann nicht Klasse ' " Funktion coerce " ' in ein data.frame '.
Wenn Sie nicht terr in Spotfire verwenden können Sie das Tag entfernen? Prost. – scsimon
Ich renne dies mit Terr in Spotfire. – Gerald