search for: coredata

Displaying 20 results from an estimated 133 matches for "coredata".

2023 Apr 12
1
converting a character matrix into numeric....
Dear Rui, Not working. I have entirely removed the column containing % but am still bootless: > head(coredata(INFYTX)) INFY Historical Data INFY Historical Data INFY Historical Data INFY Historical Data [1,] "47.26" "44.28" "47.56" "44.28" [2,] "46.30" "44.92" "46.53"...
2009 Jun 19
1
(FULL) Need help to optimize a piece of code involving zoo objects
...ate <- as.Date("2003-02-01") + seq(1,1100) - 1 temp <- zoo(rnorm(1100, 0, 10)+100, x.Date) start.time <- proc.time() for(j in seq(5,100,by=5)){ ? ? ? ?#PRODUCE FAST MOVING AVERAGE ? ? ? ?#Create equally weighted MA vector (we need only the first value) ? ? ? ?smafast <- zoo(coredata(filter(coredata(temp[,1]), filter=rep(1/j, j), sides=1)), order.by=time(temp)) ? ? ? ?#index of first non-NA value, which is the first SMA needed ? ? ? ?#which(is.na(smafast))[length(which(is.na(smafast)))]+1 ? ? ? ?#Calculate decay factor K ? ? ? ?#number of periods is j ? ? ? ?K <- 2/(1+j)...
2023 Apr 12
1
converting a character matrix into numeric....
...quot;759898" "-1.25%" > 2003-04-24 "44.53" "1185402" "0.51%" > > But it is populated with character values and I want to convert them to numeric. THe following code doesn't work: > >> head(coredata(INFYTX)) > INFY Historical Data INFY Historical Data.1 INFY Historical Data.2 INFY Historical Data.3 > [1,] "47.26" "44.28" "47.56" "44.28" > [2,] "46.30" "44.92"...
2009 Jun 19
1
Need help to optimize a piece of code involving zoo objects
...cond for-loop x.Date <- as.Date("2003-02-01") + seq(1,1100) - 1 temp <- zoo(rnorm(1100, 0, 10)+100, x.Date) start.time <- proc.time() for(j in seq(5,100,by=5)){ #PRODUCE FAST MOVING AVERAGE #Create equally weighted MA vector (we need only the first value) smafast <- zoo(coredata(filter(coredata(temp[,1]), filter=rep(1/j, j), sides=1)), order.by=time(temp)) #index of first non-NA value, which is the first SMA needed #which(is.na(smafast))[length(which(is.na(smafast)))]+1 #Calculate decay factor K #number of periods is j K <- 2/(1+j) #Calculate recursively the EM...
2023 Apr 12
1
converting a character matrix into numeric....
...7" "759898" "-1.25%" 2003-04-24 "44.53" "1185402" "0.51%" But it is populated with character values and I want to convert them to numeric. THe following code doesn't work: > head(coredata(INFYTX)) INFY Historical Data INFY Historical Data.1 INFY Historical Data.2 INFY Historical Data.3 [1,] "47.26" "44.28" "47.56" "44.28" [2,] "46.30" "44.92" "...
2023 Apr 12
1
converting a character matrix into numeric....
...eft the barn? Why not figure all this out _before_ converting to xts? On April 12, 2023 12:29:49 PM PDT, akshay kulkarni <akshay_e4 at hotmail.com> wrote: >Dear Rui, > Not working. I have entirely removed the column containing % but am still bootless: > >> head(coredata(INFYTX)) > INFY Historical Data INFY Historical Data INFY Historical Data INFY Historical Data >[1,] "47.26" "44.28" "47.56" "44.28" >[2,] "46.30" "44.92" "...
2011 Sep 27
2
Coercing a character zoo to a numeric
Dear R-helpers, It seems to me that a character zoo cannot be coerced to a numeric zoo. Below is a minimal example. Can someone tell me what I have done wrong? > z<-zoo(1:4,order.by=1:4) > coredata(z)<-as.character(coredata(z)) > str(z) ‘zoo’ series from 1 to 4 Data: chr [1:4] "1" "2" "3" "4" Index: int [1:4] 1 2 3 4 > coredata(z)<-as.numeric(coredata(z)) > str(z) ‘zoo’ series from 1 to 4 Data: chr [1:4] "1" "2"...
2007 Mar 31
1
Problem with S4 inheritance: unexpected re-initialization?
...S4 classes with similar inheritance: SubSubClassA <- SubClassB <- BaseClass SubSubClassB <- SubClassB <- BaseClass In R I am calling the following functions: > library(myclasspkg) > subA <- new("SubClassA",filename="OutSubA",filedir="/Volumes/CoreData/CRAN/Workspaces/rclasspkg",mytitle="TitleSubA") > subsubA <- new("SubSubClassA",filename="MyFileName",filedir="/Volumes/CoreData/CRAN/Workspaces/rclasspkg",subA=subA) > subsubB <- new("SubSubClassB",filename="MyFileNameB&qu...
2006 Nov 29
2
problem with indexing a zoo object
...following : I create 2 zoo objects and then I try to subset one of them using logic. indicesthatpass is a vector of trues and falses but when I send it into bckret, it returns an empty bckret. Obviously it has something to do with bckret being a zoo object and if I do the same subsctripting off of coredata(bckret), I'm confident it will work. But, I need to keep the minute days of bckret. So, I have two questions : 1) is there a way around this ? 2) even if the answer to 1) is yes, there could be some other way better than what I am doing ? It took me a while to even get to this point because...
2011 Mar 26
0
rebuilding vignettes in 2.13-0-alpha fails if name of source dir is not package name
...in R code ... OK * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for possible problems ... NOTE prcurve: no visible global function definition for ?pcget.lam? * checking Rd files ... NOTE prepare_Rd: coreData.Rd:19-20: Dropping empty section \usage prepare_Rd: coreData.Rd:21-22: Dropping empty section \arguments prepare_Rd: coreData.Rd:23-24: Dropping empty section \details * checking Rd metadata ... OK * checking Rd cross-references ... OK * checking for missing documentation entries ... WARNING Undocu...
2009 Mar 03
1
zoo and coredata() classes
...50 6 2009-03-03 13:03:30.520 perf.FilteringPublisher 14981302082 EUR.JPY.SPOT 123.49 123.51 > class(ebs) [1] "data.frame" > class(ebs$bid) [1] "numeric" > any(is.na(ebs$bid)) [1] TRUE > class(ebs$ask) [1] "numeric" > foo <- zoo(ebs) > class(coredata(foo$bid)) [1] "character" So it looks like zoo() might be doing some type coercion. I want to interpolate the NAs using na.locf() and then perform some calculations, but am a bit puzzled as to why zoo is turning the numeric columns into characters. Does anyone know if I am doing...
2006 Nov 23
1
Problem with as.ts(zoo-object)
...est) Error in z[match0(index(a), indexes), ] <- a[match0(indexes, index(a))] : number of items to replace is not a multiple of replacement length > traceback() 7: FUN(X[[1]], ...) 6: lapply(args, f, ret.zoo = retclass %in% c("list", "data.frame")) 5: merge.zoo(zoo(coredata(x), tt), zoo(, tt2)) 4: merge(zoo(coredata(x), tt), zoo(, tt2)) 3: as.ts.zooreg(x) 2: as.ts.zoo(test) 1: as.ts(test) I will use coredata() to resolve the situation in the larger context. Anyway, does anybody know to remove the above error message? Many thanks and best regards, Stefan _________...
2008 Oct 22
1
R 2.8.0 qqnorm produces error with object of class zoo?
Dear list-reader, by running the following script: library(zoo) sessionInfo() search() packageDescription("zoo") data(EuStockMarkets) dax <- as.zoo(EuStockMarkets[1:10, "DAX"]) daxr <- diff(log(dax)) identical(as.vector(qnorm(daxr)), qnorm(coredata(daxr))) qqnorm(coredata(daxr)) qqnorm(daxr) qqnorm() produces an error: > qqnorm(daxr) Fehler in if (xi == xj) 0L else if (xi > xj) 1L else -1L : Argument hat L?nge 0 Calls: qqnorm ... xtfrm.default -> as.vector -> rank -> switch -> .gt Ausf?hrung angehalten However, this...
2012 Jun 02
1
mtext bug
...wever when i run the loop the margin text does not appear ... what gives? here is the code for (col in 1:ncol(xdf)){ par(mar=c(3.5, 4.5, 2, 1), oma=c(2,0,0,0)) ymin = min(xdf[,col]) - 20 ymax = max(xdf[,col]) + 20 png(paste(drive, names(xdf)[col], '.png', sep="")) plot(coredata(yr09_10[,col]), type='l', ylim=c(ymin, ymax), col=1, lwd=2, las=1, xlab="", ylab="", xaxt='n', main=names(xdf)[col]) lines(coredata(yr10_11[,col]), col=2, lwd=2) lines(coredata(yr11_12[,col]), col=3, lwd=2) axis(1, at=c(1:365), labels=format(index(yr...
2011 Apr 19
1
Axes Alignment Problem for Multiple Plots
...to plot, in the same window, two different series, using barplot() for the first one and plot() for the second. What happens is that the second chart has a different axes origin, therefore the final plot is wrong. This piece of code shows the differences between the values of par()$usr: barplot(coredata(Z0), beside=TRUE, ylim=c(0,100)); par()$usr; par(new=T); plot(coredata(Z0), ylim=c(0,100)); par()$usr; I would like to know how it is possible to edit the values of par()$usr[3:4] of the second chart in order to be the same of the first one or, alternatively, how can I plot together...
2007 Mar 16
1
Problems with package containing S4 classes
Dear all, Currently, I am trying to create a test package "testS4" using S4 classes, which I am attaching. Running R CMD check gives the following error: coeurebooks-computer:/Volumes/CoreData/CRAN cs$ R CMD check testS4_0.1.1.tar.gz * checking for working latex ...sh: line 1: latex: command not found NO * using log directory '/Volumes/CoreData/CRAN/testS4.Rcheck' * using R version 2.5.0 Under development (unstable) (2007-02-26 r40806) * checking for file 'testS4/DESCRIPTIO...
2017 Jul 30
4
Kalman filter for a time series
...quot;2011-01-01" End = "2012-12-31" SandP = "^GSPC" windowWidth = 20 tsLength = 100 SAndP.ts = getDailyPrices( SandP, Start, End ) SAndP.ts = SAndP.ts[1:tsLength] SAndP.smoothed = rollapply( data=SAndP.ts, width=windowWidth, FUN=kalmanFilter) par(mfrow=c(1,1)) prices = coredata( SAndP.ts[windowWidth:length(SAndP.ts)]) plot(prices, col="blue", type="l") lines(coredata(SAndP.smoothed), col="magenta") par(mfrow=c(1,1)) [[alternative HTML version deleted]]
2007 Mar 04
1
Problem using callNextMethod() in S4
...lidity This is the output of an R session: > library(methods) > source("testS4.R") > tmp<-new("derivedClass") [1] "---initialize:derivedClass---" [1] "mytitle = MyTitle" [1] "---initialize:baseClass---" [1] "mydir = /Volumes/CoreData/CRAN/Workspaces/tests" > > tmp<-new("derivedClass",myname="testname",mytitle="testitle") [1] "---initialize:derivedClass---" [1] "mytitle = MyTitle" [1] "---initialize:baseClass---" [1] "mydir = /Volumes/CoreData/CRA...
2012 Apr 12
1
Could dynlm function work for xts objects?
...it for xts objects, and error message occurs. Once I coerce it to be an zoo object (by as.zoo), it works. Error message: Error in model.frame.default(formula = dynformula(PIh - PI ~ L(X, 0:i) + : variable lengths differ (found for 'L(X, 0:i)') In addition: Warning messages: 1: In zoo(coredata(x), order.by = index(x), ...) : some methods for ?zoo? objects do not work if the index entries in ?order.by? are not unique 2: In zoo(coredata(x), order.by = index(x), ...) : some methods for ?zoo? objects do not work if the index entries in ?order.by? are not unique
2007 Jul 31
1
A complicated 'aggregate'
Hi, I have a financial (zoo) time series with prices and volumes (although I can get the coredata as a matrix). Due to the data-source some indices have multiple observations. I want to aggregate these according to a weighted average. 11:00:01 34 1000 11:00:01 35 500 11:00:01 35 1000 11:00:02 34 500 11:00:02 35 500 should become 11:00:01 34.6 2500 11:00:02 34.5 1000 I currently do this u...