0

I was wondering, what is memory and speed comparison between rowwise with do and transmute function in dplyr

I have list in data frame column, I want to know which one better. Currently, due to my limited knowlege, I am using rowwise with do to collect information from list,

I have three column.

First column is unique id for each row. Second column is JSON response third column is list extracted from JSON response from following code

vectorize_fromJSON <- Vectorize(fromJSON)
z <- vectorize_fromJSON(x)

Example of JSON response

x is extracted from data frame

x =
c('{"company_name": "a", "employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]}', 
'{"company_name": "a", "employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]}')

Currently, I extract company_name from JSON response as follows:

data_df$json_list <- z

data_df %>% rowwise %>% do(company_name = .$json_list$company_name)

I am not able to use transmute or mutate to get company name from list.

Main question, How efficient rowwise is compare to transmute ?

Kush Patel
  • 3,685
  • 5
  • 42
  • 65
  • 2
    test speed with microbenchmark package – Richard Telford Apr 19 '16 at 20:05
  • I am not able to use transmute function, therefore, I am not able to compare speed between transmute and rowwise with do. I am asking question, to know if I have to find other ways to use transmute if it is more efficient – Kush Patel Apr 19 '16 at 20:08
  • 1
    Generally, rowwise has been slow in other benchmarks. For example: http://stackoverflow.com/a/33807003/ or http://stackoverflow.com/a/29885054/ or http://stackoverflow.com/a/28910780/ or http://stackoverflow.com/a/29536286/ – Frank Apr 19 '16 at 20:17

0 Answers0