Have you tried using the merge() function? E.g.,
lapply(split(d, d$NAME), function(di)merge(all=TRUE, di,
data.frame(YEAR=seq(min(di$YEAR), max(di$YEAR), by=1
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Fri, Aug 1, 2014 at 8:22 PM, Florian Denzinger
wrote:
> Thank you everyone for your
On Sat, 2 Aug 2014 05:22:26 AM Florian Denzinger wrote:
> Thank you everyone for your help so far.
>
> I am still working on the problem to get a merged new dataframe
which fills
> in new rows with NA values for each year that is missing for plotting
with
> gaps ( in the example the item BARTLEY
Thank you everyone for your help so far.
I am still working on the problem to get a merged new dataframe which fills in
new rows with NA values for each year that is missing for plotting with gaps (
in the example the item BARTLEY: years 1984 to 1987 should be filled with a row
containing NA v
Hi
Maybe others will disagree but I find for cycle for this type of task better
than sapply.
for(i in 1:length(ind)) {
if (there are more than 3 date items*) {
postscript(ind[i])
do all plotting
dev.off()
}}
If you want to plot with gaps you need to add all relevant YEARs for x axis
with mis
Even better is to replace
for(i in 1:length(something)) {}
with
for(i in seq_along(something)) {}
The former gives you 2 iterations, the 2nd probably causing an error,
when length(something) is 0. The latter always gives one iteration
per element of 'something'.
Bill Dunlap
TIBCO Softwar
The range vector is evaluated at the start of the loop, so it is only evaluated
once. ind.length would be an unnecessary extra variable.
---
Jeff NewmillerThe . . Go Live...
DCN:
While youre at it, assign length(ind) to a variable before starting the loop.
Otherwise length() is called at each iteration. e.g.,
ind.length <- length(ind)
for (i in 1:ind.length) {
etc.
On Jul 31, 2014, at 10:57 AM, David L Carlson wrote:
> This is one of those times when you would do b
This is one of those times when you would do better to just use a loop. It will
be easier to debug and to see what is going on. Replace the sapply() call with
for (i in 1:length(ind)) {
postscript(names(ind[i]))
par(mar=c(6,8,6,5), cex=0.8)
plot(ind[[i]][,c('YEAR','VA
8 matches
Mail list logo