Displaying 20 results from an estimated 6000 matches similar to: "Create matrices for time series"
2011 Jun 02
2
Counting occurrences in a moving window
Hi list, based on the following data.frame I would like to create a variable
that indicates the number of occurrences of A in the 3 years prior to the
current year:
DF = data.frame(read.table(textConnection(" A B
8025 1995
8026 1995
8029 1995
8026 1996
8025 1997
8026 1997
8025 1997
8027 1997
8026 1999
8027 1999
8028 1995
8029 1998
8025 1997
8027 1997
8026 1999
8027 1999
2011 Aug 22
1
Selecting cases from matrices stored in lists
Hi,
I have two lists (c and h - see below) containing matrices with similar
cases but different values. I want to split these matrices into multiple
matrices based on the values in h. So, I did the following:
years<-c(1997:1999)
for (t in 1:length(years))
{
year=as.character(years[t])
h[[year]]<-sapply(colnames(h[[year]]), function(var)
2011 Apr 29
4
For loop and sqldf
Hi list,
Can anyone tell my why the following does not work? Thanks a lot! Your help
is very much appreciated.
DF = data.frame(read.table(textConnection(" B C D E F G
8025 1995 0 4 1 2
8025 1997 1 1 3 4
8026 1995 0 7 0 0
8026 1996 1 2 3 0
8026 1997 1 2 3 1
8026 1998 6 0 0 4
8026 1999 3 7 0 3
8027 1997 1 2 3 9
8027 1998 1 2 3 1
8027 1999
2011 Aug 25
3
Selections in lists
Hi,
I have produced a list g and I would like to reduce the amount of
information contained in each object in g.
For each matrix I would like to keep the values where the column name equals
g[year][[1]][[x]] and the row names equals g[year][[1]][[-x]]. So in
g$`1999`$`8029`, year = 1999 and x = 8029. I have been experimenting with
the subset function, but have been unsuccesful. Thanks for your
2011 Aug 15
1
Selecting section of matrix
Hi,
I have a question concerning the selection of data. Let's say that given
list h created below, I would like to select a section of the 1999 matrix.
For a case (rownames and colnames) I would like to select the cells that
have a value > 0. So for case 8025
8025 8026 8027
8025 1 1 1
8026 1 1 1
8027 1 1 1
And for case 8028
8028 8029
8028 1
2011 May 26
1
Divide matrix into multiple smaller matrices
Hi list,
Using the script below, I have generated two lists (c and h) containing
yearly matrices. Now I would like to divide the matrices in c into multiple
matrices based on h. The number of matrices should be equal to:
length(unique(DF1$B))*length(h). So each unique value in DF1$B get's a
yearly matrix. Each matrix should contain all values from c where element
cij is 1. An example for
2011 Jun 14
1
Multiply list objects
Hi,
I am trying to use the objects from the list below to create more objects.
For each year in h I am trying to create as many objects as there are B's
keeping only the values of B. Example for 1999:
$`1999`$`8025`
B
B 8025 8026 8027 8028 8029
8025 1 1 1 0 0
8026 1 0 0 0 0
8027 1 0 0 0 0
8028 0 0 0 0 0
8029
2011 Apr 09
5
Yearly aggregates and matrices
Hi,
I need to perform calculations on subsets of a data frame:
DF = data.frame(read.table(textConnection(" A B C D E F
1 a 1995 0 4 1
2 a 1997 1 1 3
3 b 1995 3 7 0
4 b 1996 1 2 3
5 b 1997 1 2 3
6 b 1998 6 0 0
7 b 1999 3 7 0
8 c 1997 1 2 3
9 c 1998 1 2 3
10 c 1999 6 0 0
11 d 1999 3 7 0
12 e 1995 1 2 3
13 e 1998 1 2 3
14 e 1999 6
2011 Mar 10
1
Moving window per group
Hi,
I have a data.frame of the following type:
F = data.frame(read.table(textConnection(" A B
1 1 4
2 1 3
3 1 1
4 1 4
5 1 2
6 1 2
7 1 2
8 2 1
9 2 1
10 2 1
11 2 1
12 3 2
13 3 4
14 3 1
15 3 1
16 3 1"),head=TRUE,stringsAsFactors=FALSE))
F
A B
1 1 4
2 1 3
3 1 1
4 1 4
5 1 2
6 1 2
7 1 2
8 2 1
9 2 1
10 2 1
11 2 1
12 3 2
13 3 4
14 3 1
15 3 1
16 3 1
2007 Nov 30
1
rollapply on zoo object
Dear R users.
I have zoo object "size_june" containing market-capital values:
> dim(size_june) # market-cap data of 625 firms for 20 years
[1] 20 625
> class(size_june)
[1] "zoo"
> size_june # colnames = "size.firmcode"
size.34020 size.4710 size.11050 size.10660 size.9540 size.8060
size.16160 size.8080 size.9280
1988-06-30 NA
2020 Oct 06
2
Version controlled (git) Maildir generated by Dovecot
Hi Everybody,
I'd like to start archiving e-mails by moving them to a server with running Dovecot.
I installed "dovecot-core" and "dovecot-imapd" (version 2.3.4.1) on Debian 10.
One of a few configurations I made is to use Maildir:
# grep '^mail_location = ' /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:~/Maildir
I successfully moved some e-mails (at
2003 Feb 06
4
Lost writes upon disk power failure
Hi,
I'm encountering a strange situation.
I'm writing to an ext3 filesystem mounted like this:
/dev/scsi/host2/bus0/target0/lun0/part3 on /tmp/volumes/md0 type ext3 (rw,noatime,data=ordered)
with the physical device being a FC-connected RAID (IBM DF4000)
no software raid personality is used
I'm using 2.4.18-19.7
My test program writes files in a loop, with the essential system
2012 Nov 01
7
Reduce(paste, x) question
I have a question about the Reduce function:
x <- list()
x[[1]] <- LETTERS[1:5]
x[[2]] <- LETTERS[11:15]
Reduce(paste, x)
[1] "A K" "B L" "C M" "D N" "E O"
How do I get this?:
[1] "A" "K"
[2] "B" "L"
[3] "C" "M"
[4] "D" "N"
[5] "E" "O"
2009 Mar 23
1
performance: zoo's rollapply() vs inline
zoo's rollapply() function appears to be extremely useful for plugging in a
function on-the-fly to run over a window. With inline, there is a lot more
coding and room for error, and the code is less portable because the user
has to have R compiling set up or it won't work.
However, rollapply() seems to be really slow. Several orders of magnitude
slower than inline, in fact. I don't
2010 Jan 13
1
Rollapply
Hi
I would like to understand how to extend the function (FUN) I am using in
rollapply below.
######################################
With the following simplified data, test1 yields parameters for a rolling
regression
data = data.frame(Xvar=c(70.67,70.54,69.87,69.51,70.69,72.66,72.65,73.36),
Yvar =c(78.01,77.07,77.35,76.72,77.49,78.70,77.78,79.58))
data.z = zoo(d)
test1 =
2011 Aug 12
2
rollapply.zoo() with na.rm=TRUE
Hi.
I'm comparing output from rollapply.zoo, as produced by two versions
of R and package zoo. I'm illustrating with an example from a R-help
posting 'Zoo - bug ???' dated 2010-07-13.
My question is not about the first version, or the questions raised in
that posting, because the behaviour is as documented. I'm puzzled as
to why na.rm no longer is passed to mean, i.e. why
2006 Nov 23
1
how to loop this?
Hi,
I have the next procedure:
t1<-data.frame(table(substr(names(subset(lasker[[1]], lasker[[1]] >=
4)), 1, 7)))
t1[1:5,]
Var1 Freq
1 1988-02 3
2 1988-03 1
3 1988-04 1
4 1988-05 2
5 1988-06 3
How to make a new list?, dataframe? having 189 elements in the 'lasker'
list:
> str(lasker[[1]])
'table' int [, 1:1274] 1 1 3 2 1 5 4 1 1 4 ...
-
2008 Jul 31
1
rollapply() to portions of a matrix
Hi everyone,
I have a rollapply statement that applies a function, in steps, over a data
matrix as follows:
#Code start
testm<-rollapply(mat, 100, by=100, min, na.rm=F)
#Code end
This moves down matrix 'mat' and calculates the minimum value over a 100 row
range, every 100 rows (i.e. no overlaps). NAs are not removed.
I want to modify this statement somehow so that the rollapply()
2006 Nov 22
3
dataframe manipulation
Hi,
Having a dataframe 'l1' (dput output is below):
>dim(l1)
1274 2
>l1[1:12,]
Var1 Freq
1 1988-01-13 1
2 1988-01-16 1
3 1988-01-20 3
4 1988-01-25 2
5 1988-01-30 1
6 1988-02-01 5
7 1988-02-08 4
8 1988-02-14 1
9 1988-02-16 1
10 1988-02-18 4
11 1988-02-24 2
12 1988-03-04 1
I want to extract the times
2011 Apr 03
1
zoo:rollapply by multiple grouping factors
# Hi there,
# I am trying to apply a function over a moving-window for a large
number of multivariate time-series that are grouped in a nested set of
factors. I have spent a few days searching for solutions with no luck,
so any suggestions are much appreciated.
# The data I have are for the abundance dynamics of multiple species
observed in multiple fixed plots at multiple sites. (I total I