Displaying 20 results from an estimated 10000 matches similar to: "odd behavior of numeric()"
2012 Nov 30
3
protentially serious R error
Hi guy,
I have recently encountered a problem while I was just trying to generate
some random numbers with the function "rnorm", the problem is shown below:
########case 1############
> rnorm(20*0.2)
[1] -1.2765922 -0.5732654 -1.2246126 -0.4734006
########case 2###########
*> rnorm(20*(1-0.8))
[1] -0.62036668 0.04211587 -0.91092165*
#########case 3############
> a<-0.2
>
2009 Mar 18
3
numeric equality
Dear all,
I am totally confused by the following R output, but don't have a clue
for it.
> a <- 1 - 0.2
> a == 0.8
[1] TRUE
> a <- 1 - 0.8
> a == 0.2
[1] FALSE
> a <- 1 - 0.5
> a == 0.5
[1] TRUE
> a <- 1 - 0.6
> a == 0.4
[1] TRUE
> a <- 1 - 0.9
> a == 0.1
[1] FALSE
My R version is Windows XP R version 2.8.1 (2008-12-22).
2007 Jul 27
2
Matrix Multiplication, Floating-Point, etc.
Hi.
I recently tried the following in R 2.5.1 on Windows XP:
>ev2<-c(0.8,-0.6)
>ev1<-c(0.6,0.8)
>ev1%*%ev2
[,1]
[1,] -2.664427e-17
>sum(ev1*ev2)
[1] 0
>
(I got the same result with R 2.4.1 on a different Windows XP machine.)
I expect this issue is very familiar and probably has been discussed in this
forum before. Can someone please point me to some
2006 Nov 22
3
odd behaviour of %%?
Dear R Helpers,
I am trying to extract the modulus from divisions by a sequence of
fractions.
I noticed that %% seems to behave inconsistently (to my untutored eye),
thus:
> 0.1%%0.1
[1] 0
> 0.2%%0.1
[1] 0
> 0.3%%0.1
[1] 0.1
> 0.4%%0.1
[1] 0
> 0.5%%0.1
[1] 0.1
> 0.6%%0.1
[1] 0.1
> 0.7%%0.1
[1] 0.1
> 0.8%%0.1
[1] 0
> 0.9%%0.1
The modulus for 0.1, 0.2, 0.4 and 0.8 is
2004 Mar 19
1
lme: simulate.lme in R
The goal: simulate chi square mixture distributions as a way of
simulating likelihood ratio test statistics for some mixed models where
the more specific model has some zero variance components (a la Pinheiro
and Bates pg. 84-87)
The problem: R doesn't have the function ms which is apparently used by
simulate.lme
In the current version of nlme for R, is there a way around this? Is it
2004 Mar 18
1
two lme questions
1) I have the following data situation:
96 plots
12 varieties
2 time points
2 technical treatments
the experiment is arranged as follows:
a single plot has two varieties tested on it. if variety A on plot #1 has
treatment T1 applied to it, then variety B on plot #1 has treatment T2
applied to it. across the whole experiment variety A is exposed to
treatment T1 the same number of times as
2007 Apr 19
2
erratic behavior of match()?
Consider the code:
x <- seq(0,1,0.2)
y <- seq(0,1,0.01)
cbind(match(y,x),y)
which, surprisingly, doesn't show a match at 0.6! (It gives correct
matches at 0, 0.2, 0.4, 0.8 and 1, though)
In addition,
x[4]==y[61]
yields FALSE. (but x[5]==y[81], the one for 0.8, yields TRUE)
Is this a consequence of machine error or something else?
Could this be overcome? (It works correctly when
2010 Aug 18
2
functions and multiple levels
Hi,
I am trying to write a function;
I want to subtract the mean of each class in level 2 from the mean of each
class in level 1 and square the answer, eg.....
level.1 level.2 observation
1 1 0.5
1 1 0.2
1 2 0.6
1 2 0.4
2 3
2010 Jun 29
2
how to remove "numeric(0)" component from a list
like this, the list is below, I want to remove the last one . not using
newlist[-2], but using the function detect its component is numeric(0) and
then remove it from the list.
newlist
[[1]]
[1] 2 3
[[2]]
[1] numeric(0)
[[3]]
[1] 7
[[alternative HTML version deleted]]
2004 Feb 07
1
display functions in groupedData and lme
I'm trying to set up a mixed model to solve using lme. It will have 3
fixed effects, two random effects and two interaction terms.
I've been reading Pinheiro's and Bates's book on the nmle library, but
find the part about display functions to be unclear. When creating a
groupedData object from a data.frame, you need to enter a function of the
form: response ~primary|grouping
2006 Jul 27
1
seq unexpected behavior
seq(0.1, 0.9 - 0.8, by = 0.1) gives the following error message:
Error in seq.default(0.1, 0.9 - 0.8, by = 0.1) :
wrong sign in 'by' argument
but seq(0.1, 0.8 - 0.7, by = 0.1) gives
[1] 0.1
(no error message)
Why do I get an error message in the first case?
Han
> sessionInfo()
R version 2.2.1, 2005-12-20, i386-pc-mingw32
attached base packages:
[1] "methods"
2009 Feb 24
3
invalid comparison in numeric sequence (PR#13551)
Full_Name: alex
Version: 2.8.1
OS: Ubuntu / MacOSX
Submission from: (NULL) (162.38.183.51)
> 0.6==0.6
[1] TRUE
> seq(0,1,0.1)==0.4
[1] FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE
> seq(0,1,0.1)==0.6
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
> seq(0,1,0.1)==0.8
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE
2010 Jul 01
5
identifying odd or even number
Hi, I run into problem when writing a syntax, I don't know syntax that will return true or false if an integer is odd or even.
Thanks
OYEYEMI, Gafar Matanmi
Department of Statistics
University of Ilorin
P.M.B 1515
Ilorin, Kwara State
Nigeria
Tel: +2348052278655
Tel: +2348068241885
[[alternative HTML version deleted]]
2007 Oct 23
1
Strange dataframe behavior
Hello,
I have a question regarding the following output:
> database <- read.delim(file=path.input.file, header=TRUE, dec=".", sep="\t", na.strings = "#NV")
> str(database)
'data.frame': 314 obs. of 13 variables:
$ S : Factor w/ 314 levels "307073","400212",..: 147 72 299 137
162 62 189 236 134 307 ...
$ A : Factor
2012 Apr 30
2
Generate Dendrogram
Hi
I have a distance matrix which is computed by user defined method. I
would like to plot the dendrogram. I would like to use different color
and want the leaves laying down bottom.
The script like this. I am not familiar with R. I followed the example
shown in
http://stat.ethz.ch/R-manual/R-devel/library/stats/html/dendrogram.html
dist.obj <- as.dist(matrix.distance)
hc.obj <-
2008 Jan 07
2
How should I improve the following R code?
I'm looking for a way to improve code that's proven to be inefficient.
Suppose that a data source generates the following table every minute:
Index Count
------------
0 234
1 120
7 11
30 1
I save the tables in the following CSV format:
time,index,count
0,0:1:7:30,234:120:11:1
1,0:2:3:19,199:110:87:9
That is, each line represents a table, and I
2013 Mar 18
4
!0 + !0 == !0 - !0
Hi all,
The subject line is TRUE.
Today I accidentally typed rnorm(!0).
My old eyes took a minute to focus clearly enough to see what I really typed and
why I got '!0' random numbers instead of '10' random normal numbers.
If the subject line is disturbing, be assured that this is TRUE:
!0^2 == !0 * !0 # ;-)
Anyway, I hope the hands who have been around long enough to know
2008 Jan 18
1
Selecting rows conditionally between 2 data.frames
Hello everyone,
I have two data.frames that look like
calib:
place zoom scale
left 0.65 8
left 0.80 5.6
left 1.20 3
right 0.65 8.4
right 0.80 6
right 1.20 2.9
X:
... place zoom ....
... left 0.80 ....
... left 1.20 ....
... right 0.65 ....
... NA NA ....
... right 0.8 ....
... left 1.20 ....
and I want to get the corresponding values of 'scale' in a new column
2012 Jan 13
4
Averaging within a range of values
Hello all.
I have two data frames.
Group Start End
G1 200 700
G2 500 1000
G3 2000 3000
G4 4000 6000
G5 7000 8000
and
Pos C0 C1
200 0.9 0.6
500 0.8 0.8
800 0.9 0.7
1000 0.7 0.6
2000 0.6 0.4
2500 1.2 0.8
2012 Mar 01
4
problem with sum function
Hi!
I'm running R version 2.13.0 (2011-04-13)
Platform: i386-pc-mingw32/i386 (32-bit)
When i type in the command:
sum(c(-0.2, 0.8, 0.8, -3.2, 1.8))
R returns the value:
-5.551115e-17
Why doesn't R return zero in this case? There shouldn't be any rounding
error in a simple sum.
Thanks,
Mark