[BioC] error with as.numeric when running pvclust

James W. MacDonald jmacdon at uw.edu
Tue Nov 13 20:45:38 CET 2012


Hi Alyaa,

See here:

http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-convert-factors-to-numeric_003f

Best,

Jim



On 11/13/2012 1:52 PM, Alyaa Mahmoud wrote:
> Dear All
>
> I have a dataframe (data) with numeric values. However, when I run pvclust
> i get the error:
>
>> pv<- pvclust(as.matrix(data), method.dist="correlation",
> method.hclust="complete", nboot=10)
> Error in cor(x, method = "pearson", use = use.cor) : 'x' must be numeric
>
> I tried to convert to numeric using as.numeric:
> data[,1:5] = lapply(data[,1:5], as.numeric) but the values change if I do
> this ?????
>
> Anybody knows why would the values change when I use as.numeric ?? How can
> I convert the values to "numeric" without changing them then ??
>
>> data
>            TCGA.02.0074.01A.01R.0202.01 TCGA.06.0174.01A.01R.0233.01
> 1053_at               *6.78057386468964*             7.20429615680331
> 117_at                 4.5369738739652             5.71461488261629
> 121_at                 5.7547177840092             6.27768302308676
> 1255_g_at             3.51242959009833             4.38185514015951
> 1294_at               5.71812084213166             5.18297525921706
>            TCGA.06.0188.01A.01R.0233.01 TCGA.06.0241.01A.02R.0233.01
> 1053_at               6.32600010999327             7.36481160075073
> 117_at                 4.8915996267868             4.91877155427287
> 121_at                6.22521524027822             5.92939849291023
> 1255_g_at             5.81450662569868             3.56178691911277
> 1294_at               5.94603190363047             5.08045063963826
>            TCGA.06.0178.01A.01R.0233.01
> 1053_at               7.08406595975373
> 117_at                4.45519578310485
> 121_at                6.98951423954871
> 1255_g_at             3.41240570036661
> 1294_at               6.19723107114317
>> pv<- pvclust(as.matrix(data), method.dist="correlation",
> method.hclust="complete", nboot=10)
> Error in cor(x, method = "pearson", use = use.cor) : 'x' must be numeric
>> *data[,1:5] = lapply(data[,1:5], as.numeric)*
>> data
>            TCGA.02.0074.01A.01R.0202.01 TCGA.06.0174.01A.01R.0233.01
> 1053_at                          *15129 *                       16227
> 117_at                            9527                        12658
> 121_at                           12662                        13992
> 1255_g_at                         2970                         8963
> 1294_at                          12578                        11398
>            TCGA.06.0188.01A.01R.0233.01 TCGA.06.0241.01A.02R.0233.01
> 1053_at                          14118                        16721
> 117_at                           10585                        10885
> 121_at                           13874                        13334
> 1255_g_at                        12852                         2937
> 1294_at                          13197                        11307
>            TCGA.06.0178.01A.01R.0233.01
> 1053_at                          16314
> 117_at                            8829
> 121_at                           16074
> 1255_g_at                         1765
> 1294_at
>
>
> Thanks a lot
> yours,
> Alyaa

-- 
James W. MacDonald, M.S.
Biostatistician
University of Washington
Environmental and Occupational Health Sciences
4225 Roosevelt Way NE, # 100
Seattle WA 98105-6099



More information about the Bioconductor mailing list