代码之家  ›  专栏  ›  技术社区  ›  Science11

Mathematica中的茎叶图

  •  0
  • Science11  · 技术社区  · 4 年前

    我导入了一个包含10个不同列的csv数据集。

    其中一列 更改 .

    我正试图用Mathematica绘制茎叶图。

    Mathematica代码示例 StemLeafPlot[{1.2, 2.5, 4.1, 1.6, 3.8, 2.6, 2.9}] 工作得很好。

    然而,当我尝试使用 更改 将列作为StemLeafPlot函数中的参数不起作用。

    col10 = DataSet1[[All, {10}]]
    
    StemLeafPlot[col10 ]
    

    我遇到了一个错误 StemLeafPlot::ndata: The argmuent at position 1 is not a list of real numbers.

    非常感谢您提供任何解决此错误的建议。

    以下是此列中的数据元素列表

    {"NA", -0.7, "NA", 0.88, 
    "NA", 0, -0.6, -1.4, "NA", -0.65, "NA", -0.72, "NA", -1.08, -0.7, -1, 
    0.1, 0.6, -0.31, "NA", 0.4, -0.7, 1.45, "NA", 0.43, "NA", -0.3, "NA", 
    -0.13, "NA", -0.82, "NA", -0.06, "NA", -0.14, -0.17, "NA", 0, 3.07, 
    -2.17, 0, -0.2, "NA", -1.75, "NA", -2.4, "NA", -0.96, -0.29, "NA", 
    -2.3, "NA", 0.18, -0.07, "NA", -1.52, "NA", 0.47, "NA", -1.5, "NA", 
    -0.12, -0.28, "NA", 3.85, "NA", 0.04, "NA", -0.97, "NA", 0.6, "NA", 
    -0.84, "NA", -1.2, "NA", 0.06, "NA", 0.6, -1.88, "NA", -0.32, -0.68, 
    "NA", 0.34, 1.66, "NA", 0.71, "NA", 0.2, 1.49, "NA", -0.44, "NA", 
    0.03, -0.9, "NA", -0.7, -0.28, "NA", 0, 0.56, "NA", 0.34, "NA", 0, 
    -0.1, 0.9, "NA", -0.53, "NA", 0.47, "NA", 0.89, "NA", 6, "NA", -1.17, 
    "NA", -0.66, "NA", 0.6, 0, -0.6}
    
    0 回复  |  直到 4 年前
        1
  •  0
  •   Chris Degnen Akila Dilan Md    4 年前

    StemLeafPlot只接受实数,因此删除“NA”字符串。

    StemLeafPlot[DeleteCases[col10, "NA"]]