Displaying 20 results from an estimated 20000 matches similar to: "Why is 1 a double?"
2005 Apr 12
8
removing characters from a string
Is there a simple way in R to remove all characters
from a string other than those in a specified set? For
example, I want to keep only the digits 0-9 in a
string.
In general, I have found the string handling abilities
of R a bit limited. (Of course it's great for stats in
general). Is there a good reference on this? Or should
R programmers dump their output to a text file and use
something
2013 Jan 22
1
c(), rbind and cbind functions - why type of resulting object is double
Hello Everyone,
I am using R 2.15.0 and I came across this behaviour and I was wondering
why I don't get an integer vector or and integer matrix with the following
code:
> z <- c(1, 2:0, 3, 4:8)
> typeof(z)
[1] "double"
> z <- rbind(1, 2:0, 3, 4:8)
Warning message:
In rbind(1, 2:0, 3, 4:8) :
number of columns of result is not a multiple of vector length (arg
2002 May 14
2
NaN/NA and sprintf double format
With a (late prerelease of) 1.5.0 on Windows, using sprintf on NaN
yields garbage when the number of decimal is specified while it
works fine for NA:
> sprintf("%.2f", NA)
[1] "0.00"
> sprintf("%.2f", NaN)
[1] "-1.#J"
Not specifying the decimal precision lets both print garbage:
> sprintf("%f", NaN)
[1] "-1.#IND00"
>
2019 Oct 23
2
[PATCH V5 2/6] modpost: add support for mdev class id
On Wed, 23 Oct 2019 21:07:48 +0800
Jason Wang <jasowang at redhat.com> wrote:
> Add support to parse mdev class id table.
>
> Reviewed-by: Parav Pandit <parav at mellanox.com>
> Signed-off-by: Jason Wang <jasowang at redhat.com>
> ---
> drivers/vfio/mdev/vfio_mdev.c | 2 ++
> scripts/mod/devicetable-offsets.c | 3 +++
> scripts/mod/file2alias.c
2019 Oct 23
2
[PATCH V5 2/6] modpost: add support for mdev class id
On Wed, 23 Oct 2019 21:07:48 +0800
Jason Wang <jasowang at redhat.com> wrote:
> Add support to parse mdev class id table.
>
> Reviewed-by: Parav Pandit <parav at mellanox.com>
> Signed-off-by: Jason Wang <jasowang at redhat.com>
> ---
> drivers/vfio/mdev/vfio_mdev.c | 2 ++
> scripts/mod/devicetable-offsets.c | 3 +++
> scripts/mod/file2alias.c
2004 Mar 12
1
double vs. list
Hi all
I've got trouble with getting a "list" object and not being able to
change that:
Lets say x is a simple matrix and I want to remove all elements <3 to get
3
5 7
> x <- matrix(c(1,2,3,5,1,7), nrow=2, ncol=3, byrow=T)
> x
[,1] [,2] [,3]
[1,] 1 2 3
[2,] 5 1 7
> typeof(x)
[1] "double"
> y <- sapply(c(1,2), function(i)
2019 Sep 29
2
typeof(getOption("warn")) is "integer" instead of "double" in R unstable (2019-09-27 r77229)? Reproducible?
Hi,
I have a failing unit test in my package tryCatchLog on the CRAN build infrastructure
(https://cran.r-project.org/web/checks/check_results_tryCatchLog.html)
with "R Under development (unstable) (2019-09-27 r77229)"
and the unit tests just ensures consistent behaviour of R (not of my package) as a precondition:
The failing unit test is caused by
>
2005 Apr 13
3
terminate R program when trying to access out-of-bounds array element?
I want R to stop running a script (after printing an
error message) when an array subscript larger than the
length of the array is used, for example
x = c(1)
print(x[2])
rather than printing NA, since trying to access such
an element may indicate an error in my program. Is
there a way to get this behavior in R? Explicit
testing with the is.na() function everywhere does not
seem like a good
2019 Sep 29
2
typeof(getOption("warn")) is "integer" instead of "double" in R unstable (2019-09-27 r77229)? Reproducible?
Thanks a lot for pointing out the reason
(and yes, I am testing quite to stringent in this case - it's my old testing disease ;-)
For other readers:
The R-devel NEWS is a good source to find possible change reasons:
https://stat.ethz.ch/R-manual/R-devel/doc/html/NEWS.html
On Sun, 2019-09-29 at 08:33 -0400, Duncan Murdoch wrote:
> On 29/09/2019 7:55 a.m., nospam at altfeld-im.de wrote:
2005 Sep 01
1
error in apply help file? (PR#8118)
Gents: (alas, I think no ladies need to be included in the salutation)
The apply() Help file says
"...
If the calls to FUN return vectors of different lengths, apply returns a
list of length dim(X)[MARGIN]. "
Shouldn't that be:
"If the calls to FUN return vectors of different lengths, apply returns a
list of length prod(dim(X)[MARGIN]). "
Also, might you wish to add:
2013 Mar 22
1
Why does typeof() modify an object's "named" field?
Hello,
Doing typeof() on an object appears to reset the "named" field in its
sxpinfo header to 2, which can change the way that subsequent
subassignment operations are carried out:
X <- 1:5e7
.Internal(inspect(X))
# @4eeb0008 13 INTSXP g0c7 [NAM(1)] (len=50000000, tl=0) 1,2,3,4,5,...
system.time(X[1] <- 9L)
# user system elapsed
# 0 0 0
typeof(X)
2019 Oct 24
1
[PATCH V5 2/6] modpost: add support for mdev class id
On Thu, 24 Oct 2019 11:31:04 +0800
Jason Wang <jasowang at redhat.com> wrote:
> On 2019/10/24 ??5:42, Alex Williamson wrote:
> > On Wed, 23 Oct 2019 21:07:48 +0800
> > Jason Wang <jasowang at redhat.com> wrote:
> >
> >> Add support to parse mdev class id table.
> >>
> >> Reviewed-by: Parav Pandit <parav at mellanox.com>
>
2009 May 29
3
Why change data type when dropping to one-dimension?
Hello,
First, let me say I'm an avid fan of R--it's incredibly powerful and I
use it all the time. I appreciate all the hard work that the many
developers have undergone.
My question is: why does the paradigm of changing the type of a 1D
return value to an unlisted array exist? This introduces boundary
conditions where none need exist, thus making the coding harder and
confusing.
For
2010 Apr 30
3
Why do data frame column types vary across apply, lapply?
Hi,
I still have little ability to predict how these functions will treat the
columns of data frames:
> # Here's a data frame with a column "a" of integers,
> # and a column "b" of characters:
> df <- data.frame(
+ a = 1:2,
+ b = c("a","b")
+ )
> df
a b
1 1 a
2 2 b
>
> # Except -- both columns are characters:
>
2014 Apr 02
3
Typeof for character vector in dataframe returns integer
Hi ,
I want to know is this behavior expected and why is that ? Need some help
gender <- c("F", "M", "M", "F", "F", "M", "F", "F")
> age <- c(23, 25, 27, 29, 31, 33, 35, 37)
> df<- data.frame(gender,age)
> typeof(df[[1]])
[1] "integer"
2005 Apr 11
2
static analysis tools for R code?
An R script will terminate when one tries to use an
undefined variable, with a message such as
Error in print(x) : Object "x" not found
This run-time error might occur after the script has
already been running for some time. In some cases it
would be nice to get such warnings before the script
is run, just as a syntax error caused by a missing
parenthesis is caught.
Are there any
2020 Jun 30
2
[PATCH 18/18] arm64: lto: Strengthen READ_ONCE() to acquire when CLANG_LTO=y
On Tue, Jun 30, 2020 at 7:39 PM Will Deacon <will at kernel.org> wrote:
> +#define __READ_ONCE(x) \
> +({ \
> + int atomic = 1; \
> + union { __unqual_scalar_typeof(x) __val; char __c[1]; } __u; \
> +
2020 Jun 30
2
[PATCH 18/18] arm64: lto: Strengthen READ_ONCE() to acquire when CLANG_LTO=y
On Tue, Jun 30, 2020 at 7:39 PM Will Deacon <will at kernel.org> wrote:
> +#define __READ_ONCE(x) \
> +({ \
> + int atomic = 1; \
> + union { __unqual_scalar_typeof(x) __val; char __c[1]; } __u; \
> +
2004 Sep 08
4
factor always have type integer
typeof applied to a factor always seems to return "integer",
independently of the type of the levels.
This has a strange side effect.
When a variable is "imported" into a data frame,
its type changes.
character variables automatically are converted
to factors when imported into data frames.
Here is an example:
> v1<-1:3
>
2011 Aug 07
2
[PATCH] kinit minor checkpatch cleanup
coding style fixes.
FIXME: check that compiled bin the same1!!
---
usr/kinit/initrd.c | 3 ++-
usr/kinit/kinit.c | 12 ++++--------
usr/kinit/kinit.h | 20 ++++++++++----------
usr/kinit/name_to_dev.c | 6 +++---
usr/kinit/nfsroot.c | 5 ++---
5 files changed, 21 insertions(+), 25 deletions(-)
diff --git a/usr/kinit/initrd.c b/usr/kinit/initrd.c
index