Javascript 将TIBLE/dataframe转换为R中的JS数组
假设您拥有以下数据:Javascript 将TIBLE/dataframe转换为R中的JS数组,javascript,r,json,jsonlite,Javascript,R,Json,Jsonlite,假设您拥有以下数据: 库(TIBLE) 偏移量[{“索引”:0,“月份”:“七月”},{“索引”:1,“月份”:“八月”},{“索引”:2,“月份”:“九月”},{“索引”:3,“月份”:“十月”}] toJSON(偏移量,dataframe=“行”) #>[{“索引”:0,“月份”:“七月”},{“索引”:1,“月份”:“八月”},{“索引”:2,“月份”:“九月”},{“索引”:3,“月份”:“十月”}] toJSON(偏移量,dataframe=“列”) #>{“索引”:[0,1,2,3]
库(TIBLE)
偏移量[{“索引”:0,“月份”:“七月”},{“索引”:1,“月份”:“八月”},{“索引”:2,“月份”:“九月”},{“索引”:3,“月份”:“十月”}]
toJSON(偏移量,dataframe=“行”)
#>[{“索引”:0,“月份”:“七月”},{“索引”:1,“月份”:“八月”},{“索引”:2,“月份”:“九月”},{“索引”:3,“月份”:“十月”}]
toJSON(偏移量,dataframe=“列”)
#>{“索引”:[0,1,2,3],“月份”:[“七月”、“八月”、“九月”、“十月”]}
toJSON(偏移量,dataframe=“值”)
#>[0,“7月”],[1,“8月”],[2,“9月”],[3,“10月”]]
我使用JavaScript的经验非常有限,因此非常感谢您的帮助
由(v1.0.0)于2021-03-25年创建,这是否足够:
month <- offset$month
names(month) <- offset$index
cat(rjson::toJSON(list(offset = month)))
{"offset":{"0":"Jul","1":"Aug","2":"Sep","3":"Oct"}}
month辉煌!非常感谢。
month <- offset$month
names(month) <- offset$index
cat(rjson::toJSON(list(offset = month)))
{"offset":{"0":"Jul","1":"Aug","2":"Sep","3":"Oct"}}