Using dplyr commands with DataFrame objects
1
0
Entering edit mode
GE • 0
@gilad-24259
Last seen 6 months ago
United States

Hi, Is there a way to use dplyr commands on S4Vectors DataFrame objects? df <- df %>% mutate(a=str_replace(b,"hello","world"))

gives an error: Error in UseMethod("mutate") : no applicable method for 'mutate' applied to an object of class "c('DFrame', 'DataFrame', 'RectangularData', 'SimpleList', 'DataFrame_OR_NULL', 'List', 'Vector', 'list_OR_List', 'Annotated', 'vector_OR_Vector')"

S4Vectors • 543 views
ADD COMMENT
0
Entering edit mode
ATpoint ★ 4.0k
@atpoint-13662
Last seen 1 day ago
Germany
DataFrame(...) %>% data.frame %>% dplyr::anyFunction(...)

You have to convert to a base R data.frame first

ADD COMMENT
0
Entering edit mode

That won't work because my DataFrame object has columns that are only compatible with DataFrame and not with data.frame. So they will lose their 'class' type when converting to data.frame.

Is there any way to use dplyr commands on those columns that are compatible with data.frame, without losing the 'class' type of the columns that are not compatible with data.frame?

ADD REPLY

Login before adding your answer.

Traffic: 464 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6