[R] From NUM to INT

André Luis Neves andrluis at ualberta.ca
Tue Apr 26 19:11:38 CEST 2016


Dear all:

I converted the columns (Baci, Meti, Fungii, Protozoai) into integers
(using excel) and then imported the data (.txt) into R. Interestingly, the
other three variables were loaded as INT, but the 'Baci' one continued as
Num.

I imported the data using the following command line:

X <- read.delim(file.choose(),
                 header = TRUE,
                 dec = ".")

Here is the structure of X:

> str(X)
'data.frame': 115 obs. of  5 variables:
 $ ID       : Factor w/ 61 levels "107ZRED","112BLKW",..: 8 12 15 18 26 27
29 31 32 36 ...
 $ Baci     : num  2.90e+12 5.55e+11 9.46e+11 8.13e+11 4.06e+11 ...
 $ Meti     : int  352645997 334146268 767208656 171567266 462747405
414905627 237010514 387480048 214671355 328813226 ...
 $ Fungii   : int  43645 19009 15998 2189 8972 8240 3133 17922 6156 13746
...
 $ Protozoai: int  3220523 1851891 3252462 1665675 34123768 23175015 203685
4261780 43110492 69802572 ...


I need Baci as an integer, and tried to convert it using as.integer
function, but was not successful.


Could anyone please help me to solve this problem.

Thanks,


