1
2 개의 열로 구성된 데이터 세트가 있습니다. "WEBDATA"열은 각 셀에 목록을 포함합니다. 이목록을 여러 행으로 분할합니다. R
내 데이터 세트는 다음과 같습니다 ... 제가 목록을 포함하고 내가 붙어 있어요 데이터 집합을 처리해야 처음이다 :
나는의 각 셀 내부의 내용을 확인 해요WORD | WEBDATA
Home | list(Domain = c(77, 25, 7, 97, 71, 1, 42, 35, 37, 58, 9
Baby | list(Domain = c(77, 25, 7, 97, 71, 1, 42, 35, 37, 58, 9
Dog | list(Domain = c(77, 25, 7, 97, 71, 1, 42, 35, 37, 58, 9
Food | list(Domain = c(77, 25, 7, 97, 71, 1, 42, 35, 37, 58, 9
WEBDATA 열, 그것은 나에게이 반환
class(dataset$WEBDATA)
[1] "list"
testdataset <- data.frame(dataset$WEBDATA[[2]])
Domain | Url
1 website1.com | https://www.website1.com/product2/
2 mysuperwebsite.com | https://www.mysuperwebsite.com/productB/
3 bestwebsite.uk | https://www.bestwebsite.uk/product67/
:
> dataset$WEBDATA[[1]]
Domain
1 website1.com
2 mysuperwebsite.com
3 bestwebsite.uk
Url
1 https://www.website1.com/product2/
2 https://www.mysuperwebsite.com/productB/
3 https://www.bestwebsite.uk/product67/
하는이 목록이었다 확실하게하고 모양을 확인하기 위해, 나는이 시도
제 목표는 WEBDATA 목록을 여러 행으로 나누는 것입니다. 나는 strsplit() 함수의 생각
WORD | Number | Domain | Url
Home | 1 | website1.com | https://www.website1.com/product2/
Home | 2 | mysuperwebsite.com | https://www.mysuperwebsite.com/productB/
Home | 3 | bestwebsite.uk | https://www.bestwebsite.uk/product67/
Baby | 1 | websitezz.uk | https://www.websitezz.uk/page/
Baby | 2 | websiteabc.com | https://www.websiteabc.com/post/
Baby | 3 | thewebsite.com | https://www.thewebsite.com/post75/
있지만 목록에 난 정말 그것을 만드는 방법을 알고하지 않습니다
마지막 세트는 다음과 같이한다. 좀 도와 줄 수있어? 여기
은 샘플 데이터 세트, 당신은 R에 붙여 넣을 수 있습니다 : @alistaire SAIS 코멘트에서와 마찬가지로
theDataReconstituted <- structure(list(
WORD = structure(c(8L, 7L, 6L, 10L, 9L), .Label = c("dog dood", "dog foo", "dog food uk", "dog foof", "dogfood", "burns dog food", "canagan dog food", "dog food", "skinners dog food", "wainwrights dog food"), class = "factor"),
WEBDATA = list(
structure(list(
Domain = structure(c(1L, 2L, 2L), .Label = c("pet-supermarket.co.uk", "petsathome.com"), class = "factor"),
Url = structure(c(3L, 1L, 2L), .Label = c("petsathome.com/shop/en/pets/dog/dog-food-and-treats", "petsathome.com/shop/en/pets/dog/dog-food-and-treats/dry-dog-food", "pet-supermarket.co.uk/Dog/Dog-Food-Treats/Dog-Food/c/PSGB00070"), class = "factor")),
.Names = c("Domain", "Url"), class = "data.frame", row.names = c(NA, -3L)),
structure(list(
Domain = structure(c(1L, 1L, 1L), .Label = "canagan.co.uk", class = "factor"),
Url = structure(c(1L, 3L, 2L), .Label = c("canagan.co.uk/", "canagan.co.uk/products-cat.html", "canagan.co.uk/products.html"), class = "factor")),
.Names = c("Domain", "Url"), class = "data.frame", row.names = c(NA, -3L)),
structure(list(
Domain = structure(c(1L, 1L, 2L), .Label = c("burnspet.co.uk", "petsathome.com"), class = "factor"),
Url = structure(1:3, .Label = c("burnspet.co.uk/", "burnspet.co.uk/burns-dog-food-products/", "petsathome.com/shop/en/pets/merch-groups/burns"), class = "factor")),
.Names = c("Domain", "Url"), class = "data.frame", row.names = c(NA, -3L)),
structure(list(
Domain = structure(c(1L, 1L, 1L), .Label = "petsathome.com", class = "factor"),
Url = structure(c(2L, 3L, 1L), .Label = c("petsathome.com/shop/en/pets/merch-groups/feature/wainwrights-dog-food", "petsathome.com/shop/en/pets/merch-groups/mg-004", "petsathome.com/shop/en/pets/merch-groups/wainwrights-dog-"), class = "factor")),
.Names = c("Domain", "Url"), class = "data.frame", row.names = c(NA, -3L)),
structure(list(
Domain = structure(c(1L, 1L, 1L), .Label = "skinnerspetfoods.co.uk", class = "factor"),
Url = structure(c(1L, 3L, 2L), .Label = c("skinnerspetfoods.co.uk/", "skinnerspetfoods.co.uk/our-range/", "skinnerspetfoods.co.uk/product-category/field-trial-range/"), class = "factor")),
.Names = c("Domain", "Url"), class = "data.frame", row.names = c(NA, -3L)))),
row.names = c(NA, -5L),
class = c("tbl_df", "tbl", "data.frame"),
.Names = c("WORD", "WEBDATA"))
데이터의 대표 샘플에서'dput'을 호출 한 결과로 편집 할 수 있습니까? 다른 사람이 정확한 상황을 재현하는 것이 실제로 불가능한 것처럼 중첩 된 목록 열이 있습니다. – alistaire
'Home'과'Website1.com' 등은 어떻게 관련이 있습니까? 해당 사이트가 '아기'와 관련된 두 번째 항목에 속한 것 같습니다. – MKR
Website1.com은 홈과 같은 행에있는 목록에 포함되어 있습니다. 그것을 알아 줘서 고마워, 위의 코드에서 실수가 있었는데, 나는 그것을 편집했다. – Remi