[R] saving vector output as numeric

PIKAL Petr petr.pikal at precheza.cz
Thu Mar 14 17:35:42 CET 2013


Hi

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Aimee Kopolow
> Sent: Wednesday, March 13, 2013 5:39 AM
> To: r-help
> Subject: [R] saving vector output as numeric
> 
> Hi everybody,
> 
> I'm trying to create a numerical data frame on which to perform PRCC.
> So far I have created a data frame that consists of function/vector
> output that displays in numerical form, but when I try and run PRCC
> (from epiR package) I get the following error message:
> 
> 
> "Error in solve.default(C) :
>   Lapack routine dgesv: system is exactly singular"
> 
> It appears this is because the data frame is passing character strings
> rather than the numerical data to R.
> 
> An example of my original data frame minmaxfunc is as follows:
> 
>                              min          max
> T1       1.500000e+01 3.999954e+01
> SE1      0.000000e+00 1.000000e+00
> PRE      0.000000e+00 1.000000e+00
> WET      0.000000e+00 5.980000e+00
> BE1      4.664642e+00 5.866620e+00
> Kappa1   5.500000e+03 2.000000e+04
> Kappa3   1.000000e+04 2.000000e+04
> 
> 
> Then I created a latin hypercube set using (qunif(x[,i],
> minmaxfunc$min[i], minmaxfunc$max[i]). The new data frame looks as
> follows:
> 
> 
>               T1          SE1                       PRE
>    WET          BE1            Kappa1   Kappa3
> 1    31.35590 0.7066388715 0.8665111432 4.965701530 5.783424 12240.019
> 12675.12
> 2    28.27640 0.5442730461 0.7000693454 3.181014435 5.183708 16626.566
> 10759.27
> 3    28.14695 0.6295741145 0.7818034368 2.262515130 4.670685 16930.360
> 13857.44
> 4    30.51873 0.3983581045 0.4026640041 2.730221171 5.058697 19546.625
> 14408.89
> 5    16.03162 0.0440886703 0.9954737808 1.002989298 5.310149 13188.279
> 19500.85
> 6    19.48413 0.4280443098 0.8500412067 1.668042962 5.068510 11742.748
> 18891.87
> 7    36.44783 0.5033961511 0.8249423312 5.582521574 4.722634  8738.121
> 16457.21
> 8    39.76318 0.8805976090 0.3430379347 4.876022801 4.787737 19873.134
> 18660.02
> 9    39.99782 0.4109272317 0.6606016486 0.191627831 5.625588 11086.803
> 13569.30
> 
> Each cell contains a vector that is computing the numerical output, but
> how do I save the latin hypercube sampling data frame in numerical
> form??
> 
> I've tried as.numeric but the error message is (list) object cannot be
> coerced to type 'double' regardless of whether it's write.table,
> read.table or as.data.frame that I'm using as.numeric with.

Data frame is a list so as it can hold different class of objects together. as.numeric requires number or vector. Maybe you could change it by as.matrix.

However without some reproducible code (as required by posting guide) it is just a guess.

Please, try to show at least

str(your.object)

and preferably copy
dput(some.part.of.your.object)

to your post.
Regards

Petr

> 
> 
> Sorry if this is information dense, and thanks for any help you are
> able to give.
> 
> Aimee.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list