Displaying 20 results from an estimated 1000 matches similar to: "setMethods/setGeneric problem when R CMD CHECK'ing a package"
2010 Mar 28
0
Preserving both yearmon and numeric data in an xls object
Hi R gourmets,
I am trying to convert an HTML table into an xts object. The table has
six columns, with the data of interest in a single row with each cell
containing a long, \n-delimited character string. Initially, I work with
these strings as elements in a list. This is necessary because the
strings in each cell do not translate into a regular matrix with
equal-length columns. Once I fix
2008 Nov 04
2
ggplot & annotating charts
Dear "R-listers"
I've been trying to figure out how to annotate charts in ggplot (ie add text
to line charts, highlighted boxes etc). By and large, I can get close to
what i want with base graphics, but would ideally like to use ggplot
whenever possible (additionally, i would like to add text labels
automatically to the chart). The code is below
I suspect I need to use geom_rect,
2011 May 19
1
Creating a "shifted" month (one that starts not on the first of each month but on another date)
Hello!
I have a data frame with dates. I need to create a new "month" that
starts on the 20th of each month - because I'll need to aggregate my
data later by that "shifted" month.
I wrote the code below and it works. However, I was wondering if there
is some ready-made function in some package - that makes it
easier/more elegant?
Thanks a lot!
# Example data:
2009 Sep 25
0
differing behaviour between xts (0.6-7) and zoo (1.5-8)
Folks,
I have some weekly dataseries that I convert to monthly xts (with
yearmon indices), and obtain the two following extracts:
> str(sig)
An 'xts' object from Apr 1998 to Sep 1998 containing:
Data: num [1:6, 1] 0.0083 0.2799 -0.2524 -0.0119 0.18 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr "e1"
Indexed by objects of class: [yearmon] TZ:
2009 Jan 23
1
extract certain months toyears (zoo)
Dear useRs and developeRs,
In my diploma thesis I work with a daily time series of glacier runoff
data.
I did already aggregate them to monthly means etc.
Now i want to use just the summer values (I am indecisive by now what
that means, but let's make it easy and use months like June).
Is there a way to extract the data off this zoo into another zoo with
frequency=1 ?
Do you have
2010 Apr 08
2
xts off by one confusion or error
Hullo
I may have missed something blindingly obvious here. I'm using xts to
handle some timeseries data. I've got daily measurements for 100
years. If I try to reduce the error rate by taking means of each
month, I'm getting what at first sight appears to be conflicting
information. Here's a small subset to show the problem:
A small set of data:
> vv
x
2017 Sep 20
0
Convert data into zoo object using Performance analytics package
Hi
Gabor's code works as expeceted without error.
What is "u" in your case?
Cheers
Petr
> -----Original Message-----
> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Upananda
> Pani
> Sent: Wednesday, September 20, 2017 11:06 AM
> To: Gabor Grothendieck <ggrothendieck at gmail.com>
> Cc: r-help <r-help at r-project.org>
>
2017 Sep 20
1
Convert data into zoo object using Performance analytics package
Dear Sir,
Thanks for your mail and help. I got this error while trying to run your
code.
sbux1.z <- read.csv.zoo(u, FUN = as.yearmon, format = fmt)
Error in read.table(file = file, header = header, sep = sep, quote = quote,
:
'file' must be a character string or connection
Thanks and Regards,
Upananda Pani
On Tue, Sep 19, 2017 at 4:31 PM, Upananda Pani <upananda.pani at
2010 Jul 12
3
How to create sequence in month
Hi all, can anyone please guide me how to create a sequence of months? Here
I have tried following however couldn't get success
> library(zoo)
> seq(as.yearmon("2010-01-01"), as.yearmon("2010-03-01"), by="1 month")
Error in del/by : non-numeric argument to binary operator
What is the correct way to do that?
Thanks for your time.
2017 Sep 22
1
Convert data into zoo object using Performance analytics package
Dear All,
Thanks a lot for your help. Would you please let me know if i want to read
a csv file as zoo object from my local file rather than directly from the
website, how to do that?
library(zoo)
u <- "https://faculty.washington.edu/ezivot/econ424/sbuxPrices.csv"
fmt <- "%m/%d/%Y"
With sincere regards,
Upananda Pani
On Wed, Sep 20, 2017 at 3:22 PM, PIKAL Petr
2009 Nov 09
1
zoo: bug with unique for yearmon
I'm using R 2.10.0, with zoo 1.5-8. The release notes for zoo 1.5-8
claim a bug with unique for yearmon objects has been fixed, but I'm
still having problems.
Browse[1]> tmp2
[1] "Dec 1996" "Dec 1996"
Browse[1]> unique(tmp2)
[1] "Dec 1996" "Dec 1996"
Browse[1]> unique(unique(tmp2))
[1] "Dec 1996"
Browse[1]> as.numeric(tmp2) -
2009 Dec 22
1
Using zoo() to aggregate daily data to monthly means
I am trying to get monthly means for a daily data series using zoo(). I have
found an odd problem, that seems to be caused by zoo()'s handling of leap
years.
Here's my R script with 2 methods (freq=365, 366) for aggregating the daily
data to monthly series:
library(zoo)
J_link <- "http://www.ijis.iarc.uaf.edu/seaice/extent/plot.csv"
JAXA_data <- read.table(J_link,
2010 Aug 13
3
transforming dates into years
Hello!
If I have in my data frame MyFrame a variable saved as a Date and want
to translate it into years, I currently do it like this using "zoo":
library(zoo)
as.year <- function(x) as.numeric(floor(as.yearmon(x)))
myFrame$year<-as.year(myFrame$date)
Is there a function that would do it directly - like "as.yearmon" -
but for years?
Thank you!
--
Dimitri
2010 Mar 18
1
probable timezone confusion with as.yearmon
It looks like a timezone issue, and it's causing confusion to me at least.
My original data:
gmt <-
c("19880101 0000", "19880101 0100", "19880101 0300", "19880101 0400",
"19880101 0500", "19880101 0600")
These were converted to local dates/times with
akst<-strptime(gmt,format="%Y%m%d %H%M")-(3600*9) # because I want
2017 Sep 18
3
Convert data into zoo object using Performance analytics package
Dear All,
While i am trying convert data frame object to zoo object I am
getting numeric(0) error in performance analytics package.
The source code i am using from this website to learn r in finance:
https://faculty.washington.edu/ezivot/econ424/returnCalculations.r
# create zoo objects from data.frame objects
dates.sbux = as.yearmon(sbux.df$Date, format="%m/%d/%Y")
dates.msft =
2010 Apr 18
4
confused with yearmon, xts and maybe zoo
R-listers,
I am using xts with a yearmon index, but am getting some inconsistent
results with the date index when i drop observations (for example by using
na.omit).
The issue is illustrated in the example below. If I start with a monthly
zooreg series starting in 2009, yearmon converts this to "Dec-2008". Not
such a worry for my example, but strange. Having converted to xts, i drop
2018 Mar 06
1
raster time series statistics
It works if you use as.Date. But this defeates the purpose for the yearmon notion...
require(raster)
require(rts)
require(stringr)
r <- raster(ncol=100, nrow=100)
values(r) <- runif(ncell(r))
stack(r)->s
r->rs
for(i in 1:23){
rs[]<-r[]*i
addLayer(s,rs)->s
print(nlayers(s))
}
dt<-list(ID=seq(1:24),month=rep(formatC(1:12,flag=0,width=2),2), year=sort(rep(2016:2017,12)))
2010 Nov 23
2
Plot two zoo object with different indexes
Dear R community, I have the following two zoo objects:
MONTHLY CPI
> plot(z)
> par("usr")
[1] 1977.76333 2011.15333 70.39856 227.03744
> z=zooreg(cpius$Value,as.yearmon("1979-11"),frequency=12)
> str(z)
?zooreg? series from Nov 1979 to Oct 2010
Data: num [1:372] 76.2 77 77.8 78.5 79.5 80.3 81.1 82 82 82.6 ...
Index: Class 'yearmon' num [1:372]
2004 Dec 03
2
setGeneric(rm)
Hi,
We are developing a package using S4 classes. The S4 classes
are wrappers to C++ classes. So S4 classes contain an integer
that is the memory address of one C++ object. If an user
calls the rm() function, the C++ object must be deleted. But our generic
rm() function apparently doesn't work. Here is the code:
# The class
setClass("component",
2023 May 16
1
Recombining Mon and Year values
?s 21:29 de 16/05/2023, Jeff Reichman escreveu:
> R Help
>
>
>
> I have a data.frame where I've broken out the year <dbl> and an ordered
> month <ord> values. But I need to recombine them so I can graph mon-year in
> order but when I recombine I lose the month order and the results are
> plotted alphabetical.
>
>
>
> Year month