Skip to content
Back to formatted view

Raw Message

Message-ID: <4DE6B8E0.1080909@gmail.com>
Date: 2011-06-01T22:10:40Z
From: Duncan Murdoch
Subject: Create Matrix with Float32 values
In-Reply-To: <SNT117-W119CBD230C8B0335599E79C57D0@phx.gbl>

On 01/06/2011 12:16 PM, Chris English wrote:
>
> Dear R_Help:
> The following gives me a matrix with integer values.
> z= matrix(rep(10:1, each= 10), ncol= 10, byrow=TRUE)>  str(z) int [1:10, 1:10] 10 9 8 7 6 5 4 3 2 1 ...
> How do I specify that I want Float32 values instead.

You can't.  R doesn't support that type.

If you want to pass it to an external function that is expecting C 
single type, you can use as.single(x).  That won't convert it to single 
precision, but it will cause it to be copied to a single precision array 
whenever you call .C or .Fortran.

Duncan Murdoch