Skip to content

Commit 41c86d6

Browse files
committed
R essential for modeler 18.0
1 parent 27c16e2 commit 41c86d6

22 files changed

+105
-147
lines changed

src/DESCRIPTION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
Package: ibmspsscf82
1+
Package: ibmspsscf83
22
Type: Package
33
Title: IBM SPSS CF R Plugin
4-
Version: 8.2.0.0
4+
Version: 8.3.0.0
55
Author: IBM
6-
Maintainer: <***@cn.ibm.com>
6+
Maintainer: <zhxiaoli@cn.ibm.com>
77
Description: An interface to embeded R in IBM SPSS CF based application
88
License: GPL-2

src/NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
useDynLib(ibmspsscf82)
1+
useDynLib(ibmspsscf83)
22

33
export(
44
ibmspsscfpkg.preaction,

src/R/action.R

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ ibmspsscfpkg.preaction <- function()
3232

3333
outputPath <- ibmspsscfoutput.GetOutputDir()
3434
##set the temp workspace, put the console result and graphs in this dir
35+
ibmspsscfpkg.oldwd <<- getwd()
3536
setwd(outputPath)
3637

3738

@@ -55,12 +56,9 @@ ibmspsscfpkg.preaction <- function()
5556

5657
##Sys.setlocale("LC_ALL","ja_JP.utf8")
5758
## set the locale of embedding R in Linux
58-
if ("windows" != .Platform$OS.type)
59-
{
60-
out <- .C("ext_GetSystemLocale", as.character(""),as.integer(0),PACKAGE=ibmspsscf_package)
61-
Sys.setlocale("LC_ALL",out[[1]])
62-
}
63-
59+
out <- .C("ext_GetSystemLocale", as.character(""),as.integer(0),PACKAGE=ibmspsscf_package)
60+
Sys.setlocale("LC_ALL",out[[1]])
61+
6462
out <- .C("ext_IsDisplayTextOutput",as.integer(0),as.integer(0),PACKAGE=ibmspsscf_package)
6563
last.SpssCfError <<- out[[2]]
6664
if(last.SpssCfError != 0)
@@ -140,5 +138,6 @@ ibmspsscfpkg.postaction <- function()
140138

141139
ibmspsscfpkg.stopprocedure <- function()
142140
{
141+
setwd(ibmspsscfpkg.oldwd)
143142
.C("ext_StopProcedure",as.integer(0),PACKAGE=ibmspsscf_package)
144143
}

src/R/attach.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ibmspsscf_package <- NULL
2323
ibmspsscf_version <- NULL
2424
plugin_version <- NULL
2525
ibmspsscf.lib <- NULL
26-
ibmspsscfNamespace <- "ibmspsscf82"
26+
ibmspsscfNamespace <- "ibmspsscf83"
2727
last.SpssCfError <- 0
2828
## when the package is attached(via library), the hook function .onAttach is called
2929
## before the package environment is sealed

src/R/data.R

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ ibmspsscfdata.GetData <- function(fields=NULL,
8383
PACKAGE=ibmspsscf_package)
8484

8585
n <- length(out)
86-
last.SpssCfError <- out[[n]]
86+
last.SpssCfError <<- out[[n]]
8787
if(last.SpssCfError !=0)
8888
{
8989
processSpssCFError(last.SpssCfError)
@@ -192,6 +192,13 @@ ibmspsscfdata.GetData <- function(fields=NULL,
192192
{
193193
## flagValues[1] is true value, flagValues[2] is false value
194194
flagValues <- ibmspsscfdatamodel.GetFlagValues(i)
195+
if(length(flagValues) == 0)
196+
{
197+
last.SpssCfError <<- 1022
198+
.Call("ext_SendErrorCode",as.integer(last.SpssCfError), as.integer(3), as.list(fieldNames[[j]]), as.integer(err),PACKAGE=ibmspsscf_package)
199+
stop(printSpssError(last.SpssCfError),call. = FALSE, domain = NA)
200+
}
201+
195202
for(index in 1:length(result[[j]]))
196203
{
197204
if(!is.na(result[[j]][index])) {
@@ -275,13 +282,14 @@ ibmspsscfdata.GetDataFromTemp <- function(missingValue = NA,
275282
colClassesVec <- c(colClassesVec, "numeric")
276283
}
277284
}
278-
dataFromTempFile <- read.table(dataFileName, header=TRUE, sep=" ",colClasses=colClassesVec, encoding="UTF-8")
285+
dataFromTempFile <- read.table(dataFileName, header=TRUE, sep=" ",colClasses=colClassesVec,fileEncoding="UTF-8")
279286
unlink(dataFileName)
280287

281288

282289
## 2. Convert flag fields
283290
## process converting flag fields to logical fields
284291
fieldMeasure <- modelerDataModel[4,]
292+
fieldNames <- modelerDataModel[1,]
285293
fieldCount <- ibmspsscfdatamodel.GetFieldCount()
286294
fields <- 0:(fieldCount-1)
287295
if(logicalFields == TRUE)
@@ -293,6 +301,13 @@ ibmspsscfdata.GetDataFromTemp <- function(missingValue = NA,
293301
{
294302
## flagValues[1] is true value, flagValues[2] is false value
295303
flagValues <- ibmspsscfdatamodel.GetFlagValues(i)
304+
if(length(flagValues) == 0)
305+
{
306+
last.SpssCfError <<- 1022
307+
.Call("ext_SendErrorCode",as.integer(last.SpssCfError), as.integer(3), as.list(fieldNames[[j]]), as.integer(0),PACKAGE=ibmspsscf_package)
308+
stop(printSpssError(last.SpssCfError),call. = FALSE, domain = NA)
309+
}
310+
296311
## need to convert character firstly, factor will have value check
297312
dataFromTempFile[[j]] <- as.character(dataFromTempFile[[j]])
298313
for(index in 1:length(dataFromTempFile[[j]]))
@@ -353,6 +368,16 @@ ibmspsscfdata.GetDataFromTemp <- function(missingValue = NA,
353368
j<-1
354369
for(i in fields)
355370
{
371+
# only convert storage is not string, string has been converted in read.table
372+
if("string" != fieldStorages[[j]] && ("nominal" == fieldMeasure[[j]]
373+
|| "discrete" == fieldMeasure[[j]]))
374+
{
375+
if(factorMode == "levels")
376+
{
377+
dataFromTempFile[[j]] <- factor(dataFromTempFile[[j]], ordered=FALSE)
378+
}
379+
}
380+
356381
if("ordinal" == fieldMeasure[[j]])
357382
{
358383
valueLabels <- ibmspsscfdatamodel.GetValueLabels(i)

src/R/datamodel.R

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,7 @@ ibmspsscfdatamodel.SetDataModel <- function(dataModel)
326326

327327
##check the storage
328328
if(dataModel[3, i] == "string" || dataModel[3, i] == "integer" || dataModel[3, i] == "real"
329-
|| dataModel[3, i] == "date" || dataModel[3, i] == "time" || dataModel[3, i] == "timestamp"
330-
|| dataModel[3, i] == "unknown")
329+
|| dataModel[3, i] == "date" || dataModel[3, i] == "time" || dataModel[3, i] == "timestamp")
331330
{}
332331
else
333332
{
@@ -358,6 +357,23 @@ ibmspsscfdatamodel.SetDataModel <- function(dataModel)
358357
}
359358
fieldMeasure <- c(fieldMeasure, as.character(dataModel[4, i]))
360359
fieldFormat <- c(fieldFormat, as.character(dataModel[5, i]))
360+
361+
##check the role
362+
dataModelRole <- dataModel[6, i]
363+
if(dataModelRole =="" || dataModelRole == "input" ||dataModelRole == "target"
364+
|| dataModelRole == "both"|| dataModelRole == "partition" || dataModelRole == "split"
365+
|| dataModelRole == "freqWeight" || dataModelRole == "recordId" || dataModelRole == "none")
366+
{}
367+
else
368+
{
369+
last.SpssCfError <<- 1007
370+
if(is.SpssCfError(last.SpssCfError))
371+
{
372+
invalidRole <- as.character(dataModelRole)
373+
.Call("ext_SendErrorCode",as.integer(last.SpssCfError), as.integer(3), as.list(invalidRole), as.integer(err),PACKAGE=ibmspsscf_package)
374+
stop(printSpssError(last.SpssCfError),call. = FALSE, domain = NA)
375+
}
376+
}
361377
fieldRole <- c(fieldRole, as.character(dataModel[6, i]))
362378
}
363379

src/R/output.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ ibmspsscfoutput.SetHTMLWithAllGraphs <- function()
7676
temp1 <- paste("<p>", as.character(name))
7777
temp2 <- "<img src=\""
7878
temp3 <- name
79-
temp4 <- "\",width=\"500\" height=\"500\"></p>"
79+
temp4 <- "\"></p>"
8080
temp <- paste(temp1, temp2, temp3, temp4)
8181
htmlBegin <- paste(htmlBegin, temp)
8282
}

src/inst/lang/en/ibmspsscfr.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@
8282
[RError]_1006 = Invalid field format for SetDataModel.
8383
[RError]_1007 = Invalid field role for SetDataModel.
8484

85-
[RError]_1021 = Invalid field missing value.
85+
8686
##this is for GetDataModel or GetData
8787
[RError]_1020 = Invalid field name in argument.
88+
[RError]_1021 = Invalid field missing value.
89+
[RError]_1022 = Flag field does not have values.
8890

8991
## data
9092
[RError]_1008 = Invalid value for argument factorMode (must be "none", "levels" or "labels").

src/inst/lang/ibmspsscfr.properties

Lines changed: 0 additions & 108 deletions
This file was deleted.

src/inst/lang/ibmspsscfr_de.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@
8282
[RError]_1006 = Ung\u00fcltiges Feldformat f\u00fcr SetDataModel.
8383
[RError]_1007 = Ung\u00fcltige Feldrolle f\u00fcr SetDataModel.
8484

85-
[RError]_1021 = Ung\u00fcltiger Wert f\u00fcr fehlendes Feld.
85+
8686
##this is for GetDataModel or GetData
8787
[RError]_1020 = Ung\u00fcltiger Feldname in Argument.
88+
[RError]_1021 = Ung\u00fcltiger Wert f\u00fcr fehlendes Feld.
89+
[RError]_1022 = Flagfeld enth\u00e4lt keine Werte.
8890

8991
## data
9092
[RError]_1008 = Ung\u00fcltiger Wert f\u00fcr Argument factorMode (muss "none", "levels" oder "labels" sein).

0 commit comments

Comments
 (0)