Skip to content

rowwise fails to process factors #886

@holgerbrandl

Description

@holgerbrandl

Until now I was under the impression that I could use mutate with rowwise. However the following example seems to indicate otherwise:

data.frame(processed=c("foo", "bar")) %>% 
rowwise() %>% 
mutate(processed_trafo=paste("test", processed))

which results into

  processed processed_trafo
1       foo          test 2
2       bar          test 1

It seems that dplyr is not able to pick up the factor levels.

The example illustrates just the point but does not actually rely on the row-wise grouping. However imagine, the levels are filenames and you want to do something like

file_checksum=(system(paste("md5sum", processed), intern=T) %>% str_split_fixed(" ", 2))[1]

in mutate.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions