similar to: Strange seq() behavior

Displaying 20 results from an estimated 1000 matches similar to: "Strange seq() behavior"

2009 Aug 11
1
Prevent sequential repeated values in data frame column
Hi, I'm trying to randomize a sequence of trials for an experimental design. The trials consist of values for each of two factors. As is there are 30 combinations of the two factors, and I want them to be ordered randomly but with the requirement that for one of the factors, the value can never be the same as the previous value. I'm currently randomizing my dataframe by using:
2011 Nov 09
2
plot separate groups with plotmeans()
Hi, I often use plotmeans() from the gplots package to quickly visualize a pattern of change. I would like to be able to plot separate lines for different groups, but the function gives an error when a grouping variable is included in the formula argument. For instance, > require(gplots) > x <- data.frame(Score=rnorm(100), Time=rep(1:10, 10),
2010 Apr 21
1
Adding error bars to xyplot()
Hi, I want to add error bars to a plot generated with xyplot. I've tried both errbar() and plotCI(), but in both cases the points are not in the same place. It's as if the two functions are using a different frame of reference for the plotting area. for example: means <- c(92.5, 92.25, 90.9, 91.0, 94.15, 90.05) #means time <- c(1,1,2,2,3,3) #occasion variable group <-
2008 Jul 07
2
A shorter version of ".Last.value"?
Hi, There is an object, ".Last.value" to which the result of the most recent evaluation is assigned. This is similar to "ans" in Matlab. In Matlab "ans" can be very useful and time-saving, but typing the larger R version is somewhat clunky and takes away from the usefulness. Is it possible to reassign '.Last.value' to something simpler, like
2010 Oct 13
4
Change global env variables from within a function
Hi, I've looked all over for a solution to this, but haven't had much look in specifying what I want to do with appropriate search terms. Thus I'm turning to R-help. In the process of trying to write a simple function to rename individual column names in a data frame, I ran into the following problem: When I rename the columns within my function, I can't seem to get it to
2009 Mar 10
1
Nesting order for mixed models
Hello, I am confused about the order of nesting in mixed models using functions like aov(), lme(), lmer(). I have the following data: n subjects in either condition A or B each subject tested at each of 3 numerical values ("distance" = 40,50,60), repeated 4 times for each of the 3 numerical values ("trial" = 1,2,3,4) Variable summary: Condition: 2 level factor Distance:
2012 Apr 24
1
Remove top/right border from lattice plots
Hi, I've done my best to search for a solution to this, but had no luck. How can I create a lattice plot (I'm using xyplot() ) that does not have a border on the top and right side, but keeps the bottom/left axes? So far all I've found is this, which inserted into the xyplot call removes all 4 borders: / par.settings = list(axis.line = list(col = 0))/ xyplot( Sepal.Length ~
2008 Jul 18
1
Functions similar to step() and all.effects() that work for lme() objects?
Hello, I make frequent use of the *step()* and, for plotting, *all.effects() *functions for *lm()* objects. I am now doing more with *lme()* random effects models, and haven't been able to find functions similar to *step()* or *all.effects()* which will accept *lme()* objects. Do similar functions for either exist? If someone could point me in the right direction it would be much
2011 Sep 15
1
Problems with aggregate() function in stats package
Hi, I'm having some problems with the aggregate() function in the {stats} package, and the documentation doesn't address them. 1) Why would the first line work, but the second not? According to the help file, it accepts a "data=" argument. > with(tsrc, aggregate(x=DistRatio, by=list(Condition), FUN=mean)) Group.1 x 1 Congruent 1.741789 2 Mismatch 1.771425
2009 Jun 08
4
seq(...) strange logical value
Do you heve any idea why I get after this instruction everywhere false? > seq (0, 1, by=0.1) == 0.3 [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE But after different step it's ok: > seq(0, 1, by=0.1) == 0.4 [1] FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE -- View this message in context:
2009 Aug 10
3
Bug in "seq" (or a "feature") ?
(I use R 2.9.1 with win XP) If I run this code: seq(-0.1,.9, by = .05)[seq(-0.1,.9, by = .05) <= 0.5] I get this output: [1] -0.10 -0.05 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 Why is 0.50 not in the results ? (It seems that it gives a slightly bigger number then 0.5 but I don't understand why it does that) Where as if I try: seq(-0.1,.9, by = .05)[seq(-0.1,.9, by = .05) <=
2012 Jun 18
6
Inconsistency using seq
Hi all, Is there any problem of precision when using seq?. For example: x<- seq(0,4,0.1) x[4]=0.3 BUT: x[4]-0.3=5.551115e-17 It means when I use this condition within an if clause, it does not find values with 0.3 for x[4] as it is not precisely 0.3. Is there any bug in seq() ? -- View this message in context: http://r.789695.n4.nabble.com/Inconsistency-using-seq-tp4633739.html Sent from
2009 Sep 30
5
Rounding error in seq(...)
Hi, Today I was flabbergasted to see something that looks like a rounding error in the very basic seq function in R. > a = seq(0.1,0.9,by=0.1) > a [1] 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 > a[1] == 0.1 [1] TRUE > a[2] == 0.2 [1] TRUE > a[3] == 0.3 [1] FALSE It turns out that the alternative > a = (1:9)/10 works just fine. Are there any good guides out there on how to deal
2006 Apr 18
3
seq() function accuracy inacceptable (PR#8779)
Full_Name: Johannes Prix Version: 2.1.1 OS: WinXP, SuSE Linux Submission from: (NULL) (137.208.41.195) The seq-command produces unnescessary inaccurate results, which can be extremely annoying. I absolutely do not see the nescessity of numerical garbage to appear in the following simple case. E.g. try this: > seq ( 61.55 , 62.00 , by=0.01 ) - round ( seq ( 61.55 , 62.00 , by=0.01 ) ,
2008 Mar 03
7
help for the first poster- a simple question
Hi, there, I cannot get accurate value for calculation. for example: ld<-sqrt(1*0.05*0.95*0.05*0.95) 0.05*0.95-ld=-6.938894e-18 0.05*0.95-ld==0 is False. I met this problem in my program, how can I handle it. Thanks. xj.
2009 Aug 01
5
incorrect result (41/10-1/10)%%1 (PR#13863)
Full_Name: jan hattendorf Version: 2.9.0 OS: XP Submission from: (NULL) (213.3.108.185) I get an incorrect result for (41/10-1/10)%%1 [1] 1 The error did not occur with other numbers than 41 (1, 11, 21, 31, 51, ...) test <- rep(NA, 1000) for(i in 1:1000){ test[i] <- i/10-1/10 } test[test%%1==0]
2008 Apr 24
2
problem with "which"
Hi, I'm having trouble with the "which" or the "seq" function, I'm not sure. Here's an example : > lat=seq(1,2,by=0.1) > lat [1] 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 > which(lat==1) [1] 1 > which(lat==1.1) [1] 2 > which(lat==1.2) [1] 3 > which(lat==1.3) [1] 4 > which(lat==1.4) [1] 5 > which(lat==1.5) [1] 6 >
2008 Dec 05
3
Logical inconsistency
Dear colleagues Please could someone kindly explain the following inconsistencies I've discovered when performing logical calculations in R: 8.8 - 7.8 > 1 > TRUE 8.3 - 7.3 > 1 > TRUE Thank you, Emma Jane [[alternative HTML version deleted]]
2010 Jul 10
7
Need help on date calculation
Hi all, please see my code: > library(zoo) > a <- as.yearmon("March-2010", "%B-%Y") > b <- as.yearmon("May-2010", "%B-%Y") > > nn <- (b-a)*12 # number of months in between them > nn [1] 2 > as.integer(nn) [1] 1 What is the correct way to find the number of months between "a" and "b", still
2009 Apr 17
3
Modular Arithmetic Error?
Hi, I'm using the '%%' operator in some code, and am running into the following erroneous outcome: > 1.2 %% 0.2 [1] 0.2 Unless I'm very mistaken, the result should be 0 (indeed, 12 %% 2 does result in 0). Furthermore: > 1.20000000000000001 %% 0.2 [1] 0.2 > (1.2+1e17) %% .2 [1] 0 Warning message: probable complete loss of accuracy in modulus (Warning