Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

How to create columns from sub-list?

$
0
0

@premsheth wrote:

Hello,

I want to make different columns from sublist in R
Example:

head(data$product_category_tree)

output:

[1] "[\"Clothing >> Women's Clothing >> Lingerie, Sleep & Swimwear >> Shorts >> Alisha Shorts >> Alisha Solid Women's Cycling Shorts\"]"
[2] "[\"Furniture >> Living Room Furniture >> Sofa Beds & Futons >> FabHomeDecor Fabric Double Sofa Bed (Finish Colo...\"]"
[3] "[\"Footwear >> Women's Footwear >> Ballerinas >> AW Bellies\"]"

sam <- strsplit(data$product_category_tree,">>")
head(sam)

output

[[1]]
[1] "[\"Clothing "                            " Women's Clothing "
[3] " Lingerie, Sleep & Swimwear "            " Shorts "
[5] " Alisha Shorts "                         " Alisha Solid Women's Cycling Shorts\"]"

[[2]]
[1] "[\"Furniture "
[2] " Living Room Furniture "
[3] " Sofa Beds & Futons "
[4] " FabHomeDecor Fabric Double Sofa Bed (Finish Colo...\"]"

[[3]]
[1] "[\"Footwear "       " Women's Footwear " " Ballerinas "       " AW Bellies\"]"

Now I want to extract information as particular levels or make function so I will able to extract information at particular level.

can anyone please suggest me how to make For loops for it or make function ?

Thanks in Advance

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles