Re: [R] Different type of legend?

2012-01-31 Thread Kevin Burton
There must be a trick because I am not seeing a legend:

 library(maps)
 library(plotrix)
 colors - grey(0:10/10)
 mo - map('county', projection='polyconic')
 leg.txt - c(-1, 0, 1)
 color.legend(mo$range[1]-1,mo$range[2]-3,mo$range[2]+1,mo$range[2]-2,
+   leg.txt[c(1,length(leg.txt)/2,length(leg.txt))],
+   colors[-1],
+   align='rb',
+
col=colors[-1][c(1,length(colors[-1])/2,length(colors[-1]))])

-Original Message-
From: Jim Lemon [mailto:j...@bitwrit.com.au] 
Sent: Tuesday, January 31, 2012 3:37 AM
To: rkevinbur...@charter.net
Cc: r-help@r-project.org
Subject: Re: [R] Different type of legend?

On 01/31/2012 08:54 AM, rkevinbur...@charter.net wrote:
 Sorry. I am not sure how to post a link. Basically the legend looks like:

 * * * * * * * * * * *
 -4 -3 -2 -1 0 1 2 3 4

 Where ' * ' are colored boxes that are right next to each other. Kind 
 of like a gradient.

Hi Kevin,
The color.legend function (plotrix) might do what you want.

Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Different type of legend?

2012-01-31 Thread Kevin Burton
Sorry this is the commands I am using:

colors - grey(0:10/10));

leg.txt - c(-1, 0, 1)
mo - map('county', projection='polyconic'));
 
color.legend(mo$range[1]-1,mo$range[2]+1,mo$range[3]-3,mo$range[3]-1, +
 
leg.txt[c(1,length(leg.txt)/2,length(leg.txt))],colors[-1],align='rb',col=c
olors[-1][c(1,length(colors[-1])/2,length(colors[-1]))]));

-Original Message-
From: Jim Lemon [mailto:j...@bitwrit.com.au] 
Sent: Tuesday, January 31, 2012 3:37 AM
To: rkevinbur...@charter.net
Cc: r-help@r-project.org
Subject: Re: [R] Different type of legend?

On 01/31/2012 08:54 AM, rkevinbur...@charter.net wrote:
 Sorry. I am not sure how to post a link. Basically the legend looks like:

 * * * * * * * * * * *
 -4 -3 -2 -1 0 1 2 3 4

 Where ' * ' are colored boxes that are right next to each other. Kind 
 of like a gradient.

Hi Kevin,
The color.legend function (plotrix) might do what you want.

Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Different type of legend?

2012-01-31 Thread Kevin Burton
I found the problem. Operator error :(

Thank you.

-Original Message-
From: Kevin Burton [mailto:rkevinbur...@charter.net] 
Sent: Tuesday, January 31, 2012 11:53 AM
To: 'Jim Lemon'
Cc: 'r-help@r-project.org'
Subject: RE: [R] Different type of legend?

Sorry this is the commands I am using:

colors - grey(0:10/10));

leg.txt - c(-1, 0, 1)
mo - map('county', projection='polyconic'));
 
color.legend(mo$range[1]-1,mo$range[2]+1,mo$range[3]-3,mo$range[3]-1, +
 
leg.txt[c(1,length(leg.txt)/2,length(leg.txt))],colors[-1],align='rb',col=c
olors[-1][c(1,length(colors[-1])/2,length(colors[-1]))]));

-Original Message-
From: Jim Lemon [mailto:j...@bitwrit.com.au]
Sent: Tuesday, January 31, 2012 3:37 AM
To: rkevinbur...@charter.net
Cc: r-help@r-project.org
Subject: Re: [R] Different type of legend?

On 01/31/2012 08:54 AM, rkevinbur...@charter.net wrote:
 Sorry. I am not sure how to post a link. Basically the legend looks like:

 * * * * * * * * * * *
 -4 -3 -2 -1 0 1 2 3 4

 Where ' * ' are colored boxes that are right next to each other. Kind 
 of like a gradient.

Hi Kevin,
The color.legend function (plotrix) might do what you want.

Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Interactive map graphics.

2012-01-24 Thread Kevin Burton
I just watched

 

http://www.youtube.com/watch?v=iSXNfZESR5I

 

and there is a section where Hadley Wickham showed demonstrated a county map
of the US that was interactive.  This is exactly what I would like. I have
downloaded ggplot2 but still failed to find out how to even read in and plot
something like a US map let alone add the kind of interactivity that was
shown in this demo. Anyone else succeed at interacting with a plot of the US
like this?

 

Thank you.

 

Kevin


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Interactive map graphics.

2012-01-24 Thread Kevin Burton
I am stuck with R 2.14.0 for now because the COM interface that I am using
(RandFriends) is still on 2.14.0. When I try to install this package (via
the script) I get:

 

packages 'qtbase', 'qtpaint' are not available (for R version 2.14.0)

 

Is there an alternate way to install these packages?

 

From: Tengfei Yin [mailto:yinteng...@gmail.com] 
Sent: Tuesday, January 24, 2012 1:12 PM
To: David Winsemius
Cc: Kevin Burton; r-help@r-project.org
Subject: Re: [R] Interactive map graphics.

 

Hi Kevin,

 

I haven't watched through the video yet, but I guess It's not ggplot2, just
like David pointed out, it's actually using a different graphic engine,
implemented in packages qtbase/qtpaint, which are hosted on Biocondcutor, to
install them, please run

 
 
source(http://www.bioconductor.org/biocLite.R;)
biocLite(c(qtbase, qtpaint))


Another project in development you probably are interested in trying for
same kind of qt-based interactive graphics called cranvas

 

https://github.com/ggobi/cranvas

 

HTH

 

Tengfei

 

 

 

On Tue, Jan 24, 2012 at 12:57 PM, David Winsemius dwinsem...@comcast.net
wrote:


On Jan 24, 2012, at 1:15 PM, Kevin Burton wrote:

I just watched



http://www.youtube.com/watch?v=iSXNfZESR5I



and there is a section where Hadley Wickham showed demonstrated a county map
of the US that was interactive.  This is exactly what I would like. I have
downloaded ggplot2 but still failed to find out how to even read in and plot
something like a US map let alone add the kind of interactivity that was
shown in this demo. Anyone else succeed at interacting with a plot of the US
like this?

 

https://github.com/hadley/vis-migration

   [[alternative HTML version deleted]]


Sigh.

-- 

David Winsemius, MD
West Hartford, CT



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.





 

-- 
Tengfei Yin
MCDB PhD student 
1620 Howe Hall, 2274,
Iowa State University
Ames, IA,50011-2274
Homepage: www.tengfei.name

 

 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Interactive map graphics.

2012-01-24 Thread Kevin Burton
Now I install R 2.14.1 and I get:

 

packages 'qtbase', 'qtpaint' are not available (for R version 2.14.1)

 

Are you saying that the windows binaries are not available for *any* version
of R?

 

From: Tengfei Yin [mailto:yinteng...@gmail.com] 
Sent: Tuesday, January 24, 2012 1:12 PM
To: David Winsemius
Cc: Kevin Burton; r-help@r-project.org
Subject: Re: [R] Interactive map graphics.

 

Hi Kevin,

 

I haven't watched through the video yet, but I guess It's not ggplot2, just
like David pointed out, it's actually using a different graphic engine,
implemented in packages qtbase/qtpaint, which are hosted on Biocondcutor, to
install them, please run

 
 
source(http://www.bioconductor.org/biocLite.R;)
biocLite(c(qtbase, qtpaint))


Another project in development you probably are interested in trying for
same kind of qt-based interactive graphics called cranvas

 

https://github.com/ggobi/cranvas

 

HTH

 

Tengfei

 

 

 

On Tue, Jan 24, 2012 at 12:57 PM, David Winsemius dwinsem...@comcast.net
wrote:


On Jan 24, 2012, at 1:15 PM, Kevin Burton wrote:

I just watched



http://www.youtube.com/watch?v=iSXNfZESR5I



and there is a section where Hadley Wickham showed demonstrated a county map
of the US that was interactive.  This is exactly what I would like. I have
downloaded ggplot2 but still failed to find out how to even read in and plot
something like a US map let alone add the kind of interactivity that was
shown in this demo. Anyone else succeed at interacting with a plot of the US
like this?

 

https://github.com/hadley/vis-migration

   [[alternative HTML version deleted]]


Sigh.

-- 

David Winsemius, MD
West Hartford, CT



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.





 

-- 
Tengfei Yin
MCDB PhD student 
1620 Howe Hall, 2274,
Iowa State University
Ames, IA,50011-2274
Homepage: www.tengfei.name

 

 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Legend that is big?

2012-01-22 Thread Kevin Burton
Thanks for the tip. I will try it out. I am more after a legend of colors than 
readable labels. In fact I would prefer getting rid of the text labels 
altogether.

On Jan 22, 2012, at 12:46 AM, Jim Lemon j...@bitwrit.com.au wrote:

 On 01/22/2012 06:56 AM, Kevin Burton wrote:
 Of course by entering 'blah' you just get a legend of one value. I guess I 
 would like to remove the text altogether and put the colored boxes (or 
 circles) right next to each other. This would form sort of a gradient. So 
 say I needed a legend for 100 colored values on the plot. The colors are 
 generated by:
 colors- rainbow(100)
 How would I make such a legend?
 
 Hi Kevin,
 It sounds like you want something like color.legend (plotrix) that draws a 
 rectangle with as many colors as you like. However 100 colors would probably 
 require a legend as big as one side of the plot, and you certainly couldn't 
 get 100 readable labels on it. More like 10.
 
 Jim
 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Logrithmic histogram?

2012-01-22 Thread Kevin Burton
I have some data where the frequency is heavily weighted on the lower end.
So I have lots of low values with very few higher values. I would like to
find breakpoints that cover the data with as much detail as possible. I find
that if I use hist() to automatically find the breaks for me it finds breaks
that are too coarse for the low values. I have tried the other algorithms
(like 'Scott' and 'FD') but I have been unable to get it to work for me. I
think I need breaks based on the inverse logarithm of the frequency so that
the low values which have a high frequency are more or less evenly
distributed about like the lower frequency high values. Is there a function
to find the breaks like this?

 

Thank you.

 

Kevin


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Legend that is big?

2012-01-21 Thread Kevin Burton
I can put a legend on a plot with something like:

 

legend('bottom', leg.txt, horiz = TRUE, fill = colors)

 

But what if the arrays leg.txt and colors are too big? I would still like to
provide a legend but to save space I would like to just show small boxes
with the color filled in so it will still fit on the plot. If I could adjust
the size of the boxes (at least in one dimension) that would be desirable.
As a bonus and if there is room I would like to label the top and bottom
(left and right) of the legend with text indicating a minimum and maximum. I
am relatively new to 'R' and especially 'R' graphics so any help would be
greatly appreciated.

 

Thank you.

 

Kevin

 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Alaska and Hawaii map data?

2012-01-21 Thread Kevin Burton
I installed 'spatial' and could not see that the package includes data to
map Alaska and Hawaii along with the associated counties .I saw in the demo
for the package 'sp' that county data was read in for the state of North
Carolina but I am unclear where the database containing this information is.
If I were to add the functionality myself I would need to start with some
sort of database that consists of polygons that describe the applicable
counties. Unfortunately I don't have that kind of time. Surely this has been
done before.

Thank you.

-Original Message-
From: Ray Brownrigg [mailto:ray.brownr...@ecs.vuw.ac.nz] 
Sent: Thursday, January 19, 2012 1:55 PM
To: r-help@r-project.org
Cc: Kevin Burton
Subject: Re: [R] Alaska and Hawaii map data?

On Fri, 20 Jan 2012, Kevin Burton wrote:
 I can plot each county of the contiguous 48 states or all of them 
 using variations of
 
 
 
 map('county', region=c('wisconsin' . . . .)
 
 
 
 in the maps package. I was wondering whether similar data was 
 available for Alaska and Hawaii? I was also wondering if there was a 
 database that listed FIPS codes for the counties in Alaska and Hawaii.
Similar to 'county.fips'.
 
None of these is part of the maps package.  Sorry.

The good news is that maps is a *source* package, so if you need new
functionality, you are quite at liberty to add it yourself.

Further, there are other mapping (and more general 'spatial') packages
available, that may provide such functionality.  See the CRAN spatial
taskview at:
http://cran.r-project.org/web/views/Spatial.html

Ray Brownrigg
 
 
 Thank you.
 
 
 
 Kevin Burton
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html and provide commented, 
 minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Legend that is big?

2012-01-21 Thread Kevin Burton
Just any plot but put say 100 items in the legend. If you include text with 
each item it clearly will not fit on any plot. So one workable example would be 
to add a legend with a 100 or more items to your plot of choice.

Thanks for the suggestion.

On Jan 21, 2012, at 10:14 AM, John Kane jrkrid...@yahoo.ca wrote:

 Try something like this:
 
 legend('bottom', leg.txt, horiz = TRUE, cex=.75)
 
 A workable example is requested and would have been helpful.
 
 
 - Original Message -
 From: Kevin Burton rkevinbur...@charter.net
 To: r-help@r-project.org
 Cc: 
 Sent: Saturday, January 21, 2012 8:47:36 AM
 Subject: [R] Legend that is big?
 
 I can put a legend on a plot with something like:
 
 
 
 legend('bottom', leg.txt, horiz = TRUE, fill = colors)
 
 
 
 But what if the arrays leg.txt and colors are too big? I would still like to
 provide a legend but to save space I would like to just show small boxes
 with the color filled in so it will still fit on the plot. If I could adjust
 the size of the boxes (at least in one dimension) that would be desirable.
 As a bonus and if there is room I would like to label the top and bottom
 (left and right) of the legend with text indicating a minimum and maximum. I
 am relatively new to 'R' and especially 'R' graphics so any help would be
 greatly appreciated.
 
 
 
 Thank you.
 
 
 
 Kevin
 
 
 
 
 [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Legend that is big?

2012-01-21 Thread Kevin Burton
Of course by entering 'blah' you just get a legend of one value. I guess I 
would like to remove the text altogether and put the colored boxes (or circles) 
right next to each other. This would form sort of a gradient. So say I needed a 
legend for 100 colored values on the plot. The colors are generated by:
colors - rainbow(100)
How would I make such a legend?
Thanks for the suggestions. They are tricks definitely worth knowing.

On Jan 21, 2012, at 10:16 AM, Uwe Ligges lig...@statistik.tu-dortmund.de 
wrote:

 
 
 On 21.01.2012 14:47, Kevin Burton wrote:
 I can put a legend on a plot with something like:
 
 
 
 legend('bottom', leg.txt, horiz = TRUE, fill = colors)
 
 
 
 But what if the arrays leg.txt and colors are too big? I would still like to
 provide a legend but to save space I would like to just show small boxes
 with the color filled in so it will still fit on the plot.
 
 The trick could be to use filled points that look like boxes:
 
 legend('bottom', blah, horiz = TRUE, pch = 15, col = colors, pt.cex = 0.5)
 
 
 If I could adjust
 the size of the boxes (at least in one dimension) that would be desirable.
 As a bonus and if there is room I would like to label the top and bottom
 (left and right) of the legend with text indicating a minimum and maximum. I
 am relatively new to 'R' and especially 'R' graphics so any help would be
 greatly appreciated.
 
 
 If you save the returned value from legend() inn some object:
 
 lg - legend(..)
 str(lg)
 
 you will see that there is information about the soze and location of the 
 legend that can be used to calculate positions for other text() around
 
 Uwe Ligges
 
 
 
 
 
 
 
 
 Thank you.
 
 
 
 Kevin
 
 
 
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Alaska and Hawaii map data?

2012-01-19 Thread Kevin Burton
I can plot each county of the contiguous 48 states or all of them using
variations of

 

map('county', region=c('wisconsin' . . . .)

 

in the maps package. I was wondering whether similar data was available for
Alaska and Hawaii? I was also wondering if there was a database that listed
FIPS codes for the counties in Alaska and Hawaii. Similar to 'county.fips'. 

 

Thank you.

 

Kevin Burton


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Missing data?

2011-11-27 Thread Kevin Burton
I admit it isnt reality but I was hoping through judicious use of these 
functions I could approximate reality. For example in the years where there are 
more than 53 weeks in a year I would be happy if there were a way to recognize 
this and drop the last week of data. If there were less than 53 I would pad 
the year with an extra dummy week. This is just about the same as your 
suggestion of putting more than 7 days in the first and last weeks. But i still 
need this kind of date manipulation to even know how many days to add in to 
make the approximation viable. This kind of best approximation to reality seems 
better than to settle for the resolution of a month just because it is 
consistent. Daily would be too much data and even then there would be an 
approximation due to leap years.

On Nov 26, 2011, at 3:13 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote:

 On Tue, Nov 22, 2011 at 6:50 PM, Kevin Burton rkevinbur...@charter.net 
 wrote:
 Void of any other suggestions this approach makes sense but for my case I
 think I need to use zoo objects rather than xts. If I sequence the data
 generally I don't know if there will be 365 days in the year or 366. So I
 have to sequence the dates as:
 
 seq(from=as.Date(2011-01-01), to=as.Date(2011-12-31), by=day)
 
 If I use this sequence with xts I get:
 
 ds - xts(NA, seq(from=as.Date(2011-01-01), to=as.Date(2011-12-31),
 by=day))
 Error in xts(NA, seq(from = as.Date(2011-01-01), to =
 as.Date(2011-12-31),  :
  NROW(x) must match length(order.by)
 
 If I leave the 'data' empty I don't get the error but if I try to assign an
 individual item (fill as appropriate)
 
 ds - xts(, seq(from=as.Date(2011-01-01), to=as.Date(2011-12-31),
 by=day))
 ds[2011-12-24] - 10
 ds
 Error in structure(coredata(x), names = x.attr$dimnames[[1]]) :
  'names' attribute [365] must be the same length as the vector [358]
 
 So now I need to remember that I have not filled in all of the data. Also
 simple dereferencing gives:
 
 ds[1]
 Error in `[.xts`(ds, 1) : subscript out of bounds
 
 With zoo I am able to create a time-series where all of the data is
 initially NA:
 
 ds - zoo(NA, seq(from=as.Date(2011-01-01), to=as.Date(2011-12-31),
 by=day))
 
 So I can fill the data as appropriate and the remaining slots will have NA.
 I may be new with xts but I cannot see a way of creating a useable 'blank'
 time-series.
 
 Also with xts it seems like the frequency is ignored.
 
 ds - xts(1:365, seq(from=as.Date(2011-01-01), to=as.Date(2011-12-31),
 by=day), frequency=52)
 frequency(ds)
 [1] 1
 
 Whereas zoo remembers the frequency setting
 
 ds - zoo(1:365, seq(from=as.Date(2011-01-01), to=as.Date(2011-12-31),
 by=day), frequency=52)
 frequency(ds)
 [1] 52
 
 But since the ultimate goal is to get the time-series in a 'ts' format (as
 many functions require 'ts') it seems like even zoo has problems:
 
 The problem is that you seem to want a fixed number of periods per
 year but there is not a constant of 52 weeks nor 365 days in a year.
 You are going to have give up something since your apparent criteria
 conflict with reality.  For example, you could use months in which
 case there are exactly 12 or you could stick more than 7 days into the
 first or last week of the year so that there are exactly 52 weeks in a
 year but they don't all have the same number of days, etc.
 
 -- 
 Statistics  Software Consulting
 GKX Group, GKX Associates Inc.
 tel: 1-877-GKX-GROUP
 email: ggrothendieck at gmail.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Missing data?

2011-11-27 Thread Kevin Burton
I was just trying to be complete. Why is the frequency argument and
attribute available?

-Original Message-
From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com] 
Sent: Saturday, November 26, 2011 2:40 PM
To: Kevin Burton
Cc: r-help@r-project.org
Subject: Re: [R] Missing data?

Why do you need to use a frequency attribute for these data? The point of
the zoo/xts line of time series implementations is that the time stamps are
carried through for each observation (unlike ts) and can be irregular. Both
classes exist precisely to avoid being forced into a frequency attribute.

As far as setting up the time elements, wouldn't this work? Change the start
date to get weeks on any desired day

d - seq.Date(from = as.Date(2011-11-26), by = -7, length.out = 100)
xts(rep(NA, length(d)), d)

You can avoid the OHLC formatting of to.weekly if you want with the OHLC =
FALSE parameter. And if you want to index it by the first of the week rather
htan the last, just try this:

time(x) - time(x) - 6

Michael

On Tue, Nov 22, 2011 at 6:50 PM, Kevin Burton rkevinbur...@charter.net
wrote:
 Void of any other suggestions this approach makes sense but for my 
 case I think I need to use zoo objects rather than xts. If I sequence 
 the data generally I don't know if there will be 365 days in the year 
 or 366. So I have to sequence the dates as:

 seq(from=as.Date(2011-01-01), to=as.Date(2011-12-31), by=day)

 If I use this sequence with xts I get:

 ds - xts(NA, seq(from=as.Date(2011-01-01), 
 to=as.Date(2011-12-31),
 by=day))
 Error in xts(NA, seq(from = as.Date(2011-01-01), to = 
 as.Date(2011-12-31),  :
  NROW(x) must match length(order.by)

 If I leave the 'data' empty I don't get the error but if I try to 
 assign an individual item (fill as appropriate)

 ds - xts(, seq(from=as.Date(2011-01-01), to=as.Date(2011-12-31),
 by=day))
 ds[2011-12-24] - 10
 ds
 Error in structure(coredata(x), names = x.attr$dimnames[[1]]) :
  'names' attribute [365] must be the same length as the vector [358]

 So now I need to remember that I have not filled in all of the data. 
 Also simple dereferencing gives:

 ds[1]
 Error in `[.xts`(ds, 1) : subscript out of bounds

 With zoo I am able to create a time-series where all of the data is 
 initially NA:

 ds - zoo(NA, seq(from=as.Date(2011-01-01), 
 to=as.Date(2011-12-31),
 by=day))

 So I can fill the data as appropriate and the remaining slots will have
NA.
 I may be new with xts but I cannot see a way of creating a useable 'blank'
 time-series.

 Also with xts it seems like the frequency is ignored.

 ds - xts(1:365, seq(from=as.Date(2011-01-01), 
 to=as.Date(2011-12-31),
 by=day), frequency=52)
 frequency(ds)
 [1] 1

 Whereas zoo remembers the frequency setting

 ds - zoo(1:365, seq(from=as.Date(2011-01-01), 
 to=as.Date(2011-12-31),
 by=day), frequency=52)
 frequency(ds)
 [1] 52

 But since the ultimate goal is to get the time-series in a 'ts' format 
 (as many functions require 'ts') it seems like even zoo has problems:

 as.ts(ds)

 Time Series:
 Start = c(14975, 1)
 End = c(15339, 1)
 Frequency = 52
    [1]   1  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  
 NA NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  
 NA  NA NA  NA  NA  NA  NA
   [42]  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA   2  NA  NA  NA  NA  
 NA NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  
 NA  NA NA  NA  NA  NA  NA
   [83]  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  
 NA NA  NA  NA  NA  NA   3  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  
 NA  NA NA  NA  NA  NA  NA
  [124]  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  
 NA NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA   4  
 NA  NA NA  NA  NA  NA  NA
  [165]  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  
 NA NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  
 NA  NA NA  NA  NA  NA  NA
  [206] . . . . . .
  So the conversion from zoo to ts maintained the frequency but I am 
 not sure where it decided on the start and end values. Also the 
 conversion seemed to changed the data also. Notice that every period 
 (52 entries) the original data is maintained. In other words if ds is 
 the original zoo time series then ds[1] is 1 and ds[2] is 2 etc. The 
 converted time-series keeps ds[1] but inserts 51 NA's then adds ds[2] 
 etc till the end of the series.  That is not what the initial data was.
The conversion is inserting data of its own.

 The conversion to ts from xts seems better behaved:

 ds - xts(1:365, seq(from=as.Date(2011-01-01), 
 to=as.Date(2011-12-31), by=day), frequency=52)
 as.ts(ds)
 Time Series:
 Start = 1
 End = 365
 Frequency = 1
  [1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  
 17
 18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  
 36
 37  38  39  40  41  42
  [43]  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  
 59
 60  61

Re: [R] Missing data?

2011-11-27 Thread Kevin Burton
This has been very helpful. Thank you.

At the risk of further confirming my ignorance and taxing your patience I
would like to add another question. How would I modify this code so that
each week starts with the same day of the week regardless of the year? I
would add this stipulation so that for multiple years I always get the same
'week-number' like

 format(as.Date(2011-11-27), %W-%w)
[1] 47-0

The convention (at least for US culture) seems to be that the week starts
with Sunday (it is index 0 for day of week). So it would be convenient if
the code was modified so that each 'week' began on Sunday. The partial at
the beginning would just start with the day of week that was at the start. I
still would want to aggregate that 'week-number's that are greater than 51
like you have shown.

Thanks again.

Kevin
-Original Message-
From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] 
Sent: Sunday, November 27, 2011 4:24 PM
To: Kevin Burton
Cc: r-help@r-project.org
Subject: Re: [R] Missing data?

On Sun, Nov 27, 2011 at 4:08 PM, Kevin Burton rkevinbur...@charter.net
wrote:
 I admit it isnt reality but I was hoping through judicious use of these
functions I could approximate reality. For example in the years where there
are more than 53 weeks in a year I would be happy if there were a way to
recognize this and drop the last week of data. If there were less than 53 I
would pad the year with an extra dummy week. This is just about the same
as your suggestion of putting more than 7 days in the first and last weeks.
But i still need this kind of date manipulation to even know how many days
to add in to make the approximation viable. This kind of best approximation
to reality seems better than to settle for the resolution of a month just
because it is consistent. Daily would be too much data and even then there
would be an approximation due to leap years.


OK. As you are willing to regard days past the 364th as part of the last
week of the year then we can do this.

Create a zoo object z as test data.   Then convert its time scale to
year + week/52 where 0 is the first week of the year and we replace any week
that is greater than 51 with 51.  Then we aggregate z by week taking the
last data point in the week and convert it to ts.  Because of the way we
constructed it the frequency will be 52.

library(zoo)

# test data
z - zoo(1:100, Sys.Date() + 1:100)

yr.wk - with(as.POSIXlt(time(z)), year + 1900 + pmin(yday %/% 7, 51) / 52)
z.wk - aggregate(z, yr.wk, tail, 1) z.ts - as.ts(z.wk)

frequency(z.ts) # 52

--
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Time series merge?

2011-11-26 Thread Kevin Burton
I have two time series

 

a - ts(1:10, start=c(1,6), end=c(2,5), frequency=10)

b - ts(1:5, start=c(2,1), end=c(2,5), frequency=10)

 

Obviously 'b' is a subset of 'a'. I want a single index value indicating
where that start of 'b' lines up with the start of 'a'. So in this simple
example I would expect an index of 5. I was playing with 'merge'. But, for a
'ts' object this does not produce anything that is useful:

 

 merge(a,b)

  x

1 1

2 2

3 3

4 4

5 5

 

I get the same answer if I use 'merge(b,a)' so I don't know how to convert
this result to something useful. So then I decided to use 'xts'. But the
conversion fails:

 

 ax - as.xts(a)

Error in as.xts.ts(a) : could not convert index to appropriate type

 

For this simple example I could code it myself using a simple for loop but
if I add capability to handle missing dates, different frequencies, etc. it
gets complicated very fast.  It seems that 'xts' has more extensive date
handling facilities that 'ts' but I am stuck since it doesn't look like I
can convert from 'ts' to 'xts'. 

 

Thanks in advance for your suggestions.

 

Kevin


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Time series merge?

2011-11-26 Thread Kevin Burton
Seems to work fine. Thank you.

-Original Message-
From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] 
Sent: Saturday, November 26, 2011 10:11 AM
To: Kevin Burton
Cc: r-help@r-project.org
Subject: Re: [R] Time series merge?

On Sat, Nov 26, 2011 at 10:55 AM, Kevin Burton rkevinbur...@charter.net
wrote:
 I have two time series



 a - ts(1:10, start=c(1,6), end=c(2,5), frequency=10)

 b - ts(1:5, start=c(2,1), end=c(2,5), frequency=10)



 Obviously 'b' is a subset of 'a'. I want a single index value 
 indicating where that start of 'b' lines up with the start of 'a'. So 
 in this simple example I would expect an index of 5. I was playing 
 with 'merge'. But, for a 'ts' object this does not produce anything that
is useful:



 merge(a,b)


Try this:

library(zoo)
m - merge(a = as.zoo(a), b = as.zoo(b)) m

or to get a ts object back:

as.ts(m)

--
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Missing data?

2011-11-22 Thread Kevin Burton
I was wondering what the best approach is for missing data in a time series.
I give an example using xts but I would like to know what seems to be the
best method. Say I have

 

library(xts)

xts.ts - xts(1:4,as.Date(c(1970-01-01, 1970-1-3, 1980-10-10,
2007-8-19)), frequency=52)

 

I would like to turn this into a time series (still could be xts, or
converted to ts) that has values for every week starting with the week that
includes the start date and ending with the week that includes the end date.
If there is data for the week then use it otherwise set it to NA or 0.
Remember some years have 52, 53, or rarely 54 full or partial weeks. What to
do with the partials at the beginning and ending of the year? This seems to
be a fairly common problem and doing it myself is very cumbersome. Does a
solution to this kind of problem exist? Once the approach to a weekly period
is found I am sure that adjustment to daily, monthly, or quarterly would be
relatively straightforward.

 

Thank you.

 

Kevin

 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Missing data?

2011-11-22 Thread Kevin Burton
Thank you for the suggestions.

The only problems I see with 'to.weekly' is converting from the OHLC format
and realizing that the date is the last day of the week rather than the
first day of the week. Very minor compared to doing the whole thing myself.

-Original Message-
From: R. Michael Weylandt michael.weyla...@gmail.com
[mailto:michael.weyla...@gmail.com] 
Sent: Tuesday, November 22, 2011 3:10 PM
To: Kevin Burton
Cc: r-help@r-project.org
Subject: Re: [R] Missing data?

Couldn't you use seq.Date() to set up the time index and then just fill as
appropriate?

Alternatively, to.weekly if you are starting with a daily series. 

Michael

On Nov 22, 2011, at 4:00 PM, Kevin Burton rkevinbur...@charter.net
wrote:

 I was wondering what the best approach is for missing data in a time
series.
 I give an example using xts but I would like to know what seems to be 
 the best method. Say I have
 
 
 
 library(xts)
 
 xts.ts - xts(1:4,as.Date(c(1970-01-01, 1970-1-3, 1980-10-10, 
 2007-8-19)), frequency=52)
 
 
 
 I would like to turn this into a time series (still could be xts, or 
 converted to ts) that has values for every week starting with the week 
 that includes the start date and ending with the week that includes the
end date.
 If there is data for the week then use it otherwise set it to NA or 0.
 Remember some years have 52, 53, or rarely 54 full or partial weeks. 
 What to do with the partials at the beginning and ending of the year? 
 This seems to be a fairly common problem and doing it myself is very 
 cumbersome. Does a solution to this kind of problem exist? Once the 
 approach to a weekly period is found I am sure that adjustment to 
 daily, monthly, or quarterly would be relatively straightforward.
 
 
 
 Thank you.
 
 
 
 Kevin
 
 
 
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Missing data?

2011-11-22 Thread Kevin Burton
Also with to.weekly there seems to be a problem with when the week starts.
For example:

xts.ts - xts(1:4, c(as.Date(2011-01-01), as.Date(2011-01-10),
as.Date(2011-10-09), as.Date(2011-10-10)), frequency=52)
 to.weekly(xts.ts)
   xts.ts.Open xts.ts.High xts.ts.Low xts.ts.Close
2011-01-01   1   1  11
2011-01-10   2   2  22
2011-10-09   3   3  33
2011-10-10   4   4  44

 xts.ts - xts(1:4, c(as.Date(2011-01-01), as.Date(2011-01-02),
as.Date(2011-10-09), as.Date(2011-10-10)), frequency=52)
 to.weekly(xts.ts)
   xts.ts.Open xts.ts.High xts.ts.Low xts.ts.Close
2011-01-02   1   2  12
2011-10-09   3   3  33
2011-10-10   4   4  44

So in the first case the week ends on January 1st. But the second indicates
that the end of the week is the 2nd but it includes the data from the first.
I would expect that the first column should be consistent.
Notice that 10-09 and 10-10 are properly considered different weeks because
the 9th is a Sunday and the 10th is a Monday (the beginning of the week).

-Original Message-
From: R. Michael Weylandt michael.weyla...@gmail.com
[mailto:michael.weyla...@gmail.com] 
Sent: Tuesday, November 22, 2011 3:10 PM
To: Kevin Burton
Cc: r-help@r-project.org
Subject: Re: [R] Missing data?

Couldn't you use seq.Date() to set up the time index and then just fill as
appropriate?

Alternatively, to.weekly if you are starting with a daily series. 

Michael

On Nov 22, 2011, at 4:00 PM, Kevin Burton rkevinbur...@charter.net
wrote:

 I was wondering what the best approach is for missing data in a time
series.
 I give an example using xts but I would like to know what seems to be 
 the best method. Say I have
 
 
 
 library(xts)
 
 xts.ts - xts(1:4,as.Date(c(1970-01-01, 1970-1-3, 1980-10-10, 
 2007-8-19)), frequency=52)
 
 
 
 I would like to turn this into a time series (still could be xts, or 
 converted to ts) that has values for every week starting with the week 
 that includes the start date and ending with the week that includes the
end date.
 If there is data for the week then use it otherwise set it to NA or 0.
 Remember some years have 52, 53, or rarely 54 full or partial weeks. 
 What to do with the partials at the beginning and ending of the year? 
 This seems to be a fairly common problem and doing it myself is very 
 cumbersome. Does a solution to this kind of problem exist? Once the 
 approach to a weekly period is found I am sure that adjustment to 
 daily, monthly, or quarterly would be relatively straightforward.
 
 
 
 Thank you.
 
 
 
 Kevin
 
 
 
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Missing data?

2011-11-22 Thread Kevin Burton
 351 352 353
354 355 356 357 358 359 360 361 362 363 364 365

But alas the frequency is ignored.

So this is what I have found out using these two packages.  If I want to
create a 'blank' data set it seems like zoo is 'better' since I can create a
time-series initialized with NA irrespective of the length of the series.
However I must be unfamiliar with the conversion because zoo doesn't convert
to a regular 'ts' very well.  But  zoo remembers the frequency setting
whereas xts just ignores it.

It seems like there is still considerable work to solve the original
problem. If I create a time series and fill in the values that are
appropriate I still could have NA in the series it seems to.weekly has a
problem with NA in the time series:
 ds - xts(rep(NA,365), seq(from=as.Date(2011-01-01),
to=as.Date(2011-12-31), by=day), frequency=52)
 to.weekly(ds, sum)
Error in if (drop.time) x - .drop.time(x) : 
  argument is not interpretable as logical
In addition: Warning message:
In to.period(x, weeks, name = name, ...) :
  missing values removed from data


-Original Message-
From: R. Michael Weylandt michael.weyla...@gmail.com
[mailto:michael.weyla...@gmail.com] 
Sent: Tuesday, November 22, 2011 3:10 PM
To: Kevin Burton
Cc: r-help@r-project.org
Subject: Re: [R] Missing data?

Couldn't you use seq.Date() to set up the time index and then just fill as
appropriate?

Alternatively, to.weekly if you are starting with a daily series. 

Michael

On Nov 22, 2011, at 4:00 PM, Kevin Burton rkevinbur...@charter.net
wrote:

 I was wondering what the best approach is for missing data in a time
series.
 I give an example using xts but I would like to know what seems to be 
 the best method. Say I have
 
 
 
 library(xts)
 
 xts.ts - xts(1:4,as.Date(c(1970-01-01, 1970-1-3, 1980-10-10, 
 2007-8-19)), frequency=52)
 
 
 
 I would like to turn this into a time series (still could be xts, or 
 converted to ts) that has values for every week starting with the week 
 that includes the start date and ending with the week that includes the
end date.
 If there is data for the week then use it otherwise set it to NA or 0.
 Remember some years have 52, 53, or rarely 54 full or partial weeks. 
 What to do with the partials at the beginning and ending of the year? 
 This seems to be a fairly common problem and doing it myself is very 
 cumbersome. Does a solution to this kind of problem exist? Once the 
 approach to a weekly period is found I am sure that adjustment to 
 daily, monthly, or quarterly would be relatively straightforward.
 
 
 
 Thank you.
 
 
 
 Kevin
 
 
 
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] List of lists to data frame?

2011-11-16 Thread Kevin Burton
Say I have the following data:

 s - list()
 s[[A]] - list(name=first, series=ts(rnorm(50), frequency=10,
start=c(2000,1)), category=top)
 s[[B]] - list(name=second, series=ts(rnorm(60), frequency=10,
start=c(2000,2)), category=next)

If I use unlist since this is a list of lists I don't end up with a data
frame. And the number of rows in the data frame should equal the number of
time series entries. In the sample above it would be 110. I would expect
that the name and category strings would be recycled for each row. My brute
force code attempts to build the data frame by appending to the master data
frame but like I said it is *very* slow.

Kevin

-Original Message-
From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com] 
Sent: Wednesday, November 16, 2011 5:26 PM
To: rkevinbur...@charter.net
Cc: r-help@r-project.org
Subject: Re: [R] List of lists to data frame?

unlist(..., recursive = F)

Michael

On Wed, Nov 16, 2011 at 6:20 PM,  rkevinbur...@charter.net wrote:

 I would like to make the following faster:

        df - NULL
        for(i in 1:length(s))
        {
                df - rbind(df, cbind(names(s[i]), time(s[[i]]$series), 
 as.vector(s[[i]]$series), s[[i]]$category))
        }
        names(df) - c(name, time, value, category)
        return(df)

 The s object is a list of lists. It is constructed like:

 s[[object]] - list(. . . . . .)

 where object would be the name associated with this list 
 s[[i]]$series is a 'ts' object and s[[i]]$category is a name.

 Constructing this list is reasonably fast but to do some more 
 processing on the data it would be easier if it were converted to a data
frame.
 Right now the above code is unacceptably slow at converting this list 
 of lists to a data frame. Any suggestions on how to optimize this are 
 welcome.

 Thank you.

 Kevin

        [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Controlling the precision of the digits printed

2011-11-15 Thread Kevin Burton
Has anyone come across the right combinations to print a limited number of
digits? My trial and error approach is taking too much time. Here is what I
have tried:

 

 op - options()

 a - c(1e-10,1,2,3,.5,.25)

 names(a) - c(A, B, C, D, E, F)

 # default

 a

  A   B   C   D   E   F 

1.0e-10 1.0e+00 2.0e+00 3.0e+00 5.0e-01 2.5e-01 

 options(digits = 4, scipen=5)

 # Doesn't print exponents but there are too many trailing digits

 a

   ABCDE
F 

0.01 1.00 2.00 3.00 0.50
0.25 

 

 options(digits = 3, scipen=4)

 # Now we are back to exponents

 a

  A   B   C   D   E   F 

1.0e-10 1.0e+00 2.0e+00 3.0e+00 5.0e-01 2.5e-01 

 

I would like the integers to print as integers (1,2,3). The larger fractions
to print something like .5000 or .2500. And the very small number to use
exponents (1.0e-10)

 

Is this possible?

 

Thank you.

 

Kevin


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Controlling the precision of the digits printed

2011-11-15 Thread Kevin Burton
Thank you. I mainly didn't know about the vector/matrix printing rules. 

Kevin

-Original Message-
From: William Dunlap [mailto:wdun...@tibco.com] 
Sent: Tuesday, November 15, 2011 10:43 AM
To: Kevin Burton; r-help@r-project.org
Subject: RE: [R] Controlling the precision of the digits printed

When you print a vector R uses a single
format for the whole vector and tries to come up with one format that
displays all the values accurately enough.  For a matrix (or data.frame) it
uses a different format for each column, so perhaps you would like the
output of:

   matrix(a, nrow=1, dimnames=list(, names(a)))
   A B C D   EF
   1e-10 1 2 3 0.5 0.25

Now you said you wanted a minimum of 4 digits after the decimal point for
large fractions like 0.25 but only 2 when using scientific notation for
small fractions like 1.0e-10 and you didn't say what you wanted for big
numbers like pi*10^10.  That rule seems complicated enough that you may want
to write your own print function based on sprintf().

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Kevin Burton
 Sent: Tuesday, November 15, 2011 8:19 AM
 To: r-help@r-project.org
 Subject: [R] Controlling the precision of the digits printed
 
 Has anyone come across the right combinations to print a limited 
 number of digits? My trial and error approach is taking too much time. 
 Here is what I have tried:
 
 
 
  op - options()
 
  a - c(1e-10,1,2,3,.5,.25)
 
  names(a) - c(A, B, C, D, E, F)
 
  # default
 
  a
 
   A   B   C   D   E   F
 
 1.0e-10 1.0e+00 2.0e+00 3.0e+00 5.0e-01 2.5e-01
 
  options(digits = 4, scipen=5)
 
  # Doesn't print exponents but there are too many trailing digits
 
  a
 
ABCDE
 F
 
 0.01 1.00 2.00 3.00 0.50
 0.25
 
 
 
  options(digits = 3, scipen=4)
 
  # Now we are back to exponents
 
  a
 
   A   B   C   D   E   F
 
 1.0e-10 1.0e+00 2.0e+00 3.0e+00 5.0e-01 2.5e-01
 
 
 
 I would like the integers to print as integers (1,2,3). The larger 
 fractions to print something like .5000 or .2500. And the very small 
 number to use exponents (1.0e-10)
 
 
 
 Is this possible?
 
 
 
 Thank you.
 
 
 
 Kevin
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Plot alignment with mtext

2011-11-15 Thread Kevin Burton
I would like the text plotted with 'mtext' to be alighned like it is for
printing on the console. Here is what I have:

 

 print(emt)

ME   RMSE  MAE
MPE   MAPE MASE

original -1.034568e+07 1.097695e+08 2.433160e+07 -31.30554   37.47713
1.5100050

xreg1.561235e+01 2.008599e+03 9.089473e+02 267.05490 280.66734
0.9893643

 

 a - capture.output(print(emt))

 a

[1] ME RMSE  MAE   MPE  MAPE
MASE

[2] original -1.034568e+07 1.097695e+08 2.433160e+07 -31.30554  37.47713
1.5100050

[3] xreg  1.561235e+01 2.008599e+03 9.089473e+02 267.05490 280.66734
0.9893643

 

There are no tabs but when adding to a plot with mtext like:

 

op - par(mfcol = c(2, 1), oma=c(0,0,4,0))

. . . . .

a - capture.output(print(emt))

mtext(a[1], line= 1, side=3, outer=TRUE)

mtext(a[2], line= 0, side=3, outer=TRUE)

mtext(a[3], line=-1, side=3, outer=TRUE)

 

The plotted text is not aligned like when it is displayed on the console. I
have looked at the strings and they all have the same length so it seems
that mtext is doing something with the spaces so that the output is not
aligned. Any ideas on how I can get it aligned (by column)?

 

Thank you.

 

Kevin


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Plot alignment with mtext

2011-11-15 Thread Kevin Burton
I hadn't considered altering the font. Thank you I will try that.

-Original Message-
From: Sarah Goslee [mailto:sarah.gos...@gmail.com] 
Sent: Tuesday, November 15, 2011 1:53 PM
To: Kevin Burton
Cc: r-help@r-project.org
Subject: Re: [R] Plot alignment with mtext

Hi Kevin,

On Tue, Nov 15, 2011 at 2:36 PM, Kevin Burton rkevinbur...@charter.net
wrote:
 I would like the text plotted with 'mtext' to be alighned like it is 
 for printing on the console. Here is what I have:

You don't provide any of the info in the posting guide (OS may be important
here), or a reproducible example, which would also be helpful.

But see below anyway.



 print(emt)

                    ME                   RMSE                  MAE MPE    
      
 MAPE         MASE

 original -1.034568e+07 1.097695e+08 2.433160e+07 -31.30554   37.47713
 1.5100050

 xreg        1.561235e+01 2.008599e+03 9.089473e+02 267.05490 280.66734
 0.9893643



 a - capture.output(print(emt))

 a

 [1]                     ME         RMSE          MAE       MPE      
 MAPE MASE

 [2] original -1.034568e+07 1.097695e+08 2.433160e+07 -31.30554  
 37.47713 1.5100050

 [3] xreg      1.561235e+01 2.008599e+03 9.089473e+02 267.05490 
 280.66734 0.9893643



 There are no tabs but when adding to a plot with mtext like:



 op - par(mfcol = c(2, 1), oma=c(0,0,4,0))

 . . . . .

 a - capture.output(print(emt))

 mtext(a[1], line= 1, side=3, outer=TRUE)

 mtext(a[2], line= 0, side=3, outer=TRUE)

 mtext(a[3], line=-1, side=3, outer=TRUE)


 The plotted text is not aligned like when it is displayed on the 
 console. I have looked at the strings and they all have the same 
 length so it seems that mtext is doing something with the spaces so 
 that the output is not aligned. Any ideas on how I can get it aligned (by
column)?

The default font used for titles is not proportionally spaced, at least on
my linux system, so of course they won't line up.

Try:

a - c(ME RMSE  MAE   MPE
 MAPE  MASE,
original -1.034568e+07 1.097695e+08 2.433160e+07 -31.30554  37.47713
1.5100050,
xreg  1.561235e+01 2.008599e+03 9.089473e+02 267.05490 280.66734
0.9893643)

par(mfcol=c(2,1), oma=c(0,0,4,0))
plot(1:10, 1:10)
plot(1:10, 1:10)

par(family=mono)
mtext(a[1], line= 1, side=3, outer=TRUE) mtext(a[2], line= 0, side=3,
outer=TRUE) mtext(a[3], line=-1, side=3, outer=TRUE)

Or whatever the appropriate font family specification for your OS is.

Sarah



--
Sarah Goslee
http://www.functionaldiversity.org

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] if/else scope

2011-11-15 Thread Kevin Burton
What is wrong with the following?

 

x - 1:2

if(x[1]  0)

{

if(x[2]  0)

{

print(1  2  0)

}

else

{

print(1  0)

}

}

else

{

if(x[2]  0)

{

print(2  0)

}

else

{

print(NONE  0)

}

}

 

Gives me

 

Error: unexpected 'else' in else

 

What am I missing?

 

Kevin


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Upgrade R?

2011-11-14 Thread Kevin Burton
I am also using statConn so I will let you know if I hear anything new.

-Original Message-
From: Cem Girit [mailto:gi...@comcast.net] 
Sent: Monday, November 14, 2011 8:52 AM
To: 'Kevin Burton'
Cc: r-help@r-project.org
Subject: RE: [R] Upgrade R?

Hello Kevin,

Thank you. I will delete the folder and run an application called
CCleaner (free). That will remove all the broken registry entries.

There should be a problem free update path for R installation. As
you rightfully mentioned the R- manual is not clear about package update
issues. I received many helpful suggestions on the update path but some of
the them were contradictory in the order of steps to be taken.  I am also
using statConn (DCOM) interface for programming.  So my problems are
multifold.  I will compile the answers I received on the R version update
issue and publish them so that that the experts could put them into more
effective use.

Sincerely,

Cem


-Original Message-
From: Kevin Burton [mailto:rkevinbur...@charter.net]
Sent: Sunday, November 13, 2011 4:11 PM
To: 'Cem Girit'
Subject: RE: [R] Upgrade R?

I don't know if it was correct but I just removed the directory and then
searched and removed all instances in the registry that referred to 2.13.1
(in my case searching for this seemed to only return references to 'R'). I
have since been given some links that address specific registry entries but
I haven't had any problem yet with my 'slash and burn' approach. It removed
it from the 'Install/Uninstall' list with windows so it seems to have be
removed and the disk space that 2.13.2 took up has been reclaimed. 

Hope this helps. Let me know if you find any more definitive answers.

Thanks.

Kevin

-Original Message-
From: Cem Girit [mailto:gi...@comcast.net]
Sent: Saturday, November 12, 2011 6:33 PM
To: 'Kevin Burton'
Subject: RE: [R] Upgrade R?

Hello Kevin,

I am getting the same error utCompiledCode... since I  installed
R2.14 while R2.13 existed.  How did you get rid of R2.13 eventually? Did you
just delete it? If so, how did you clean the registry? 

Thank you,

Cem

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Kevin Burton
Sent: Thursday, November 10, 2011 11:54 AM
To: 'jose Bartolomei'; 'R Help'
Subject: Re: [R] Upgrade R?

The problem with this documentation is two-fold. One it seems to concentrate
on building from source which I don't need. Two it doesn't address the
upgade. I have a number of packages and so I need to do what has been
suggested and install the latest version *first*. Then copy the libraries
(packages). Then uninstall the previous version. It is on this last step
that I am stuck on right now. The last link on uninstalling R manually was
what I needed. Thank you.

 

Kevin

 

From: jose Bartolomei [mailto:surfpr...@hotmail.com]
Sent: Thursday, November 10, 2011 10:19 AM
To: rkevinbur...@charter.net; R Help
Subject: RE: [R] Upgrade R?

 

Hi,
Don't know if this will help you but...
In my short experience and following the guidelines you should first
uninstall R.

http://cran.r-project.org/doc/manuals/R-admin.html#Installing-R-under-Window
s
 
Unistall it from the Windows control panel.
 
The old R version libraries file will be kept on machine.
For example : C:\Program Files\R\R-2.13.0\library
 
Then install the new version via:
http://cran.r-project.org/doc/manuals/R-admin.html#Installing-R-under-Window
s
 
You can copy/paste libraries from the old version R library file to the new
one.
C:\Program Files\R\R-2.14.0\library
 
There is too an function named:
?update.packagee

If above was what you did, then there is a post on Uninstalling R manually:
 
http://learnserver.csd.univie.ac.at/rcomwiki/doku.php?id=wiki:uninstalling_r
_manually
 
Regards,
Jose
 

 From: rkevinbur...@charter.net
 To: r-help@r-project.org
 Date: Thu, 10 Nov 2011 09:07:20 -0600
 Subject: Re: [R] Upgrade R?
 
 Since apparently there is no one familiar with this error message let 
 me rephrase the question. Is there a 'manual' process to fully remove 
 a
version
 of 'R' from my machine? This is a Window PC running Windows 7.
 
 
 
 Thank you.
 
 
 
 Kevin
 
 
 
 From: Kevin Burton [mailto:rkevinbur...@charter.net]
 Sent: Monday, November 07, 2011 2:23 PM
 To: 'r-help@r-project.org'
 Subject: Upgrade R?
 
 
 
 I am trying to upgrade to R 2.14 from R 2.13.1 I have compied all the 
 libraries from the 'library' directory in my existing installation
(2.13.1)
 to the installed R 2.14. Now I want to uninstall the old installation 
 (R
 2.13.1) and I get the error:
 
 
 
 Internal Error: Cannot find utCompiledCode record for this version of 
 the uninstaller.
 
 
 
 Any ideas?
 
 
 
 Kevin
 
 
 [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
http://www.R

[R] rugarch data format?

2011-11-14 Thread Kevin Burton
I am sorry to ask this group but the maintainer of this package did not
leave an email address. 

 

Has anyone used or is using the 'rugarch' package with time-series data
(ts)? I try to fit a GARCH model to my data using the following:

 

 gf - ugarchfit(data=l[[MEN]]$series, spec=spec)

 

and I get:

 

Error in .extractdata(data) : 

rgarch--error: class of data object not recognized

 

 class(l[[MEN]]$series)

[1] ts

 

The documentation states that :

 


data

A univariate data object. Can be a numeric vector, matrix, data.frame, zoo,
xts, timeSeries, ts or irts object.

 

I am not sure what I am doing wrong.

 

Thank you.

 

Kevin


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] string to list()

2011-11-14 Thread Kevin Burton
I can get an array of strings for the data that I want using 'paste()' as
follows:

 

paste('ma', 1:am$arma[2], '=', coef(am)[1:am$arma[2] + am$arma[1]], sep='')

 

This results in a vector of strings like:

 

[1] ma1=1.17760133668255  ma2=0.649795570407939 ma3=0.329456750858276

 

What I would like is

 

fixed.pars -
list(ma1=1.17760133668255,ma2=0.649795570407939,ma3=0.329456750858276)

 

Is there an 'R' guru that would be willing to suggest a good way of doing
this?

 

Thank you.

 

Kevin


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Formula variable help

2011-11-11 Thread Kevin Burton
It seems that there is a bug in the forecast::tslm function. I have forwarded 
what I think is the bug (the call to get() should supply the argument 
'envir=parent.frame()').

Thank you.

On Nov 11, 2011, at 12:11 PM, Joshua Wiley jwiley.ps...@gmail.com wrote:

 Seems like it could work---can you save your script as a .txt file and
 send it as an attachment, upload it online, or make a reproducible
 example?
 
 Cheers,
 
 Josh
 
 On Fri, Nov 11, 2011 at 9:52 AM,  rkevinbur...@charter.net wrote:
 
 I have an R script with the following applicable lines:
 
xshort - window(s, start=st, end=ed)
 . . .
xshort - ts(xshort, frequency=1, start=1)
 . . .
m1 - m2 - m3 - m4 - m5 - m6 - NULL
m1 - tslm(xshort ~ trend)
 
 I get an error:
 
 Error in get(dataname) : object 'xshort' not found
 
 When I do traceback() I get:
 
 3: get(dataname)
 2: tslm(xshort ~ trend) at #19
 1: model.cross.validation(l[[MEN]]$series)
 
 Which points to the call to tslm above.  Since I am not supply 'data' to
 the tslm call (in the forecast package),, I am assuming that the code is
 dying here (in tslm):
 
 if (missing(data)) {
 dataname - as.character(formula)[2]
 x - get(dataname)
 data - data.frame(x)
 colnames(data) - dataname
 }
 
 Any ideas what is failing?
 
 Kevin
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
 -- 
 Joshua Wiley
 Ph.D. Student, Health Psychology
 Programmer Analyst II, ATS Statistical Consulting Group
 University of California, Los Angeles
 https://joshuawiley.com/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Upgrade R?

2011-11-10 Thread Kevin Burton
Since apparently there is no one familiar with this error message let me
rephrase the question. Is there a 'manual' process to fully remove a version
of 'R' from my machine? This is a Window PC running Windows 7.

 

Thank you.

 

Kevin

 

From: Kevin Burton [mailto:rkevinbur...@charter.net] 
Sent: Monday, November 07, 2011 2:23 PM
To: 'r-help@r-project.org'
Subject: Upgrade R?

 

I am trying to upgrade to R 2.14 from R 2.13.1 I have compied all the
libraries from the 'library' directory in my existing installation (2.13.1)
to the installed R 2.14. Now I want to uninstall the old installation (R
2.13.1) and I get the error:

 

Internal Error: Cannot find utCompiledCode record for this version of the
uninstaller.

 

Any ideas?

 

Kevin


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Stack trace?

2011-11-10 Thread Kevin Burton
Will traceback() work in the error routine specified in tryCatch?

error - function(e)
{
traceback()
}

tryCatch(..., error=error)

-Original Message-
From: William Dunlap [mailto:wdun...@tibco.com] 
Sent: Wednesday, November 09, 2011 5:09 PM
To: Thomas Lumley; rkevinbur...@charter.net
Cc: r-help
Subject: RE: [R] Stack trace?

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Thomas Lumley
 Sent: Wednesday, November 09, 2011 1:53 PM
 To: rkevinbur...@charter.net
 Cc: r-help
 Subject: Re: [R] Stack trace?
 
 On Thu, Nov 10, 2011 at 10:35 AM,  rkevinbur...@charter.net wrote:
 
  Currently I have a for loop executing functions and at the end I get 
  a message like:
 
  There were 50 or more warnings (use warnings() to see the first 50)
 
  If I do what it says and type warnings(), I get 50 messages like:
 
  2: In !is.na(x)  !is.na(rowSums(xreg)) :
    longer object length is not a multiple of shorter object length
 
  I am not sure what function these errors are originating from. I 
  don't think it is from any of the 'R' script that I wrote. I would 
  like to see which function is being called when this error is thrown 
  and which called that . . . and so on.
 
  I have the same problem with error messages. An error is thrown but 
  I don't have a call stack to help trace down the problem. Is there 
  some function or technique that I could use to help get a call stack?
 
 traceback() gets you a stack trace at the last error
 
 options(warn=2) makes warnings into errors
 
 options(error=recover) starts the post-mortem debugger at any error, 
 allowing you to inspect the stack interactively.

And
  options(warning.expression=quote(recover()))
will start that same debugger at each warning.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

 
   -thomas
 
 --
 Thomas Lumley
 Professor of Biostatistics
 University of Auckland
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Upgrade R?

2011-11-10 Thread Kevin Burton
I downloaded and installed the latest (2.14.0). It works just fine. But, I
still have 2.13.2 installed and when I try to uninstall it I get the error
that I showed at the beginning of this thread.

-Original Message-
From: steve_fried...@nps.gov [mailto:steve_fried...@nps.gov] 
Sent: Thursday, November 10, 2011 9:17 AM
To: Kevin Burton
Cc: r-help@r-project.org; r-help-boun...@r-project.org
Subject: Re: [R] Upgrade R?

Why don't you just download the latest release from CRAN - R.  It is the
recommended approach to installing R.

Steve Friedman Ph. D.
Ecologist  / Spatial Statistical Analyst Everglades and Dry Tortugas
National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

steve_fried...@nps.gov
Office (305) 224 - 4282
Fax (305) 224 - 4147


   
 Kevin Burton
 rkevinburton@cha 
 rter.net  To 
 Sent by:  r-help@r-project.org  
 r-help-bounces@r-  cc 
 project.org   
   Subject 
   Re: [R] Upgrade R?  
 11/10/2011 10:07  
 AM
   
   
   
   




Since apparently there is no one familiar with this error message let me
rephrase the question. Is there a 'manual' process to fully remove a version
of 'R' from my machine? This is a Window PC running Windows 7.



Thank you.



Kevin



From: Kevin Burton [mailto:rkevinbur...@charter.net]
Sent: Monday, November 07, 2011 2:23 PM
To: 'r-help@r-project.org'
Subject: Upgrade R?



I am trying to upgrade to R 2.14 from R 2.13.1 I have compied all the
libraries from the 'library' directory in my existing installation (2.13.1)
to the installed R 2.14. Now I want to uninstall the old installation (R
2.13.1) and I get the error:



Internal Error: Cannot find utCompiledCode record for this version of the
uninstaller.



Any ideas?



Kevin


 [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Title for a group of plots?

2011-11-10 Thread Kevin Burton
I can get multiple plots on a page like:

 

op - par(mfcol = c(3, 1))

 

What I was wondering is if there is a way to have a title for the whole
page? I can specify the title for each individual plot like:

 

plot(xxx, main=.)

 

But I would like a 'title' for the group of plots. Is this possible?

 

Thank you.

 

Kevin


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Upgrade R?

2011-11-10 Thread Kevin Burton
I know they can coexist. It all works fine with both versions installed. But
with limited resources I would like to uninstall the previous version (for
me it is 2.13.1). Choosing uninstall from the 'Control Panel' results in the
error listed at the beginning of this thread.

 

From: Bert Gunter [mailto:gunter.ber...@gene.com] 
Sent: Thursday, November 10, 2011 10:40 AM
To: jose Bartolomei
Cc: rkevinbur...@charter.net; R Help
Subject: Re: [R] Upgrade R?

 

The advice below is wholly unnecessary, and, in fact, various versions of R
can coexist without problems (and are designed to do so).

I just upgraded to 2.14.0 on Windows via the simple binary install process,
copied old libraries over (unnecessary if you do not wish to keep old
versions around -- just use .libPaths() to point to the library tree)  ran
the update packages options from the packages menu. 

Pretty simple! (Thanks Duncan M.)

-- Bert

On Thu, Nov 10, 2011 at 8:18 AM, jose Bartolomei surfpr...@hotmail.com
wrote:


Hi,Don't know if this will help you but...In my short experience and
following the guidelines you should first uninstall R.
http://cran.r-project.org/doc/manuals/R-admin.html#Installing-R-under-Window
s Unistall it from the Windows control panel. The old R version libraries
file will be kept on machine.
For example : C:\Program Files\R\R-2.13.0\library Then install the new
version
via:http://cran.r-project.org/doc/manuals/R-admin.html#Installing-R-under-Wi
ndows You can copy/paste libraries from the old version R library file to
the new one.
C:\Program Files\R\R-2.14.0\library There is too an function named:
?update.packagee
If above was what you did, then there is a post on Uninstalling R manually:
http://learnserver.csd.univie.ac.at/rcomwiki/doku.php?id=wiki:uninstalling_r
_manually Regards,
Jose
  From: rkevinbur...@charter.net
 To: r-help@r-project.org
 Date: Thu, 10 Nov 2011 09:07:20 -0600
 Subject: Re: [R] Upgrade R?

 Since apparently there is no one familiar with this error message let me
 rephrase the question. Is there a 'manual' process to fully remove a
version
 of 'R' from my machine? This is a Window PC running Windows 7.



 Thank you.



 Kevin



 From: Kevin Burton [mailto:rkevinbur...@charter.net]
 Sent: Monday, November 07, 2011 2:23 PM
 To: 'r-help@r-project.org'
 Subject: Upgrade R?



 I am trying to upgrade to R 2.14 from R 2.13.1 I have compied all the
 libraries from the 'library' directory in my existing installation
(2.13.1)
 to the installed R 2.14. Now I want to uninstall the old installation (R
 2.13.1) and I get the error:



 Internal Error: Cannot find utCompiledCode record for this version of the
 uninstaller.



 Any ideas?



 Kevin


   [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

   [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




-- 

 

Bert Gunter

Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:

http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biost
atistics/pdb-ncb-home.htm

 

 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Upgrade R?

2011-11-10 Thread Kevin Burton
The problem with this documentation is two-fold. One it seems to concentrate
on building from source which I don't need. Two it doesn't address the
upgade. I have a number of packages and so I need to do what has been
suggested and install the latest version *first*. Then copy the libraries
(packages). Then uninstall the previous version. It is on this last step
that I am stuck on right now. The last link on uninstalling R manually was
what I needed. Thank you.

 

Kevin

 

From: jose Bartolomei [mailto:surfpr...@hotmail.com] 
Sent: Thursday, November 10, 2011 10:19 AM
To: rkevinbur...@charter.net; R Help
Subject: RE: [R] Upgrade R?

 

Hi,
Don't know if this will help you but...
In my short experience and following the guidelines you should first
uninstall R.

http://cran.r-project.org/doc/manuals/R-admin.html#Installing-R-under-Window
s
 
Unistall it from the Windows control panel.
 
The old R version libraries file will be kept on machine.
For example : C:\Program Files\R\R-2.13.0\library
 
Then install the new version via:
http://cran.r-project.org/doc/manuals/R-admin.html#Installing-R-under-Window
s
 
You can copy/paste libraries from the old version R library file to the new
one.
C:\Program Files\R\R-2.14.0\library
 
There is too an function named:
?update.packagee

If above was what you did, then there is a post on Uninstalling R manually:
 
http://learnserver.csd.univie.ac.at/rcomwiki/doku.php?id=wiki:uninstalling_r
_manually
 
Regards,
Jose
 

 From: rkevinbur...@charter.net
 To: r-help@r-project.org
 Date: Thu, 10 Nov 2011 09:07:20 -0600
 Subject: Re: [R] Upgrade R?
 
 Since apparently there is no one familiar with this error message let me
 rephrase the question. Is there a 'manual' process to fully remove a
version
 of 'R' from my machine? This is a Window PC running Windows 7.
 
 
 
 Thank you.
 
 
 
 Kevin
 
 
 
 From: Kevin Burton [mailto:rkevinbur...@charter.net] 
 Sent: Monday, November 07, 2011 2:23 PM
 To: 'r-help@r-project.org'
 Subject: Upgrade R?
 
 
 
 I am trying to upgrade to R 2.14 from R 2.13.1 I have compied all the
 libraries from the 'library' directory in my existing installation
(2.13.1)
 to the installed R 2.14. Now I want to uninstall the old installation (R
 2.13.1) and I get the error:
 
 
 
 Internal Error: Cannot find utCompiledCode record for this version of the
 uninstaller.
 
 
 
 Any ideas?
 
 
 
 Kevin
 
 
 [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] window?

2011-11-08 Thread Kevin Burton
Can someone enlighten me on why the following doesn't work?

 

 

setwd('C:/Temp/R')

 

d - rep(1:53,2)

(s - ts(d, frequency=53, start=c(2000,10)))

n - length(s)

k - n%/%3

 

for(i in (n-k):n)

{

st - c(start(s)[1] + (start(s)[2] + i)%/%frequency(s), (start(s)[2] +
i) %% frequency(s))

ed - c(start(s)[1] + (start(s)[2]+k+i)%/%frequency(s),
(start(s)[2]+i+k) %% frequency(s))

xshort - window(s, start=st, end=ed)

cat(Start , st,  End , ed, \n)

cat(Length , length(xshort),  start , start(xshort), 
end , end(xshort), \n)

}

 

I get a bunch of warnings like:

 

36: In window.default(x, ...) : 'end' value not changed

 

Thank you.

 

Kevin

rkevinbur...@charter.net


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] window?

2011-11-08 Thread Kevin Burton
This doesn't seem to work:

 

 d - rnorm(2*53)

 ds - ts(d, frequency=53, start=c(2000,10))

 dswin - window(ds, start=c(2001,1), end=c(2001,10), frequency=1)

 dswin

Time Series:

Start = 2001 

End = 2001 

Frequency = 1 

[1] 1.779409

 

 dswin - window(ds, start=c(2001,1), end=c(2001,10))

 dswin

Time Series:

Start = c(2001, 1) 

End = c(2001, 10) 

Frequency = 53 

 [1]  1.7794090  0.6916779 -0.6641813 -0.7426889 -0.5584049 -0.2312959

[7] -0.0183454 -1.0026301  0.4534920  0.6058198

 

 

The problem is that when the frequency is specified only one value shows up
in the window. When no frequency is specified I get all 10 values but now
the time series has a frequency that I don't want.

 

Comments?

 

Kevin

 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] window?

2011-11-08 Thread Kevin Burton
I expect the frequency to be set to what I set it at and the window to
return all of the data in the window from the original time series. The
error is not because it is prime. I can generate a time series with just 52
values (or 10) and it still occurs. I am building these objects for use with
the 'forecast' packages and one of the methods 'ets' cannot handle a
frequency above 24 so I set it (or try to) to 1. Will 'window' take z zoo or
xts object? Can I convert from zoo or xts to ts?

-Original Message-
From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com] 
Sent: Tuesday, November 08, 2011 2:28 PM
To: Kevin Burton
Cc: r-help@r-project.org
Subject: Re: [R] window?

I'm not entirely sure that your request makes sense: what do you expect the
frequency to be? It makes sense to me as is...Might your troubles be because
53 is prime?

More generally, most people don't like working with the raw ts class and
prefer the zoo or xts packages because they are much more pleasant for most
time series work. You might want to take a look into those.

Michael

On Tue, Nov 8, 2011 at 3:18 PM, Kevin Burton rkevinbur...@charter.net
wrote:
 This doesn't seem to work:



 d - rnorm(2*53)

 ds - ts(d, frequency=53, start=c(2000,10))

 dswin - window(ds, start=c(2001,1), end=c(2001,10), frequency=1)

 dswin

 Time Series:

 Start = 2001

 End = 2001

 Frequency = 1

 [1] 1.779409



 dswin - window(ds, start=c(2001,1), end=c(2001,10))

 dswin

 Time Series:

 Start = c(2001, 1)

 End = c(2001, 10)

 Frequency = 53

  [1]  1.7794090  0.6916779 -0.6641813 -0.7426889 -0.5584049 -0.2312959

 [7] -0.0183454 -1.0026301  0.4534920  0.6058198





 The problem is that when the frequency is specified only one value 
 shows up in the window. When no frequency is specified I get all 10 
 values but now the time series has a frequency that I don't want.



 Comments?



 Kevin




        [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] window?

2011-11-08 Thread Kevin Burton
The problem is when I use the window function an try to extract a subset of
the time series an specify the frequency as 1 (not only will ets not take a
time series with a frequency greater than 24, now that I am taking a subset
there is no frequency so I would like to set it to 1 (which is one of the
arguments to the window function) but it does not produce what I expect.
That is the problem.  I fail to see the relationship of the discussion of
what frequency is and how to use the forecast package with this problem.

-Original Message-
From: Dennis Murphy [mailto:djmu...@gmail.com] 
Sent: Tuesday, November 08, 2011 6:20 PM
To: Kevin Burton
Cc: R. Michael Weylandt; r-help@r-project.org
Subject: Re: [R] window?

The ets() function in the forecast package requires either a numeric vector
or a Time-Series object (produced from ts()). The frequency argument in ts()
refers to the time duration between observations; e.g., frequency = 7 means
that the data are weekly; frequency = 12 means that the data are monthly;
frequency = 4 means that the data are quarterly. You can see this from the
examples on the help page of ts:
?ts at the R prompt.

The example associated with the forecast::ets() function uses the
USAccDeaths data:

data(USAccDeaths)
USAccDeaths   ## monthly data for six years
# Simulate the same structure with ts:
u - ts(rnorm(72), start = c(1973, 1), frequency = 12) u

# Evidently you want to produce a multivariate series; # here's one way with
monthly frequency:
v - ts(matrix(rnorm(106), ncol = 2), start = c(2001, 1), frequency = 12) v

Is that more or less what you were after?

Dennis

On Tue, Nov 8, 2011 at 2:04 PM, Kevin Burton rkevinbur...@charter.net
wrote:
 I expect the frequency to be set to what I set it at and the window to 
 return all of the data in the window from the original time series. 
 The error is not because it is prime. I can generate a time series 
 with just 52 values (or 10) and it still occurs. I am building these 
 objects for use with the 'forecast' packages and one of the methods 
 'ets' cannot handle a frequency above 24 so I set it (or try to) to 1. 
 Will 'window' take z zoo or xts object? Can I convert from zoo or xts to
ts?

 -Original Message-
 From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com]
 Sent: Tuesday, November 08, 2011 2:28 PM
 To: Kevin Burton
 Cc: r-help@r-project.org
 Subject: Re: [R] window?

 I'm not entirely sure that your request makes sense: what do you 
 expect the frequency to be? It makes sense to me as is...Might your 
 troubles be because
 53 is prime?

 More generally, most people don't like working with the raw ts class 
 and prefer the zoo or xts packages because they are much more pleasant 
 for most time series work. You might want to take a look into those.

 Michael

 On Tue, Nov 8, 2011 at 3:18 PM, Kevin Burton 
 rkevinbur...@charter.net
 wrote:
 This doesn't seem to work:



 d - rnorm(2*53)

 ds - ts(d, frequency=53, start=c(2000,10))

 dswin - window(ds, start=c(2001,1), end=c(2001,10), frequency=1)

 dswin

 Time Series:

 Start = 2001

 End = 2001

 Frequency = 1

 [1] 1.779409



 dswin - window(ds, start=c(2001,1), end=c(2001,10))

 dswin

 Time Series:

 Start = c(2001, 1)

 End = c(2001, 10)

 Frequency = 53

  [1]  1.7794090  0.6916779 -0.6641813 -0.7426889 -0.5584049 
 -0.2312959

 [7] -0.0183454 -1.0026301  0.4534920  0.6058198





 The problem is that when the frequency is specified only one value 
 shows up in the window. When no frequency is specified I get all 10 
 values but now the time series has a frequency that I don't want.



 Comments?



 Kevin




        [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Upgrade R?

2011-11-07 Thread Kevin Burton
I am trying to upgrade to R 2.14 from R 2.13.1 I have compied all the
libraries from the 'library' directory in my existing installation (2.13.1)
to the installed R 2.14. Now I want to uninstall the old installation (R
2.13.1) and I get the error:

 

Internal Error: Cannot find utCompiledCode record for this version of the
uninstaller.

 

Any ideas?

 

Kevin


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] acf?

2011-11-04 Thread Kevin Burton
I started to check what I thought I knew with autocovariance and it doesn’t
jive with the the calculations given by ‘R’. I was wondering if there is
some scaling or something that I am not aware of.

 

Take the example

 

Ø  d - 1:10

Ø  (a - acf(d, type=covariance, demean=FALSE, plot=FALSE))

 

Autocovariances of series ‘d’, by lag

 

   0123456789 

38.5 33.0 27.6 22.4 17.5 13.0  9.0  5.6  2.9  1.0

 

But when I calculate it manually (for lag of 1) like:

 

Ø  y1 - d – mean(d)

Ø  dl - c(d[-1], d[1])

Ø  y2 - dl – mean(d)

Ø  mean(y1*y2)

[1] 3.75

 

What am I missing to get this basic concept? Isn’t it E[(Yt – ut)(Ys – us)]?

 

Thank you.

 

Kevin


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Plotting text?

2011-10-24 Thread Kevin Burton
Thank you. This works pretty well. I am having some trouble with the text on
the left-hand side getting cut off. I have tried haling=center  with not
luck. How can I make the text seem wider than it really is to avoid the
truncation. It is only a few characters but still it is annoying. Thank you.

-Original Message-
From: Eik Vettorazzi [mailto:e.vettora...@uke.de] 
Sent: Saturday, October 22, 2011 7:06 AM
To: rkevinbur...@charter.net
Cc: r-help@r-project.org
Subject: Re: [R] Plotting text?

Hi Kevin,
have a look at ?textplot from the gplots-package.

cheers

Am 22.10.2011 02:26, schrieb rkevinbur...@charter.net:
 
 I noticed that the text() command adds text to a plot. Is there a way 
 to either make the plot blank or add text to a blank sheet. I would 
 like to plot a page that contains just text, no plot lines, labels, etc.
 
 Suggestions?
 
 Kevin
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


--
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie Universitätsklinikum
Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Plotting text?

2011-10-24 Thread Kevin Burton
I get the following error trying to install the package:

 install.packages(grid)
--- Please select a CRAN mirror for use in this session ---
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
  package ‘grid’ is not available (for R version 2.13.2)


-Original Message-
From: baptiste auguie [mailto:baptiste.aug...@googlemail.com] 
Sent: Saturday, October 22, 2011 12:46 AM
To: rkevinbur...@charter.net
Cc: r-help@r-project.org
Subject: Re: [R] Plotting text?

Try this,

library(grid)
grid.newpage()
grid.text(text)

HTH,

baptiste

On 22 October 2011 13:26,  rkevinbur...@charter.net wrote:

 I noticed that the text() command adds text to a plot. Is there a way 
 to either make the plot blank or add text to a blank sheet. I would 
 like to plot a page that contains just text, no plot lines, labels, etc.

 Suggestions?

 Kevin

        [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Length of string?

2011-10-24 Thread Kevin Burton
This is very basic but I have not been able to find an answer. Basically I
want to find the length of a string.

length(Text)

returns 1 so I know that is not right.

Thank you.

Kevin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Plotting text?

2011-10-24 Thread Kevin Burton
I was able to solve it by supplying the 'mar' argument. Even when I spell it
right this argument did not solve it.

Thanks again.

Kevin

-Original Message-
From: Eik Vettorazzi [mailto:e.vettora...@uke.de] 
Sent: Monday, October 24, 2011 8:46 AM
To: Kevin Burton
Cc: r-help@r-project.org
Subject: Re: [R] Plotting text?

Hi Kevin,
this should be read as halign=center - so is it a typo just in your mail
or in your program as well?

apart from that, the rules at the bottom lines of every post on this list
also apply here: what have you tried and what went wrong?

Cheers

Am 24.10.2011 14:48, schrieb Kevin Burton:
 Thank you. This works pretty well. I am having some trouble with the 
 text on the left-hand side getting cut off. I have tried 
 haling=center  with not luck. How can I make the text seem wider 
 than it really is to avoid the truncation. It is only a few characters but
still it is annoying. Thank you.
 
 -Original Message-
 From: Eik Vettorazzi [mailto:e.vettora...@uke.de]
 Sent: Saturday, October 22, 2011 7:06 AM
 To: rkevinbur...@charter.net
 Cc: r-help@r-project.org
 Subject: Re: [R] Plotting text?
 
 Hi Kevin,
 have a look at ?textplot from the gplots-package.
 
 cheers
 
 Am 22.10.2011 02:26, schrieb rkevinbur...@charter.net:

 I noticed that the text() command adds text to a plot. Is there a way 
 to either make the plot blank or add text to a blank sheet. I would 
 like to plot a page that contains just text, no plot lines, labels,
etc.

 Suggestions?

 Kevin

  [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 --
 Eik Vettorazzi
 Institut für Medizinische Biometrie und Epidemiologie 
 Universitätsklinikum Hamburg-Eppendorf
 
 Martinistr. 52
 20246 Hamburg
 
 T ++49/40/7410-58243
 F ++49/40/7410-57790
 


--
Eik Vettorazzi

Department of Medical Biometry and Epidemiology University Medical Center
Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

--
Pflichtangaben gemäß Gesetz über elektronische Handelsregister und
Genossenschaftsregister sowie das Unternehmensregister (EHUG):

Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen
Rechts; Gerichtsstand: Hamburg

Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des Vorsitzenden),
Dr. Alexander Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.