我已经按照这篇文章如何将JavaScript数组信息导出到csv(在客户端)?获取嵌套的js数组写为csv文件.
该数组看起来像:
var test_array = [["name1", 2, 3], ["name2", 4, 5], ["name3", 6, 7], ["name4", 8, 9], ["name5", 10, 11]];
Run Code Online (Sandbox Code Playgroud)
链接中给出的代码很好地工作,除了在csv文件的第三行之后所有其余值都在同一行上,例如
name1,2,3
name2,4,5
name3,6,7
name4,8,9name5,10,11等
任何人都可以解释为什么会这样吗?使用Chrome或FF也是如此.
谢谢
编辑
jsfiddle http://jsfiddle.net/iaingallagher/dJKz6/
伊恩
使用以下数据框,我想通过复制和分组对数据进行分组,然后计算处理值与控制值的比率。
structure(list(group = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L,
2L), .Label = c("case", "controls"), class = "factor"), treatment = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "EPA", class = "factor"),
replicate = structure(c(2L, 4L, 3L, 1L, 2L, 4L, 3L, 1L), .Label = c("four",
"one", "three", "two"), class = "factor"), fatty_acid_family = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "saturated", class = "factor"),
fatty_acid = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label …Run Code Online (Sandbox Code Playgroud)