Displaying 20 results from an estimated 1000 matches similar to: "Prevent sequential repeated values in data frame column"
2008 Nov 25
1
Strange seq() behavior
Hi,
This is really strange. Can anyone help explain what's going on here
(on 3 and 7)?
> targets <- seq(from=.1, to=.9, by=.1)
> targets[1]==.1
[1] TRUE
> targets[2]==.2
[1] TRUE
> targets[3]==.3
[1] FALSE
> targets[4]==.4
[1] TRUE
> targets[5]==.5
[1] TRUE
> targets[6]==.6
[1] TRUE
> targets[7]==.7
[1] FALSE
> targets[8]==.8
[1] TRUE
>
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),
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 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 <-
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:
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
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
2005 Nov 09
2
help with legacy R code
Hi there,
Could somebody help me disect this legacy R script I inherited at work, I
have two questions:
1. I've tried to upgrade our R version from 1.6.2 (yeah, I know), to R 2.0,
but some of the lines in this script are not compatible with R 2.0, could
someone help me figure out where the problem is?
2. the jpeg generated (attached) seems to be off on some of the data, is
there a better way
2008 Apr 21
1
Labelling a secondary axis in R
Hello,
How can I label a secondary axis in R? At the moment it's labelled as
c(-100,200). Obviously I would like it to be more sensible.
Here is the code I am using
newx = -100+37.5*((1:9)-1)
axis(4,at=newx,labels=(newx+100)/3750)
Thanks,
Rob
--
View this message in context: http://www.nabble.com/Labelling-a-secondary-axis-in-R-tp16807708p16807708.html
Sent from the R help mailing list
2010 Mar 27
5
producing a QQ plot.
Hello everyone I'm a beginner in Stats and R, I'm using R 2.10.1. I need to
create a multivariate qq plot, there is 8 variable group with each has 55
number of input. An example of what I did so far, just to get my point out:
> data=read.csv(file.choose(),header=T)
> data
country village group av_expen P2ary_ed no_fisher
1 Cook Islands Aitutaki D
2007 May 09
1
predict.tree
I have a classification tree model similar to the following (slightly
simplified here):
> treemod<-tree(y~x)
where y is a factor and x is a matrix of numeric predictors. They have
dimensions:
> length(y)
[1] 1163
> dim(x)
[1] 1163 75
I?ve evaluated the tree model and am happy with the fit. I also have a
matrix of cases that I want to use the tree model to classify. Call it
2005 May 06
4
Choices from a matrix
Could someone please suggest a more clever solution to the following problem than my loop below?
Given X a 2xN matrix X, and I a k-subset of N,
Generate the (2^k)xN matrix Y with columns not in I all zero and the other columns with all choices of an entry from the first or second row of X.
For example, with
X <- matrix(1:8, nrow=2)
I <- c(1,3)
X is
1 3 5 7
2 4 6 8
and Y should be
1 0 5
2009 Sep 01
1
understanding the output from gls
I'd like to compare two models which were fitted using gls, however I'm
having trouble interpreting the results of gls. If any of you could offer
me some advice, I'd greatly appreciate it.
Short explanation of models: These two models have the same fixed-effects
structure (two independent, linear effects), and differ only in that the
second model includes a corExp structure for
2012 Mar 12
1
2 images on one plot
Dear all
with image I can plot only one set of values in one plot.
Do somebody have any insight how to put those 2 matrices into one picture
so that in one cell in image picture are both values from mat[1,1] and
mat2[1,1].
mat<-matrix(1:4, 2,2)
mat2<-matrix(4:1,2,2)
x <-1:2
y <-1:2
image(x, y, mat)
image(x, y, mat2)
The only way I found is to mix x or y for both matrices let
2009 Mar 21
2
limiting simulated animal movement
Hi,
I am trying to simulate animal movement in a gridded landscape made up of
cells. At each time step (iteration), the animal moves from one cell to
another in a random fashion.
This is how I am simulating movement, where a and b are the x,y co-ordinates
of the animal at the previous time step:
for (i in 1:no.of.steps){
direction <- sample(1:8, 1)
if(direction == 1){
a <- a
b <- b -
2010 Jul 29
1
Using 'dimname names' in aperm() and apply()
I think that the "dimname names" of tables and arrays could make
aperm() and apply() (and probably some other functions) easier to use.
(dimname names are, for example, created by table() )
The use would be something like:
--
x <-table( from=sample(3,100,rep=T), to=sample(5,100,rep=T))
trans <- x / apply(x,"from",sum)
y <- aperm( trans,
2006 Sep 28
2
safe prediction from lm
I am fitting a regression model with a bs term and then making predictions
based on the model. According to some info on the internet at
http://www.stat.auckland.ac.nz/~yee/smartpred/DummiesGuide.txt
there are some problems with using predict.lm when you have a model with
terms such as bs,ns,or poly. However when I used one of the examples they
said would illustrate the problems I get virtually
2010 Feb 06
1
duplicating records
Dear friends,
I need to fill in (duplicate the whole record) the missing days with the
same record values as long as AE is the same value (i.e. "1"), once AE
value changes, the process of duplication should proceed with the new AE
value till it changes again. e.g. I need to fill in records: day 18-day
44, all the records are carried with the new AE value of "0".
At the