search for: na_real_

Displaying 20 results from an estimated 92 matches for "na_real_".

2009 Jun 03
2
Create a time interval from a single time variable
...of 2 subjects: sample1 <- structure(list(ID = c(71622L, 71622L, 71622L, 71622L, 71622L, 71622L, 71622L, 71622L, 71622L, 1436L), Age = c(0.008, 0.085, 0.123, 0.277, 0.441, 0.517, 0.594, 0.715, 0.791, 6.968), DaysEnrolled = c(0L, 28L, 42L, 98L, 158L, 186L, 214L, 258L, 286L, 0L), HAZ = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), WAZ = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), WHZ = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA...
2012 Jul 18
2
loop searching the id corresponding to the given index (timestamp)
...1.600", "1.600", "1.600", "1.600", "1.600", "1.600", "1.600", "1.600", "1.600", "1.600", "1.600", "1.600", "1.600", "1.600", "1.600"), l_along = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), l_cross = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_re...
2008 Jun 19
1
PrettyR (describe)
...0.00021, 5.3e-05, NA, NA, NA, 0.0036, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA ), Calcium = c(2.3, 1.9, 2.3, 2, 2.2, 2, 2.5, 2, 2.2, 2, 1.7, 1.8, 1.8, 2.2, 2.1, 3.4, 2.2, 2.2, 2.6, 2.4, 2.6, 2.5, 2.1, 2.4, 2.3, 2.5, 2.6), Carbonaceous.BOD..5.day = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), Chloride = c(2.9,...
2012 Apr 19
1
SmoothTrend in OpenAir
...quot;,) #Plot the data smoothTrend(mydata, pollutant = "pH") --------------------------------------------------------------------------------- I get the following error: Error in seq.int(0, to0 - from, by) : 'to' must be finite In addition: Warning messages: 1: In min.default(c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, : no non-missing arguments to min; returning Inf 2: In max.default(c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, : no non-missing arguments to max; returning -Inf > A copy of the data can be found at www.doylesdartden.com/e/MCNP-pH.csv Any s...
2008 Apr 29
1
merging multiple data frames with different numbers of rows
...her feb06 <- structure(list(RiverMile = c(202L, 190L, 185L), X2.1.06 = c(2850000, NA, NA)), .Names = c("RiverMile", "X2.1.06"), row.names = c(29L, 31L, 32L), class = "data.frame") may06 <- structure(list(RiverMile = c(202L, 198L, 190L, 185L, 148L), X5.1.06 = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_)), .Names = c("RiverMile", "X5.1.06"), row.names = c(29L, 30L, 31L, 32L, 34L), class = "data.frame") jun06 <- structure(list(RiverMile = c(202L, 198L, 190L, 185L, 148L), X6.1.06 = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_...
2017 Jan 11
2
R 'base' returning 0 as sum of NAs
Dear R Team The following line returns 0 (zero) as answer: sum(c(NA_real_, NA_real_, NA_real_, NA_real_), na.rm = TRUE) One would, however, have expected it to return 'NaN', as is the case with function 'mean': > mean(c(NA_real_, NA_real_, NA_real_, NA_real_), na.rm = TRUE) [1] NaN The problem in other words: I have a vector filled with missing numb...
2023 Apr 14
1
Possible inconsistency between `as.complex(NA_real_)` and the docs
Hi all, Surprisingly (at least to me), `as.complex(NA_real_)` results in `complex(real = NA_real_, imaginary = 0)` rather than `NA_complex_`. It seems to me that this goes against the docs of `as.complex()`, which say this in the Details section: "Up to R versions 3.2.x, all forms of NA and NaN were coerced to a complex NA, i.e., the NA_complex_ cons...
2008 Apr 29
1
data management (subsetting and recombining)
...nts? feb06 <- structure(list(RiverMile = c(202L, 190L, 185L), X2.1.06 = c(2850000, NA, NA)), .Names = c("RiverMile", "X2.1.06"), row.names = c(29L, 31L, 32L), class = "data.frame") may06 <- structure(list(RiverMile = c(202L, 198L, 190L, 185L, 148L), X5.1.06 = c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_)), .Names = c("RiverMile", "X5.1.06"), row.names = c(29L, 30L, 31L, 32L, 34L), class = "data.frame") merge(feb06, may06, by="RiverMile") Error in fix.by(by.x, x) : 'by' must specify column(s) as numbers, nam...
2009 Apr 30
2
NA_real_ <op> NaN -> NA or NaN, should we care?
On Linux when I compile R 2.10.0(devel) (src/main/arithmetic.c in particular) with gcc 3.4.5 using the flags -g -O2 I get noncommutative behavior when adding NA and NaN: > NA_real_ + NaN [1] NaN > NaN + NA_real_ [1] NA If I compile src/main/arithmetic.c without optimization (just -g) then both of those return NA. On Windows, using a precompiled R 2.8.1 from CRAN I get NA for both answers. On Linux, after compiling src/main/arithmetic.c with -g -O2 the bit patter...
2010 Nov 24
0
rbind error (maybe a problem with chron package?)
...rmat = structure(c("m/d/y", "h:m:s"), .Names = c("dates", "times")), origin = structure(c(1, 1, 1970), .Names = c("month", "day", "year")), class = c("chron", "dates", "times")), val = structure(c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), .Dim = 6L)), .Names = c("date", "val"), row.names = c(NA, 6L), class = "data.frame") -------------------------------------------------- and an example of the error: ------------------------------------------------...
2020 May 23
2
Should 0L * NA_integer_ be 0L?
...all(NA, FALSE) # [1] FALSE NA * FALSE # [1] NA I agree with all(NA, FALSE) being FALSE because we know for sure that all cannot be true. The same can be said of the multiplication -- whether NA represents TRUE or FALSE, the resulting value is 0 (FALSE). I also agree with the numeric case, FWIW: NA_real_ * 0 has to be NA_real_, because NA_real_ could be Inf or NaN, for both of which multiplication by 0 gives NaN, hence 0 * NA_real_ is either 0 or NaN, hence it must be NA_real_. [[alternative HTML version deleted]]
2017 May 19
2
Inconsistency in handling of numeric input with %d by sprintf
Consider #as.numeric for emphasis sprintf('%d', as.numeric(1)) # [1] "1" vs. sprintf('%d', NA_real_) > Error in sprintf("%d", NA_real_) : invalid format '%d'; use format %f, %e, %g or %a for numeric object > I understand the error is correct, but if it works for other numeric input, why doesn't R just coerce NA_real_ to NA_integer_? Michael Chirico [[alternat...
2015 Jun 01
0
sum(..., na.rm=FALSE): Summing over NA_real_ values much more expensive than non-NAs for na.rm=FALSE? Hmm...
...code and the internal code for base::sum() is that the latter uses LDOUBLE = long double (on some system it's only double, cf. https://github.com/wch/r-source/blob/trunk/src/nmath/nmath.h#L28-L33), whereas my sum2() code uses double. So using long double, I can reproduce the penalty of having NA_real_ with na.rm=FALSE; > sum3 <- inline::cfunction(sig=c(x="double", narm="logical"), body=' #define LDOUBLE long double double *x_ = REAL(x); int narm_ = asLogical(narm); int n = length(x); LDOUBLE sum = 0.0; for (R_xlen_t i = 0; i < n; i++) { if (!narm_ || !IS...
2015 Jun 01
2
sum(..., na.rm=FALSE): Summing over NA_real_ values much more expensive than non-NAs for na.rm=FALSE? Hmm...
....2.0, on Windows (using the official CRAN builds), on Linux (local built), and on OS X (official AT&T builds), I get: > x <- rep(0, 1e8) > stopifnot(typeof(x) == "double") > system.time(sum(x, na.rm=FALSE)) user system elapsed 0.19 0.01 0.20 > y <- rep(NA_real_, 1e8) > stopifnot(typeof(y) == "double") > system.time(sum(y, na.rm=FALSE)) user system elapsed 9.54 0.00 9.55 > z <- x; z[length(z)/2] <- NA_real_ > stopifnot(typeof(z) == "double") > system.time(sum(z, na.rm=FALSE)) user system elapsed...
2017 May 23
2
Inconsistency in handling of numeric input with %d by sprintf
...l coerce real to > integer without complaint, other times it won't. (My particular email had > to do with the vectors longer than 1 and their positioning vis-a-vis the > format string.) The safest thing is just to pass the right type. In this > case, sprintf('%d', as.integer(NA_real_)) works. > > Best, > > Evan > > On Fri, May 19, 2017 at 9:23 AM, Michael Chirico < > michaelchirico4 at gmail.com> > wrote: > > > Consider > > > > #as.numeric for emphasis > > sprintf('%d', as.numeric(1)) > > # [1] "1"...
2009 Jun 03
1
Print bug for matrix(list(NA_complex_, ...))
...in printing val <- matrix(list(NA_complex_,NA_complex_),1). > dput(val) structure(list(NA_complex_, NA_complex_), .Dim = 1:2) > print(val) [,1] [1,] [,2] [1,] Note that a large number of spaces are printed instead of NA. Compare the unproblematic real case: print(structure(list(NA_real_, NA_real_), .Dim = 1:2)) [,1] [,2] [1,] NA NA Also, when printed in the read-eval-print loop, printing takes a very very long time: > proc.time(); matrix(list(NA_complex_,NA_complex_),1); proc.time() user system elapsed 74.35 0.09 329.45 [,1] [1,] [,2] [1,] user syst...
2012 Jul 11
1
Package MuMIn (dredge): Error in ret[, ] <- cbind(x, se, rep(if (is.null(df)) NA_real_ else df, : number of items to replace is not a multiple of replacement length.
...9;MuMIn' [dredge]. The data file is large (585000 rows) and has no NA, -9999 or blank values (attached data file with 200 rows). Following the dredge command, I get the following error and warning (see end of message for details): "Error in ret[, ] <- cbind(x, se, rep(if (is.null(df)) NA_real_ else df, : number of items to replace is not a multiple of replacement length In addition: Warning message: In cbind(x, se, rep(if (is.null(df)) NA_real_ else df, length.out = n), : number of rows of result is not a multiple of vector length (arg 3)". I am unclear what this means and h...
2017 May 23
2
Inconsistency in handling of numeric input with %d by sprintf
...teger without complaint, other times it won't. (My particular email had >>> to do with the vectors longer than 1 and their positioning vis-a-vis the >>> format string.) The safest thing is just to pass the right type. In this >>> case, sprintf('%d', as.integer(NA_real_)) works. >>> >>> Best, >>> >>> Evan >>> >>> On Fri, May 19, 2017 at 9:23 AM, Michael Chirico < >>> michaelchirico4 at gmail.com> >>> wrote: >>> >>> > Consider >>> > >>> > #as.n...
2023 Nov 06
1
c(NA, 0+1i) not the same as c(as.complex(NA), 0+1i)?
Hmm, it is not actually at odds with help(c), it is just that the autocoercion works different that it used to, so that as.complex(NA) == as.complex(NA_real) == NA_real_+0i) which now differs from NA_complex although both print as NA. I haven't been quite alert when this change was discussed, but it does look a bit unfortunate that usage patterns like c(NA, 0+1i) does not give complex NA for the 1st component, effectively changing the interpretation from &...
2024 Oct 08
1
WRE about R_strtod
...rtod (const char* str, char ** end) >> >> Implementations of the C99/POSIX functions atof and strtod which >> guarantee platform-dependent behaviour, including always using the >> period as the decimal point aka ?radix character? and converting >> "NA" to R?s NA_REAL_ . Besides the easily fixable return type (void -> double), shouldn't the documentation mention the fact that, unlike the standard C library functions, R's parser returns NA_REAL instead of 0 when no conversion is performed (including for the "NA" string, *end == str)? Index:...