我有一个成分数据集。我有一组包含百分比数据的列(样本)。因此,每一行(在我的情况下为通道直径)是每个样本都具有一定百分比的特定变量。例如
Channel diameter (um) sample2 sample3 sample8 sample9 sample17
0.375198 0.0365797 0.0424338 0.0158648 0.02944 0.0157091
0.411878 0.0647681 0.0750611 0.0280678 0.052028 0.0278099
0.452145 0.0956633 0.111489 0.0415484 0.0770551 0.0410209
0.496347 0.137893 0.162464 0.0601572 0.111755 0.0589772
0.544872 0.175746 0.210556 0.0771818 0.143911 0.0748565
0.59814 0.210752 0.257403 0.0932129 0.174446 0.089273
0.656615 0.244288 0.304665 0.10884 0.204511 0.102797
0.720807 0.278281 0.354677 0.124906 0.235612 0.11622
0.791275 0.31069 0.405324 0.140553 0.266354 0.128626
0.868632 0.339832 0.454374 0.15495 0.295125 0.139238
0.953552 0.365523 0.500985 0.167898 0.321535 0.147978
1.04677 0.387791 0.544478 0.179338 0.345493 0.154899
1.14911 0.407715 0.585383 0.189749 0.367873 0.160534
1.26145 0.424342 0.622144 0.1988 0.388226 0.164562
1.38477 0.437851 0.654347 0.206637 0.406776 0.167147
1.52015 0.448418 0.681951 0.213521 0.424175 0.168487
1.66876 0.457694 0.706822 0.220449 0.442197 0.169372
1.8319 0.466729 0.730714 0.228307 0.462539 0.170336
2.011 0.476516 0.755269 0.237889 0.48627 0.171799
2.2076 0.487906 0.782015 0.249849 0.514036 0.174083
2.42342 0.501736 0.81248 0.264752 0.546016 0.177432
2.66033 0.51929 0.848837 0.283331 0.582431 0.182235
2.92042 0.541324 0.892608 0.305976 0.62241 0.188562
3.20592 0.568374 0.944571 0.332691 0.663758 0.196293
3.51934 0.599897 1.00394 0.362726 0.702966 0.204848
3.8634 0.635522 1.06984 0.395209 0.736726 0.213754
4.2411 0.674643 1.14148 0.429266 0.762942 0.222574
4.65572 0.717242 1.21878 0.464337 0.780965 0.231205
5.11087 0.76318 1.30134 0.499874 0.791079 0.23963
5.61052 0.812207 1.38818 0.535257 0.794286 0.247904
6.15902 0.863791 1.478 0.570021 0.793137 0.256198
6.76114 0.917491 1.56991 0.604296 0.792304 0.264896
7.42212 0.973638 1.66349 0.638955 0.797465 0.274726
8.14773 1.03178 1.75579 0.674653 0.812076 0.286046
8.94427 1.09013 1.83889 0.710974 0.834453 0.298613
9.81869 1.14346 1.89853 0.745919 0.857295 0.310908
10.7786 1.18666 1.92001 0.77754 0.871976 0.321507
11.8323 1.21701 1.89513 0.805316 0.873849 0.329678
12.9891 1.23962 1.82973 0.830937 0.865868 0.336774
14.2589 1.26532 1.74176 0.855741 0.855011 0.345067
15.6529 1.30625 1.65369 0.877552 0.846228 0.35632
17.1832 1.37039 1.58411 0.889331 0.838007 0.370876
18.863 1.45674 1.54142 0.881201 0.822809 0.387127
20.7071 1.55939 1.52665 0.846803 0.793656 0.403864
22.7315 1.6691 1.53505 0.7877 0.749241 0.42062
24.9538 1.78027 1.56136 0.714575 0.696582 0.438749
27.3934 1.89095 1.60072 0.642402 0.646703 0.459818
30.0714 2.00065 1.64851 0.583683 0.608531 0.484033
33.0113 2.10867 1.70138 0.544639 0.585721 0.50996
36.2385 2.21043 1.75647 0.52405 0.57563 0.534436
39.7813 2.30025 1.81358 0.51599 0.572488 0.554934
43.6704 2.37323 1.87431 0.512943 0.570144 0.570926
47.9397 2.42843 1.9405 0.509019 0.564741 0.584767
52.6264 2.47132 2.01249 0.502374 0.556494 0.60136
57.7713 2.51141 2.08592 0.494986 0.549106 0.626145
63.4192 2.55913 2.15193 0.491467 0.549135 0.663665
69.6192 2.62015 2.19769 0.496593 0.563727 0.716063
76.4253 2.69185 2.2104 0.513592 0.598638 0.782837
83.8969 2.7645 2.18362 0.543656 0.656535 0.861711
92.0988 2.826 2.12191 0.585723 0.735146 0.949471
101.103 2.86765 2.04062 0.637396 0.827534 1.04325
110.987 2.88366 1.95552 0.695157 0.923739 1.1402
121.837 2.86566 1.87145 0.756528 1.01592 1.23771
133.748 2.79489 1.77514 0.820962 1.10124 1.33218
146.824 2.64552 1.64295 0.891174 1.18226 1.41966
161.177 2.39707 1.45793 0.970232 1.26132 1.49497
176.935 2.05403 1.2272 1.05834 1.3359 1.55358
194.232 1.65431 0.983299 1.14894 1.39739 1.59279
213.221 1.25961 0.76806 1.2303 1.43626 1.61461
234.066 0.932009 0.612117 1.29251 1.45138 1.62797
256.948 0.708748 0.526414 1.33762 1.45415 1.64839
282.068 0.596048 0.507822 1.3814 1.46446 1.69346
309.644 0.577959 0.544827 1.44754 1.49861 1.77678
339.916 0.628404 0.619653 1.55335 1.5589 1.90214
373.147 0.712328 0.706958 1.70468 1.63116 2.06529
409.626 0.785738 0.771807 1.88764 1.69265 2.25554
449.672 0.808987 0.78167 2.07784 1.72831 2.46479
493.633 0.763715 0.72189 2.24938 1.74795 2.69133
541.892 0.665773 0.613547 2.40785 1.79079 2.94904
594.869 0.562534 0.5129 2.57317 1.90894 3.24541
653.025 0.501094 0.468972 2.78062 2.1497 3.57554
716.866 0.509195 0.50887 3.03373 2.53054 3.89743
786.949 0.584288 0.63571 3.33205 3.02726 4.16047
863.883 0.682625 0.805693 3.64631 3.56815 4.31705
948.338 0.736664 0.946139 3.93691 4.04493 4.34466
1041.05 0.679724 0.960431 4.14637 4.34887 4.24767
1142.83 0.462905 0.717301 4.29187 4.39208 4.08343
1254.55 0.212328 0.364022 4.3391 4.11532 3.85551
1377.2 0.0459161 0.0848405 4.29583 3.5172 3.56707
1511.84 0.00420859 0.00868247 4.08845 2.63958 3.15498
1659.64 0 0 3.86265 1.92542 2.794
1821.89 0 0 3.64037 1.16644 2.40284
2000
我想将每个样本绘制为散点图(线)在同一张图上。 X轴为通道直径(行),y轴为列中的百分比数据。
我尝试过的大多数方法似乎都无法将第一列识别为x轴值。
答案 0 :(得分:-1)
创建一个空图:
plot(x=NA, y=NA, xlim=c(0,1), ylim=c(0,1),
xlab="My X Label", ylab="My Y Label",
main="My Title")
一次添加一行:
for(i in 2:ncol(df)) {
lines(x=df[,1], y=df[,i])
}
此代码假定您的data.frame与数据一起称为df
,并且您希望将所有列都绘制为y
变量,但将第一列视为x
变量除外