[R] how to keep all zeros in 1st row (not NA)
iembry
iruckaE at mail2world.com
Wed Nov 28 14:17:37 CET 2012
Hi, let me correct my previous post ("zeros in double matrix rather than
character matrix").
I have included entries from the .csv file that has 4 columns of 1000
columns and 101 rows. The first column with the "Time (day)" will not be
removed, but the row headers are the numbers 1 to 1000 and they will remain
in the matrix.
In the previous post I mentioned that R makes the 1000 columns and the 101
rows into a "101x0 character matrix" once I removed the 1st column "Time
(day)". Instead I want this to be a "101x1000 double matrix".
What needs to be done to make the .csv into a double matrix rather than a
character matrix when the first row is all zeros (0s)?
Thank-you.
Irucka Embry
This is the code that I am using:
Input <- as.matrix(read.csv("Input_Parameter.csv", header = TRUE, sep =","))
Input <- as.matrix(Input[,-1]) # remove column 1 from analysis
This is some of the values that are being read from the .csv file:
Time (day) 1 2 3 4
0 0 0 0 0
1 0.16387 0.60612 0.87705 0.83798
2 0.32774 1.2122 1.7541 1.676
3 0.4916 1.8184 2.6312 2.5139
4 0.65547 2.4245 3.5082 3.3519
5 0.81934 3.0306 4.3853 4.1899
6 0.98321 3.6367 5.2623 5.0279
7 1.1471 4.2429 6.1394 5.8659
8 1.3109 4.849 7.0164 6.7038
9 1.4748 5.4551 7.8935 7.5418
10 1.6387 6.0612 8.7705 8.3798
11 1.8026 6.6673 9.6476 9.2178
12 1.9664 7.2735 10.525 10.056
13 2.1303 7.8796 11.402 10.894
14 2.2942 8.4857 12.279 11.732
15 2.458 9.0918 13.156 12.57
16 2.6219 9.6979 14.033 13.408
17 2.7858 10.304 14.91 14.246
18 2.9496 10.91 15.787 15.084
19 3.1135 11.516 16.664 15.922
20 3.2774 12.122 17.541 16.76
21 3.4412 12.729 18.418 17.598
22 3.6051 13.335 19.295 18.436
23 3.769 13.941 20.172 19.274
24 3.9328 14.547 21.049 20.112
25 4.0967 15.153 21.926 20.95
26 4.2606 15.759 22.803 21.788
27 4.4244 16.365 23.68 22.625
28 4.5883 16.971 24.557 23.463
29 4.7522 17.578 25.434 24.301
30 4.916 18.184 26.312 25.139
31 5.0799 18.79 27.189 25.977
32 5.2438 19.396 28.066 26.815
33 5.4077 20.002 28.943 27.653
34 5.5715 20.608 29.82 28.491
35 5.7354 21.214 30.697 29.329
36 5.8993 21.82 31.574 30.167
37 6.0631 22.426 32.451 31.005
38 6.227 23.033 33.328 31.843
39 6.3909 23.639 34.205 32.681
40 6.5547 24.245 35.082 33.519
41 6.7186 24.851 35.959 34.357
42 6.8825 25.457 36.836 35.195
43 7.0463 26.063 37.713 36.033
44 7.2102 26.669 38.59 36.871
45 7.3741 27.275 39.467 37.709
46 7.5379 27.882 40.344 38.547
47 7.7018 28.488 41.221 39.385
48 7.8657 29.094 42.098 40.223
49 8.0295 29.7 42.976 41.061
50 8.1934 30.306 43.853 41.899
51 8.1115 30.003 43.414 41.48
52 8.0295 29.7 42.976 41.061
53 7.9476 29.397 42.537 40.642
54 7.8657 29.094 42.098 40.223
55 7.7837 28.791 41.66 39.804
56 7.7018 28.488 41.221 39.385
57 7.6199 28.185 40.783 38.966
58 7.5379 27.882 40.344 38.547
59 7.456 27.579 39.906 38.128
60 7.3741 27.275 39.467 37.709
61 7.2921 26.972 39.029 37.29
62 7.2102 26.669 38.59 36.871
63 7.1283 26.366 38.152 36.452
64 7.0463 26.063 37.713 36.033
65 6.9644 25.76 37.275 35.614
66 6.8825 25.457 36.836 35.195
67 6.8005 25.154 36.398 34.776
68 6.7186 24.851 35.959 34.357
69 6.6367 24.548 35.521 33.938
70 6.5547 24.245 35.082 33.519
71 6.4728 23.942 34.644 33.1
72 6.3909 23.639 34.205 32.681
73 6.3089 23.336 33.766 32.262
74 6.227 23.033 33.328 31.843
75 6.1451 22.73 32.889 31.424
76 6.0631 22.426 32.451 31.005
77 5.9812 22.123 32.012 30.586
78 5.8993 21.82 31.574 30.167
79 5.8173 21.517 31.135 29.748
80 5.7354 21.214 30.697 29.329
81 5.6535 20.911 30.258 28.91
82 5.5715 20.608 29.82 28.491
83 5.4896 20.305 29.381 28.072
84 5.4077 20.002 28.943 27.653
85 5.3257 19.699 28.504 27.234
86 5.2438 19.396 28.066 26.815
87 5.1618 19.093 27.627 26.396
88 5.0799 18.79 27.189 25.977
89 4.998 18.487 26.75 25.558
90 4.916 18.184 26.312 25.139
91 4.8341 17.881 25.873 24.72
92 4.7522 17.578 25.434 24.301
93 4.6702 17.274 24.996 23.882
94 4.5883 16.971 24.557 23.463
95 4.5064 16.668 24.119 23.044
96 4.4244 16.365 23.68 22.625
97 4.3425 16.062 23.242 22.206
98 4.2606 15.759 22.803 21.788
99 4.1786 15.456 22.365 21.369
100 4.0967 15.153 21.926 20.95
--
View this message in context: http://r.789695.n4.nabble.com/how-to-keep-all-zeros-in-1st-row-not-NA-tp4651132.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list