​
-- 
Andre
-------------- next part --------------
ID	Baci	Meti	Fungii	Protozoai
126BLK	2.90E+12	352645997	43645	3220523
13ZBLK	5.55E+11	334146268	19009	1851891
157BLK	9.46E+11	767208656	15998	3252462
162ZRED	8.13E+11	171567266	2189	1665675
17ZBLKY	4.06E+11	462747405	8972	34123768
184ZBLK	5.75E+11	414905627	8240	23175015
1ZBLKW	3.45E+10	237010514	3133	203685
2094ZBLK	3.49E+11	387480048	17922	4261780
20LZBLK	1.63E+11	214671355	6156	43110492
29ZBLK	3.37E+11	328813226	13746	69802572
2ZBLKG	3.13E+11	564519908	4003	93195958
60ZRED	3.76E+11	145383281	12473	33141411
77BLK	2.92E+11	227643897	13328	306363850
8ZBLK	2.45E+11	565298547	2900	29939862
91ZRED	5.62E+11	472996887	8584	73402283
112BLKW	7.02E+10	475554339	192654	37844605
1226BLK	1.84E+10	239034620	65524	3994847
12ZBLK	6.45E+10	296646742	286966	45244390
134BLK	9.65E+09	201168840	47474	2756770
160ZRED	5.96E+10	193983600	155040	79660710
166ZRED	8.14E+10	315417009	26056	85856558
17ZBLK G	1.88E+11	626249880	74214	17763633
226ZBLK	3.88E+10	181768548	291862	128256576
3ZBLK	2.38E+10	175939117	46015	8351259
58BLK	5.37E+10	304530782	50342	7718372
60ZBLK	4.23E+10	375725507	146473	58960339
72ZRED	9.58E+10	373650117	73205	171268872
7ZBLK	4.78E+10	146490232	17068	171268872
95BLK	4.18E+10	210377292	71368	31213851
9PZRED	7.12E+10	278312630	178204	392574732
107ZRED	1.18E+11	497812799	7074	5212968
129BLK	1.01E+10	172557004	565	373103
150ZRED	1.48E+11	343107486	7869	65118676
168BLK	9.45E+10	298332033	5281	17428719
174ZBLK	6.29E+10	269735103	24635	42532632
185ZRED	7.81E+10	647775276	1973	48855746
2ZBLKY	4.93E+09	35698451	3183	28935576
4089ZBLK	1.94E+10	326852779	1329	520051
438XZRED	7.20E+09	113153909	630	127811
4ZBLK	5.30E+10	248877230	1469	827989
706ZBLK	3.12E+10	151072339	2407	4885127
86BLK	9.39E+10	526984044	417	1034021
86ZRED	5.71E+10	385701592	7834	92440481
89BLK	3.80E+10	297806285	6314	62159379
112XZBLKG	9.56E+11	603355806	5205	199868382
1191ZBLK	4.59E+11	403738704	35115	93137246
122ZRED	2.93E+11	266699375	930	68471595
14ZBLK	8.03E+11	607043335	5570	75196835
15ZBLK	3.99E+11	185346266	1716	26429018
163BLK	7.18E+11	598193580	20475	419543828
175ZRED	2.08E+11	660223375	4421	35481033
1ZBLKY	6.84E+11	472986697	43059	137129730
20SXZBLK	3.16E+11	26119538	20297	8031502
22ZBLK	7.70E+11	823508297	154975	264859084
63ZBLK	2.10E+11	1601226529	13317	44878482
6ZBLK	1.31E+11	110772471	1395	40830068
82ZBLK	1.10E+12	839550736	5368	68087375
92ZBLK	4.32E+11	829679134	14981	98201518
94BLK	1.54E+11	197873442	1680	6800437
126BLK	2.22E+11	209765315	13000	92754991
13ZBLK	6.75E+11	366018180	18291	60965929
157BLK	2.88E+11	227660122	8904	20595699
162ZRED	1.85E+11	372912115	3124	516219
17ZBLKY	1.02E+11	170028711	4288	1391174
184ZBLK	4.28E+11	385951078	18173	142041693
1ZBLKW	1.26E+11	258658827	3974	1096335
2094ZBLK	2.80E+11	299019239	22940	4827333
20LZBLK	3.00E+11	258928407	1865	5996901
29ZBLK	2.75E+11	363091053	6551	7162010
2ZBLKG	4.53E+11	464020273	12748	20250369
60ZRED	2.45E+11	352738870	15630	22315303
77BLK	1.44E+11	342240282	4192	52542312
8ZBLK	6.66E+10	493488493	3308	8744844
91ZRED	3.52E+10	232562927	861	3506357
112BLKW	2.23E+10	261910886	35522	20277307
1226 BLK	2.39E+10	107972216	48447	25703984
12ZBLK	9.52E+09	392721062	21520	24103013
134BLK	1.73E+10	320819409	62156	107809914
160ZRED	1.06E+11	423290206	201494	62173555
166ZRED	2.92E+10	173837762	9813	4325219
17ZBLKG	2.87E+10	108073600	151168	19695454
226ZBLK	3.58E+10	470892623	203516	447240999
3ZBLK	1.98E+10	149631240	5962	758907
58BLK	6.71E+09	98009797	10103	18282903
60ZBLK	4.12E+10	382747754	96469	4348146
7ZBLK	7.97E+09	88160280	79680	0
95BLK	2.98E+10	202534656	33088	51649275
9PZRED	8.24E+10	388722787	274104	50360078
107ZRED	1.59E+11	109157702	170772	3550234
129BLK	7.59E+09	56423562	1081	1655868
150ZRED	5.69E+10	961853511	33383	13049429
168BLK	6.45E+10	858912603	5990	2934900
174ZBLK	2.04E+10	275907178	601	14077017
185ZRED	1.01E+11	659755530	12468	145136849
2ZBLKY	1.74E+11	458456526	1757	1314242
4089ZBLK	1.88E+11	166340053	2227	861368
438XZRED	3.83E+11	146896139	17545	25426282
4ZBLK	3.96E+11	340192787	7375	16393765
706ZBLK	3.35E+11	656715841	45618	16360596
86ZRED	3.58E+11	594300567	3410	6976935
89BLK	3.51E+11	452257311	22147	12239312
112XZBLKG	2.68E+11	32640092	49973	30637702
1191ZBLK	2.64E+11	744630951	6067	40742989
122ZRED	8.69E+11	1949076953	11653	75332032
14ZBLK	9.29E+11	683016842	50505	70023751
15ZBLK	9.35E+11	310951369	11492	73268344
163BLK	5.01E+11	285192250	12751	43365735
175ZRED	1.19E+12	597936244	14100	44029110
20SXZBLK	5.57E+11	903885504	22956	119497274
22ZBLK	2.60E+11	667969933	23005	6043141
63ZBLK	2.98E+11	685111047	3578	23920500
6ZBLK	4.77E+11	543466563	11550	39048343
82ZBLK	2.55E+11	697276518	3153	72481942
92ZBLK	1.95E+11	272494229	48511	60524953
94BLK	1.02E+12	2146559014	104139	258779386


More information about the R-help mailing list