0

I have a data frame which contains 3 columns of numeric values (p-values) and 1 columns of frequency values (which should not be multiplied). I want to multiply the first 3 columns and let the last column untouched.

my.df:

myfamDF<-structure(list(MASHvstRap = c(3.36388469632471e-14, 4.33277656523673e-123, 
3.06769943976602e-08, 6.07022175358029e-30, 4.82890837154273e-32, 
4.93181852868703e-06, 1.22573775496788e-08, 1.25502843779857e-05, 
1.72864219357795e-05, 4.71138538453502e-05, 8.34818462488622e-05, 
1.62205005760679e-17), MASHvsBEEML = c(0.763756578209722, 0.442020719677047, 
0.423594358667165, 0.0994358268075855, 0.0736357072352032, 0.0467257430288347, 
0.00119919900578073, 0.00094114146973297, 0.000840376826415137, 
0.000623286035357452, 0.000250015234002341, 1.46483433509648e-08
), tRapvsBEEML = c(3.75944533892572e-07, 8.44025048683083e-74, 
7.51004008659922e-09, 5.3728011843321e-09, 7.20783906680568e-26, 
6.69189512726035e-07, 3.60117573203279e-07, 1.17030570144044e-06, 
2.54589884424594e-07, 3.93333369828925e-07, 8.80480124829088e-06, 
2.89656372293867e-25), frequency = c(19, 158, 11, 44, 121, 10, 
13, 10, 10, 17, 10, 54)), .Names = c("MASHvstRap", "MASHvsBEEML", 
"tRapvsBEEML", "frequency"), row.names = c("Homeo ", "Homeo", 
"Homeo, POU", "HMG", "unknown", "ZnF_C4", "HLH", "IRF", "FH", 
"Zn2Cys6", "ETS", "ZnF_C2H2"), class = "data.frame")

i tried the following: myfamDF[1:3] * 12 But that gives me only the first 3 columns and 4th is lossed. How to maintain all columns and multiply the first 3 with 12.

4

2 回答 2

5

你几乎拥有它:

myfamDF[, 1:3] <- myfamDF[, 1:3] * 12
于 2013-06-24T12:10:58.120 回答
4
transform(myfamDF, MASHvstRap=MASHvstRap*12, MASHvsBEEML=MASHvsBEEML*12, tRapvsBEEML=tRapvsBEEML*12)
## or ##
cbind(myfamDF[,1:3]*12, myfamDF[,4])
于 2013-06-24T12:08:13.887 回答