Displaying 20 results from an estimated 10000 matches similar to: "changing the x axis labels in a time series plot"
2009 Aug 10
4
problem selecting rows meeting a criterion
When I try to select only those rows from the following data frame, called
"data", in which X > Y
X Y V3
2 2 1 8.062258
3 3 1 2.236068
4 4 1 6.324555
5 5 1 5.000000
6 1 2 8.062258
8 3 2 9.486833
9 4 2 2.236068
10 5 2 5.656854
11 1 3 2.236068
12 2 3 9.486833
14 4 3 8.062258
15 5 3 5.099020
16 1 4 6.324555
17 2 4 2.236068
18 3 4 8.062258
20 5 4 5.385165
21 1 5 5.000000
2005 Jun 02
1
Wishlist: more flexible handling of tick labels in axis.Date (PR#7913)
Full_Name: Gavin Simpson
Version: 2.1.0-patched (1-Jun-2005)
OS: Linux (Fedora Core 3)
Submission from: (NULL) (128.40.32.76)
axis.Date() insists on labelling tick marks. It could be made more flexible by
allowing the user to specify if they want the ticks to be labelled, for example,
to add un-labelled minor ticks for "months", added to a plot with "years"
labelled. The user
2007 Oct 25
1
Strange behavior with time-series x-axis
I recently called plot(x,y) where x was an array of POSIXct timestamps,
and was pleasantly surprised that it produced a nice plot right out of
the box:
z <- as.POSIXct(c("2006-10-26 08:00:00 EDT","2007-10-25 12:00:00 EDT"))
x <- seq(z[1],z[2],len=100)
y <- 1:100
plot(x,y,type="l")
The X axis had nice labels, one tick mark every other month. (Plotting
on
2010 Jul 09
2
nls error regarding numerics vs logicals
I am trying to perform an nls for a valid negative exponential function:
zz=nls(y~constant+a.est*2.7183^(b.est*x),start=list(constant=4.0,a.est=-4,b.est
= -.005),trace=T)
and am getting a number of different error messages, the most problematic
of which is "Error in nls(ring.area ~ constant + a.est * 2.7183^(b.est *
ba.beg), start = list(constant = 4, :
REAL() can only be applied to a
2010 May 06
2
splitting character strings and converting to numeric vectors
This seemingly should be quite simple but I can't solve it:
I have a long character vector of geographic data (data frame column named
"XY") whose elements vary in length (from 11 to 14 chars). Each element is
structured as a set of digits, then an underscore, then more digits, e.g:
> data.frame(head(as.character(XY)))
head.as.character.XY..
1 -448623_854854
2
2010 May 12
1
removing duplicate rows
I'm trying to identify and remove rows in a data frame that are duplicated
only on particular columns within it (i.e. not on all columns). The
"unique" function looks for uniqueness across all columns of a data frame.
Identifying unique rows based only on specific columns of interest returns
only those columns, not all of the columns in the original frame. I tried
this, and then
2006 Aug 31
2
cumulative growth rates indexed to a common starting point over n series of observations
What is the R way of computing cumulative growth rates given a series of
discrete values indexed .
For instance, given a matrix of 20 observations for each of 5 series (zz),
what is the most straight forward technique in R for computing cumulative
growth (zzcum) ?
It seems for the solution I'm after might be imbedding the following cum
growth rate calc as a function into a function call
2009 Jul 23
5
error message: .Random.seed is not an integer vector but of type 'list'
I'm trying to run this simple random sample procedure and keep getting the
error message shown. I don't understand this; I've designated x as a
numeric vector, so what is going on here? Thanks.
> x = as.vector(c(1:12));x
[1] 1 2 3 4 5 6 7 8 9 10 11 12
> mode(x)
[1] "numeric"
> sample(x, 3)
Error in sample(x, 3) :
.Random.seed is not an integer vector
2009 Mar 04
2
adding value labels on Interaction Plot
Hello - and sorry for what might look like a simple graphics question.
I am building an interaction plot for d:
d=data.frame(xx=c(3,3,2,2,1,1),yy=c(4,3,4,3,4,3),zz=c(5.1,4.4,3.5,3.3,-1.1,-1.3))
d[[1]]<-as.factor(d[[1]])
d[[2]]<-as.factor(d[[2]])
print(d)
interaction.plot(d$xx, d$yy, d$zz,
type="b", col=c("red","blue"), legend=F,
lty=c(1,2), lwd=2,
2009 Mar 04
2
patch for axis.POSIXct (related to timezones)
I am finding that axis.POSIXct uses the local timezone for deciding where to
put tic marks, even if the data being plotted are in another time zone. The
solution is to use attr() to copy from the 'x' (provided as an argument) to
the 'z' (used for the 'at' locations).
I have pasted my proposed solution in section 1 below (as a diff). Then, in
section 2, I'll put some
2010 Jul 07
3
quantiles on rows of a matrix
I'm trying to obtain the mean of the middle 95% of the values from each row
of a matrix (that is, the highest and lowest 2.5% of values in each row
are removed before calculating the mean). I am having all sorts of
problems with this; for example the command:
apply(matrix1,1,function(x) quantile(c(.05,.90),na.rm=T))
returns the exact same quantile values for each row, which is clearly
2009 Jun 03
1
insert and count missing data
Hi R-users,
I have missing data for the month. My question is how do I insert the missing month and fill up the cell with 'na' for the rain amount? Then I would like to count the percentage of missing data.
No Year month rain
1398 1985 10 104.2
1399 1985 11 138.0
1400 1985 12 120.4
1401 1986 1 12.6
1402 1986 2 19.4
1403 1986 3 1.0
1404 1986 4 58.8
2009 Oct 09
2
different time series in one plot
Hello,
I need to put 2 or more different time series to one plot for comparison
each other. The problem is that the time series are irregular, moreover
the time lenghts and periods are not the same. Is there a way to manage
it in R?
Many thanks for any hint and advice in advance
Tomas
2009 Jul 23
5
Random # generator accuracy
Dan Nordlund wrote:
"It would be necessary to see the code for your 'brief test' before anyone
could meaningfully comment on your results. But your results for a single
test could have been a valid "random" result."
I've re-created what I did below. The problem appears to be with the
weighting process: the unweighted sample came out much closer to the actual
2011 Oct 24
3
extract the p value
OK, what is the trick to extracting the overall p value from an lm object?
It shows up in the summary(lm(model)) output but I can't seem to extract it:
> test2 = apply(aa, 1, function(x) summary(lm(x[,1] ~ 0 + x[,3] + x[,6])))
> test2[[1]]
Call:
lm(formula = x[, 1] ~ 0 + x[, 3] + x[, 6])
[omitted summary output]
F-statistic: 40.94 on 2 and 7 DF, p-value: 0.0001371
It does not seem
2011 Sep 23
2
converting object elements to variable names and making subsequent assignments thereto
This has got to be incredibly simple but I nevertheless can't figure it out
as I am apparently brain dead.
I just want to convert the elements of a character vector to variable names,
so as to then assign formulas to them, e.g:
z = c("model1","model2"); I want to assign formulas, such as lm(y~x[,1]) and
lm(y~x[,2]), to the variables "model1" and
2009 Nov 21
7
consecutive numbering of elements in a matrix
Within a very large matrix composed of a mix of values and NAs, e.g, matrix A:
[,1] [,2] [,3]
[1,] 1 NA NA
[2,] 3 NA NA
[3,] 3 10 17
[4,] 4 12 18
[5,] 6 16 19
[6,] 6 22 20
[7,] 5 11 NA
I need to be able to consecutively number, in new columns, the non-NA
values within each column (i.e. A[1,1] A[3,2] and A[3,3] would all be set
to one, and
2010 Dec 26
2
object names from character strings
I realize this is probably pretty basic but I can't figure it out.
I'm looping through an array, doing various calculations and producing a
resulting data frame in each loop iteration. I need to give each data
frame a different name. Although I can easily create a new character
string for writing each frame to an output file, I cannot figure out how
to convert such strings to
2005 Jun 02
1
Wishlist: more flexible handling of tick labels in axis.Date (PR#7914)
I think allowing the user to change the labels is a good idea, but have
some nitpicking about the details.
- Could you grab a copy of the current axis.Date source from
https://svn.r-project.org/R/trunk/src/library/graphics/R/datetime.R
and edit that, rather than what you see in R? There are some comments
in the source that shouldn't be lost. This will also mean that it's
easier to
2010 Mar 11
3
NAs and row/column calculations
I continue to have great frustrations with NA values--in particular making
summary calculations on rows or cols of a matrix containing them. For
example, why does:
> a = matrix(1:30,nrow=5)
> is.na(a[c(1:2),c(3:4)]);a
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 1 6 NA NA 21 26
[2,] 2 7 NA NA 22 27
[3,] 3 8 13 18 23 28
[4,] 4 9 14 19 24 29