Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Virgile Baudrot
fdf
Commits
463dce46
Commit
463dce46
authored
Oct 29, 2019
by
Virgile Baudrot
Browse files
improve melt by keeping factors
parent
fd2b49f1
Pipeline
#788
passed with stage
in 5 minutes and 31 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
R/melt.R
View file @
463dce46
...
@@ -114,8 +114,14 @@ fd_melt <- function(x, key, id = NULL, keep = NULL){
...
@@ -114,8 +114,14 @@ fd_melt <- function(x, key, id = NULL, keep = NULL){
#' @export
#' @export
#'
#'
fd_melt_STICK
=
function
(
x
,
key1
,
keep
){
fd_melt_STICK
=
function
(
x
,
key1
,
keep
){
if
(
is.factor
(
x
[[
keep
]])){
vec
=
factor
(
do.call
(
"c"
,
lapply
(
1
:
nrow
(
x
),
function
(
i
){
as.character
(
rep
(
x
[[
keep
]][
i
],
length
(
x
[[
key1
]][[
i
]])))})),
levels
=
levels
(
x
[[
keep
]]))
}
else
{
vec
=
do.call
(
"c"
,
lapply
(
1
:
nrow
(
x
),
vec
=
do.call
(
"c"
,
lapply
(
1
:
nrow
(
x
),
function
(
i
){
rep
(
x
[[
keep
]][
i
],
length
(
x
[[
key1
]][[
i
]]))}))
function
(
i
){
rep
(
x
[[
keep
]][
i
],
length
(
x
[[
key1
]][[
i
]]))}))
}
return
(
vec
)
return
(
vec
)
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment