我基本上是.net开发人员我的项目页面之一需要来自MongoDB集合的数据。但是我需要比较每个列的值,所以我使用了R语言。我从MongoDB检索了数据,但有些列有变量列表,所以我无法比较每列。你能帮我分一下列列的值,并添加一个列表变量同名的新列吗?
如果可以使用任何算法来解决意味着它更可取。
我的示例数据框(数据集)
ID UserDetails CompanyDetails
1 list(UserID = 247891,Useraltr="Admin",UsercumEmpdetaisl=list(list(FirstName="Jack",LastName="De"))) list(ComyAddress="4/8 9 Block UD",ComyReg="344/88 7 Cross UK")
2 list(UserID=c(247891,256134),Useraltr=c("Admin","SuperAdmin"),UsercumEmpdetaisl=list(list(FirstName=c("peter","jhon","Vector"),LastName =c("Anderson","VJ","PK")))) list(ComyAddress =c("1BLOCK","2BLOCK"),ComyReg=c("1MainRoad","3street"),LandMark =c("Near post Office","check post"))
结果数据框
ID UserID Useraltr FirstName LastName ComyAddress ComyReg LandMark
1 247891 Admin Jack De 4/8 9 Block UD 344/88 7 Cross UK Empty(NULL)
2 247891,256134 Admin,SuperAdmin peter,jhon,Vector Anderson,VJ,PK 1BLOCK,2BLOCK 1MainRoad,3street Near post Office,check post
前两行的数据帧输入数据。
structure(list(ID = c("1", "2"), UserDetails = list(structure(list(
UserID = 247891, Useraltr = 'Admin', UsercumEmpdetaisl = list(structure(list(
FirstName = "Jack", LastName ="De" ), .Names = c("FirstName", "LastName"
), class = "data.frame", row.names = 1L))), .Names = c("UserID",
"Useraltr", "UsercumEmpdetaisl"), class = "data.frame", row.names = 1L),
structure(list(UserID = c(247891,256134), Useraltr = c('Admin','SuperAdmin'), UsercumEmpdetaisl = list(
structure(list(FirstName = c("peter", "jhon", "Vector"), LastName = c("Anderson",
"VJ","PK")), .Names = c("FirstName", "LastName"), class = "data.frame", row.names = 1L))), .Names = c("UserID",
"Useraltr", "UsercumEmpdetaisl"), class = "data.frame", row.names = 1L)),
CompanyDetails = list(structure(list(ComyAddress = "4/8 9 Block UD"
, ComyReg = "344/88 7 Cross UK"), .Names = c("ComyAddress", "ComyReg"
), class = "data.frame", row.names = 1:2), structure(list(
ComyAddress = c("1BLOCK","2BLOCK"), ComyReg = c("1MainRoad","3 street"
),LandMark=c("Near post Office","check post")), .Names = c("ComyAddress", "ComyReg","LandMark"), class = "data.frame", row.names = 1:2))), .Names = c("ID",
"UserDetails", "CompanyDetails"), row.names = 1:2, class = "data.frame")