Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QueryR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien Lopez
QueryR
Commits
85a25ab1
Commit
85a25ab1
authored
10 years ago
by
Mick Jordan
Browse files
Options
Downloads
Patches
Plain Diff
fix WriteTable for RFactor
parent
dc92e90d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/utils/WriteTable.java
+6
-13
6 additions, 13 deletions
.../com/oracle/truffle/r/nodes/builtin/utils/WriteTable.java
with
6 additions
and
13 deletions
com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/utils/WriteTable.java
+
6
−
13
View file @
85a25ab1
...
...
@@ -34,7 +34,7 @@ public class WriteTable {
/* handle factors internally, check integrity */
RStringVector
[]
levels
=
new
RStringVector
[
nc
];
for
(
int
j
=
0
;
j
<
nc
;
j
++)
{
RAbstract
Vecto
r
xj
=
(
RAbstract
Vecto
r
)
x
.
getDataAtAsObject
(
j
);
RAbstract
Containe
r
xj
=
(
RAbstract
Containe
r
)
x
.
getDataAtAsObject
(
j
);
if
(
xj
.
getLength
()
!=
nr
)
{
throw
new
IllegalArgumentException
(
"corrupt data frame -- length of column "
+
(
j
+
1
)
+
" does not not match nrows"
);
}
...
...
@@ -51,23 +51,16 @@ public class WriteTable {
os
.
write
(
csep
.
getBytes
());
}
for
(
int
j
=
0
;
j
<
nc
;
j
++)
{
RAbstract
Vecto
r
xj
=
(
RAbstract
Vecto
r
)
x
.
getDataAtAsObject
(
j
);
RAbstract
Containe
r
xj
=
(
RAbstract
Containe
r
)
x
.
getDataAtAsObject
(
j
);
if
(
j
>
0
)
os
.
write
(
csep
.
getBytes
());
if
(
isna
(
xj
,
i
))
{
tmp
=
cna
;
}
else
{
if
(
levels
[
j
]
!=
null
)
{
/*
* We do not assume factors have integer levels, although they should.
*/
if
(
xj
instanceof
RIntVector
||
xj
instanceof
RDoubleVector
)
{
tmp
=
encodeElement2
(
levels
[
j
],
(
int
)
xj
.
getDataAtAsObject
(
i
)
-
1
,
quoteCol
[
j
],
qmethod
,
cdec
);
}
else
{
throw
new
IllegalArgumentException
(
"column "
+
(
j
+
1
)
+
" claims to be a factor but does not have numeric codes"
);
}
tmp
=
encodeElement2
(
levels
[
j
],
(
int
)
xj
.
getDataAtAsObject
(
i
)
-
1
,
quoteCol
[
j
],
qmethod
,
cdec
);
}
else
{
tmp
=
encodeElement2
(
xj
,
i
,
quoteCol
[
j
],
qmethod
,
cdec
);
tmp
=
encodeElement2
(
(
RAbstractVector
)
xj
,
i
,
quoteCol
[
j
],
qmethod
,
cdec
);
}
/* if(cdec) change_dec(tmp, cdec, TYPEOF(xj)); */
}
...
...
@@ -138,7 +131,7 @@ public class WriteTable {
return
encodeElement
(
x
,
indx
,
quote
?
'"'
:
0
,
cdec
);
}
private
static
boolean
isna
(
RAbstract
Vecto
r
x
,
int
indx
)
{
private
static
boolean
isna
(
RAbstract
Containe
r
x
,
int
indx
)
{
if
(
x
instanceof
RLogicalVector
)
{
return
RRuntime
.
isNA
(((
RLogicalVector
)
x
).
getDataAt
(
indx
));
}
else
if
(
x
instanceof
RDoubleVector
)
{
...
...
@@ -161,7 +154,7 @@ public class WriteTable {
throw
RInternalError
.
unimplemented
();
}
private
static
boolean
isFactor
(
RAbstract
Vecto
r
v
)
{
private
static
boolean
isFactor
(
RAbstract
Containe
r
v
)
{
for
(
int
i
=
0
;
i
<
v
.
getClassHierarchy
().
getLength
();
i
++)
{
if
(
v
.
getClassHierarchy
().
getDataAt
(
i
).
equals
(
"factor"
))
{
return
true
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment