Json 是否可以使R数据帧列中的项目可索引?

Json 是否可以使R数据帧列中的项目可索引?,json,r,list,dataframe,Json,R,List,Dataframe,我正在尝试创建一个数据帧,其中包含可索引项 我的意思是 我目前有以下结构: X Y Z 1 2 3 我想要一个 A c(1,2,3) 例如,我可以调用[1]来查看第二个值 到目前为止,我使用了以下方法: Change <- paste(SNPs$V4, SNPs$V5, sep=",") 也许你能明白我为什么简化了。。我有strsplitv10:V18,并选择了一些值,希望将它们连接到列中的列表中 由于结构不清楚,请使用dput

我正在尝试创建一个数据帧,其中包含可索引项

我的意思是

我目前有以下结构:

X     Y     Z  
1     2     3
我想要一个

A          
c(1,2,3)
例如,我可以调用[1]来查看第二个值

到目前为止,我使用了以下方法:

Change <- paste(SNPs$V4, SNPs$V5, sep=",")

也许你能明白我为什么简化了。。我有strsplitv10:V18,并选择了一些值,希望将它们连接到列中的列表中

由于结构不清楚,请使用dput显示输入数据。如果有三列和一行,请使用unlistyourdf。如果要转换为JSON格式,请选择libraryjsonlite;ToJSONYOURDF您可以使用您的数据子集更新帖子,即dputdLovelsHeadYourDataThank的结构。您有18列,您的预期输出是什么?你想只考虑V10:V18吗?你想要ActudiunListDF1[10:18]我不确定你想要什么,但是在投入大量工作之前看看JSONLITE的输出。如果我做jsonlite::toJSONdata.framex=c1,2,3,y=c4,5,6,我会得到[{x:1,y:4},{x:2,y:5},{x:3,y:6}],这些行放在一起,这就是我理解您想要的。
structure(list(V1 = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = "XXX", class = "factor"), 
    V2 = c(3579L, 3585L, 37378L, 37625L, 46230L, 46340L), V3 = structure(c(4L, 
    6L, 3L, 5L, 2L, 1L), .Label = c("k31_cl0_BC_var_1081", "k31_cl0_BC_var_199", 
    "k31_cl0_BC_var_780", "k31_cl0_BC_var_852", "k51_cl0_BC_var_329", 
    "k51_cl0_BC_var_348"), class = "factor"), V4 = structure(c(3L, 
    4L, 1L, 1L, 2L, 1L), .Label = c("A", "C", "CT", "TT"), class = "factor"), 
    V5 = structure(c(1L, 3L, 2L, 2L, 3L, 2L), .Label = c("C", 
    "G", "T"), class = "factor"), V6 = structure(c(1L, 1L, 1L, 
    1L, 1L, 1L), .Label = ".", class = "factor"), V7 = structure(c(1L, 
    1L, 1L, 1L, 1L, 1L), .Label = "PASS", class = "factor"), 
    V8 = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = ".", class = "factor"), 
    V9 = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = "GT:COV:GQ:SITE_CONF", class = "factor"), 
    V10 = structure(c(6L, 2L, 5L, 4L, 1L, 3L), .Label = c("0/0:143,0:777.06:529.76", 
    "0/0:161,0:852.81:582.37", "0/0:163,0:846.27:999.60", "0/0:166,0:911.35:958.58", 
    "0/0:179,0:951.30:1404.56", "0/0:200,0:940.27:716.92"), class = "factor"), 
    V11 = structure(c(2L, 1L, 5L, 3L, 6L, 4L), .Label = c("0/0:481,0:2692.68:582.37", 
    "0/0:630,0:3070.18:716.92", "0/0:665,0:3518.84:958.58", "0/0:691,0:3464.55:999.60", 
    "0/0:849,0:4096.86:1404.56", "1/1:0,581:3009.81:529.76"), class = "factor"), 
    V12 = structure(c(5L, 1L, 4L, 2L, 6L, 3L), .Label = c("0/0:277,0:1474.49:582.37", 
    "0/0:323,0:1723.17:958.58", "0/0:347,0:1744.05:999.60", "0/0:349,0:1748.06:1404.56", 
    "0/0:356,0:1696.13:716.92", "1/1:0,282:1459.25:529.76"), class = "factor"), 
    V13 = structure(c(2L, 1L, 6L, 4L, 5L, 3L), .Label = c("0/0:345,0:1870.48:582.37", 
    "0/0:404,0:1977.86:716.92", "0/0:439,0:2230.71:999.60", "0/0:467,0:2471.55:958.58", 
    "1/1:0,389:2014.25:529.76", "1/1:0,509:2504.55:1404.56"), class = "factor"), 
    V14 = structure(c(4L, 3L, 2L, 5L, 6L, 1L), .Label = c("0/0:316,0:1615.78:999.60", 
    "0/0:408,0:2010.02:1404.56", "1/1:0,170:1016.14:582.37", 
    "1/1:0,205:1122.81:716.92", "1/1:0,307:1704.23:958.58", "1/1:0,311:1619.98:529.76"
    ), class = "factor"), V15 = structure(c(4L, 2L, 5L, 3L, 6L, 
    1L), .Label = c("0/0:179,0:934.24:999.60", "0/0:190,0:997.43:582.37", 
    "0/0:209,0:1124.87:958.58", "0/0:227,0:1067.85:716.92", "0/0:236,0:1173.70:1404.56", 
    "1/1:0,182:951.02:529.76"), class = "factor"), V16 = structure(c(5L, 
    1L, 4L, 3L, 6L, 2L), .Label = c("0/0:256,0:1342.47:582.37", 
    "0/0:271,0:1334.45:999.60", "0/0:294,0:1572.75:958.58", "0/0:321,0:1565.49:1404.56", 
    "0/0:322,0:1490.25:716.92", "1/1:0,210:1112.15:529.76"), class = "factor"), 
    V17 = structure(c(5L, 2L, 4L, 3L, 6L, 1L), .Label = c("0/0:162,0:827.57:999.60", 
    "0/0:171,0:887.59:582.37", "0/0:175,0:941.37:958.58", "0/0:198,0:963.49:1404.56", 
    "0/0:207,0:963.56:716.92", "1/1:0,137:701.77:529.76"), class = "factor"), 
    V18 = structure(c(2L, 1L, 4L, 3L, 5L, 6L), .Label = c("0/0:229,0:1256.92:582.37", 
    "0/0:264,0:1330.53:716.92", "0/0:303,0:1639.95:958.58", "0/0:399,0:1899.69:1404.56", 
    "1/1:0,268:1400.21:529.76", "1/1:0,332:1649.86:999.60"), class = "factor")), .Names = c("V1", 
"V2", "V3", "V4", "V5", "V6", "V7", "V8", "V9", "V10", "V11", 
"V12", "V13", "V14", "V15", "V16", "V17", "V18"), row.names = c(NA, 
6L), class = "data.frame")