(1351927518))
Sat Nov 3 20:25:18 2012
Using gmtime in Perl...
DB8 p scalar(gmtime(1351927518))
Sat Nov 3 07:25:18 2012
cheers
Worik
On Fri, Mar 30, 2012 at 3:10 PM, Worik R wor...@gmail.com wrote:
On Fri, Mar 30, 2012 at 2:53 PM, Joshua Ulrich josh.m.ulr...@gmail.comwrote:
On Thu, Mar 29
When I import the library timeSeries I get (at least) the variable USDCHF
imported too.
I would like to delete it, but I cannot. As you can see below.
Clearly I am doing something wrong. What is it?
library(timeSeries)
Loading required package: timeDate
class(USDCHF)
[1] timeSeries
...@gmail.comwrote:
On 12-12-10 4:40 PM, Worik R wrote:
When I import the library timeSeries I get (at least) the variable USDCHF
imported too.
I would like to delete it, but I cannot. As you can see below.
You didn't import timeSeries, you attached it. It is on your search list;
you can see
On Tue, Dec 11, 2012 at 2:27 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote:
On 12-12-10 7:33 PM, Worik R wrote:
Let me restate my question.
Is there a straightforward way of ensuring I can use the variable name
USDCHF?
You can use any legal variable name. The only risk is that you
, env=PAIR.ENV)
returns trhe USDCHF defined in timeSeries
This is very hard!
Worik
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 Worik R
Sent: Monday, December 10
On Tue, Dec 11, 2012 at 7:49 PM, Jeff Newmiller jdnew...@dcn.davis.ca.uswrote:
What about putting your objects in a list, which does not have the search
through parents semantics?
---
You may find it more reliable to
Friends
I need to get R reading from a fifo. I want it to block till there is some
data in the fifo, consume what input it gets there, do some thing with it
then loop back and block again.
Very simple. Yes? No.
The example in the documentation works OK..
zz - fifo(foo-fifo, w+)
If you `source(test.R, keep.source=FALSE)`, you will see that the
line number is not reported.
Not always.
I have code that uses sapply to call another function and all I get back is
the line of the sapply.
Useful but in the 21st century I do think I could get more aid from the
runtime and
wrote:
Hi,
On Thu, Dec 6, 2012 at 12:01 AM, Worik R wor...@gmail.com wrote:
If you `source(test.R, keep.source=FALSE)`, you will see that the
line number is not reported.
Not always.
I have code that uses sapply to call another function and all I get back
is
the line
a lot of time chasing down errors in mine and others
code...
Worik
On Sat, Dec 1, 2012 at 1:47 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote:
On 12-11-30 7:15 PM, Worik R wrote:
How?
This is a script I am running under ess on Emacs
I've never used ESS. You'll need to ask someone
Is it possible to get a line number with an error report?
I have a long script and an error:
Error in `[.xts`(x, xsubset) : subscript out of bounds
It would be very helpful, and save a lot of time, if there was some
indication in the error message which line the error was.
I can find it using
How?
This is a script I am running under ess on Emacs
(Useful information optuion(error=recover)
cheers
Worik
On Sat, Dec 1, 2012 at 12:34 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote:
On 12-11-30 4:22 PM, Worik R wrote:
Is it possible to get a line number with an error report?
Yes
When I say:
Sys.time()
[1] 2012-11-12 21:30:14 NZDT
But that is not what my clock on the wall and my system say. Cannot show
you my clock but...
worik@lemy:/tmp$ date
Tue Nov 13 10:32:20 NZDT 2012
Sys.time() is returning GMT
$version.string
[1] R version 2.14.1 (2011-12-22)
Compiling this little function gets me some strange behaviour
.initDataDir - function(){
if(file.exists(LOCATION)) {
if(as.logical(file.info(LOCATION)[isdir]))return
stop(LOCATION, exists but is not a directory)
}
Z - dir.create(LOCATION)
if(!Z){
stop(geterrmessage())
##
refs found.. I am starting to loose my mind!
A debugger where I could set breakpoints with a little more
granularity than the function level and a little more accessible than
the trace function. What I ideally want is GDB for R.
Does that exist?
cheers
Worik
#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---
Sent from my phone. Please excuse my brevity.
Worik R wor...@gmail.com wrote:
Friends
I clearly donot understand how sapply and vapply work
have to accept I am going to be getting a list and I have to
assemble a matrix in a loop?
cheers
Worik
__
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
- as.vector(V)
length(V2)
[1] 2
V2[1]
[[1]]
[[1]][[1]]
[1] TRUE
[[1]]$ABC
[1] 3.141593
V2[2]
[[1]]
[1] asd
That is astonishing to me! I had no way to predict what would happen.
5 days ago I would have expected the statement as.vector(L) to
produce an error. V[2] - list() did.
cheers
Worik
Message-
From: Worik R [mailto:wor...@gmail.com]
Sent: Wednesday, April 18, 2012 5:05 PM
To: William Dunlap
Cc: r-help
Subject: Re: [R] Can a matrix have 'list' as rows/columns?
[snip]
sapply. In this case I would expect M to be a list. I am gobsmacked that
a list can be considered
On Tue, Apr 17, 2012 at 11:52 PM, David Winsemius dwinsem...@comcast.netwrote:
On Apr 17, 2012, at 12:13 AM, Worik R wrote:
After a lot of processing I get a matrix into M. I expected each row and
column to be a vector. But it is a list.
This behavior is not the result of limitation
After a lot of processing I get a matrix into M. I expected each row and
column to be a vector. But it is a list.
R-Inferno says...
Arrays (including matrices) can be subscripted with a matrix of positive
numbers. The subscripting matrix has as many columns as there are dimensions
in the
Friends
I am extracting sub-sets of the rows of a matrix. Generally the result is
a matrix. But there is a special case. When the result returned is a
single row it is returned as a vector (in the example below an integer
vector). If there are 0, or more than 1 rows returned the result is a
[M[,a]==1000,] (from my example below)
would return NULL, which has class NULL rather than a matrix with zero
rows.
thanks
Worik
On Wed, Apr 11, 2012 at 11:54 AM, David Winsemius dwinsem...@comcast.netwrote:
On Apr 10, 2012, at 7:33 PM, Worik R wrote:
Friends
I am extracting sub-sets
I have a reproducible example of my problem below
On Mon, Mar 26, 2012 at 9:22 AM, Joshua Ulrich josh.m.ulr...@gmail.comwrote:
Given two identical string representations of POSIXct objects, can the
two
objects represent different times?
Yes. Here's an example (from my Ubuntu machine) of
On Fri, Mar 30, 2012 at 2:53 PM, Joshua Ulrich josh.m.ulr...@gmail.comwrote:
On Thu, Mar 29, 2012 at 3:56 PM, Worik R wor...@gmail.com wrote:
I removed the (not so minimal) reproducible example because you can
get the same behavior via:
(s - Sys.time())
[1] 2012-03-29 20:43:35 CDT
Friends
I have an xts that I wish to access.
Browse[2] DATA.ba[[p]][2012-03-20 00:59:57,bid]
bid
2012-03-20 00:59:57 1.4993
So far so good.
Now putting the index into a variable:
Browse[2] Time
[1] 2012-03-20 00:59:57 NZDT
Browse[2] DATA.ba[[p]][Time, bid]
bid
My bad. I should be clearer about the source of my confusion.
Given two identical string representations of POSIXct objects, can the two
objects represent different times?
Where has it gone?
It's hard to say, especially since you give no indication how you
assigned the value to Time. A
I am interested in the package 'rgp'
But
install.packages(rgp)
Installing package(s) into /home/worik/R/x86_64-pc-linux-gnu-library/2.12
(as lib is unspecified)
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
package rgp is not available
It is in cran
Sigh Please note that your df and M are undoubtedly different
objects by now:
Right. Not my most coherent day.
thanks
W
M - matrix(runif(5*20), nrow=20)
colnames(M) - c('a', 'b', 'c', 'd', 'e')
l1 - lm(e~., data=as.data.frame(M))
l1
Call:
lm(formula = e ~ ., data =
Use `lm` the way it is designed to be used, with a data argument:
l2 - lm(e~. , data=as.data.frame(M))
summary(l2)
Call:
lm(formula = e ~ ., data = as.data.frame(M))
And what is the regression being done in this case? How are the
independent variables used?
It looks like
Duh! Silly me! But my confusion persits: What is the regression being
done? See below
On Sat, Dec 3, 2011 at 5:10 PM, R. Michael Weylandt
michael.weyla...@gmail.com wrote:
In your code by supplying a vector M[,e] you are regressing e
against all the variables provided in the data
I really would like to be able to read about this in a document but I
cannot find my way around the documentation properly
Given the code...
M - matrix(runif(5*20), nrow=20)
colnames(M) - c('a', 'b', 'c', 'd', 'e')
ind - c(1,2,3,4)
dep - 5
I can then do...
l2 - lm(M[,dep]~M[,ind]) ## Clearly
It seems obvious to me that the empty string is length 0.
cheers
Worik
[[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
Thanks.
Thinking like a C programmer again
W
On Fri, Nov 11, 2011 at 1:27 PM, Peter Langfelder
peter.langfel...@gmail.com wrote:
On Thu, Nov 10, 2011 at 4:17 PM, Worik R wor...@gmail.com wrote:
It seems obvious to me that the empty string is length 0.
You are using the wrong
Friends
I am looking at Rcpp and I am a bit stuck on a simple matter.
(I am calling R from c++, if there is a better way...)
Given this simple example using the TTR package and the SMA function which
returns a simple moving average
Rcpp::NumericVector rv;
for(int i = 0; i 100; i++){
Friends
I am starting on a (section of the) project where I need to build a matrix
with on the order of 5 million rows and 200 columns
I am wondering if I can stay in R.
I need to do rollapply type operations on the columns, including some that
will be functions of (windows of) two columns.
I
Friends
If I have a matrix such as...
[,1] [,2]
[1,]77
[2,]79
[3,]9 2
[4,]79
And I want to find the row number that has the minimum value of column 2
(row 3 in this case) how can I do it? Is there a simple way?
cheers
Worik
[[alternative HTML
Friends
I am trying to format a number to a string so 2189.745 goes to 2,189.35
and 309283.929 goes to 309,283.93
I have tried to use formatC(X, big.mark=,,drop0trailing=FALSE, format=f)
but it does not get the number of decimals correct. Specifying digits does
not work as that is significant
formatC(round(2189.745, 2), big.mark=,,format=f)
[1] 2,189.7400
Unfortunately this does not work
Worik
On Mon, May 9, 2011 at 11:45 AM, Peter Langfelder
peter.langfel...@gmail.com wrote:
On Sun, May 8, 2011 at 4:41 PM, Worik R wor...@gmail.com wrote:
Friends
I am trying to format
On Mon, May 9, 2011 at 12:06 PM, David Winsemius dwinsem...@comcast.netwrote:
On May 8, 2011, at 8:02 PM, Worik R wrote:
formatC(round(2189.745, 2), big.mark=,,format=f)
[1] 2,189.7400
Unfortunately this does not work
Because you did not follow his example.
That is true. I did
Friends
This is an elementary question. Is there is a built in R function for
finding a sub-string in another string? Like strstr in C.
I can easily roll my own, but if there is a built in that is one less thing
I can do wrong!
cheers
Worik
[[alternative HTML version deleted]]
To improve the efficiency of a process I am writing I would like to cache
results. So I would like a data structure like a hash table.
So if I call Z - f(Y) I can cache Z associated with Y: CACHE[Y] - Z
I am stumped. I expected to be able to use a list for this but I cannot
figure how
Given a vector:
S - c(1,1,0,0,1,1,-1,-1,-1,0,1)
Then I expected lag(S) to give...
c(1,0,0,1,1,-1,-1,-1,0,1)
but instead...
S
[1] 1 1 0 0 1 1 -1 -1 -1 0 1
lag(S)
[1] 1 1 0 0 1 1 -1 -1 -1 0 1
attr(,tsp)
[1] 0 10 1
This is very odd. What is happening?
I get what I
Friends.
I cannot simplify this much, and I think the loop is unavoidable. As a
recovering C programmer I want to avoid loops and in cases like this I
almost allways can by using an apply function. But I suspect in this case
there is nothing I can do.
It is a finance example where a price
I am sure this si a simple problem but the solution is evading me.
I have a list of matrices all with the same number of columns but different
number of rows. The first two columns label the row. The labels are
allways the same for the same row numbers, just some matricies have more
rows.
For
Is there a simple way to put a legend outside the plot area for a simple
plot?
I found... (at http://www.harding.edu/fmccown/R/)
# Expand right side of clipping rect to make room for the legend
*par(xpd=T, mar=par()$mar+c(0,0,0,4))*
# Graph autos (transposing the matrix) using heat colors,
#
I have been examining the Mann-Whitney test closely. And there are two
features of the R implementation that puzzles me. The test statistic is
reported as W and depends on the order of the arguments to the function.
x - c(1,3,5,7,9)
y - x-1
x
[1] 1 3 5 7 9
y
[1] 0 2 4 6 8
wilcox.test(x,
Sorry, I realized that is is fairly easy to test that it is an issue
with which tail of the distribution you use. This should show what is
going on better than my prior message.
1.353946/2 = 0.676973
1 - 0.676973 = 0.323027
0.323027 * 2 = 0.646054
in pt(), the default is lower.tail=TRUE.
...@manchester.ac.ukwrote:
On 16-Jun-10 22:30:39, Worik R wrote:
I have two pairs of related vectors
x1,y1
and
x2,y2
I wish to do a test for differences in means of x1 and y1,
ditto x2 and y2.
I am getting odd results. I am not sure I am using 'pt' properly...
I have not included
I have two pairs of related vectors
x1,y1
and
x2,y2
I wish to do a test for differences in means of x1 and y1, ditto x2 and y2.
I am getting odd results. I am not sure I am using 'pt' properly...
I have not included the raw vectors as they are long. I am interested if I
am using R
If it were not for the fact that I get inconsistent results I would be sure
that I need...
2*pt(stat, df)
Section 8.1 of R-intro.pdf is explicit.
Problem is it gives inconsistent results
Worik
On Thu, Jun 17, 2010 at 10:30 AM, Worik R wor...@gmail.com wrote:
I have two pairs of related
More:
When the t-stat is 0 should I use 'pt' differently?
I have been checking my results and (except for the example I posted) all
the inconsistencies occur when t0
Worik
On Thu, Jun 17, 2010 at 10:30 AM, Worik R wor...@gmail.com wrote:
I have two pairs of related vectors
x1,y1
and
x2
I am puzzled by the scope rules that apply with sapply.
If I want to modify a vector with sapply I tried...
N - 10
vec - vector(mode=numeric, length=N)
test - function(i){
vec[i] - i
}
sapply(1:N, test)
vec
but it not work.
How can this be done?
Worik
[[alternative HTML version
I was careless.
Here is a better example of what I am trying to. With the '-' you
offered.
?-
That was exactly what I needed, thankyou.
cheers
Worik
N - 10
## x simulate a return series
x - runif(N)-.5
## Build an array of cumulative returns of a portfolio starting with $1 as
it changes
Given the following snippet
m.nf.xts - xts(rep(0, length(index(m.xts))), order.by=index(m.xts))
Does R know to cache the index(m.xts) or is it more efficient to say...
m.i - index(m.xts)
m.nf.xts - xts(rep(0, length(m.i)), order.by=index(m.i))
?
cheers
Worik
[[alternative HTML
If I create a vector thusly
v1 - runif(20, min=0, max=1)
v1
[1] 0.9754443 0.6306228 0.3238158 0.3175769 0.6791534 0.6956507 0.3840803
[8] 0.1421328 0.8592398 0.4388306 0.9472040 0.4727435 0.5645302 0.7391616
[15] 0.6116199 0.2727754 0.2657867 0.5261744 0.8764804 0.2032126
And I want to
I am sorry if this is documented in apply's dcumentation or completely
obvious, I could not find or work it out.
Given an matricies Q: 2x3, R:1x3 and S:1x2
apply(Q, 1, '-', R) is 3x2 and apply(Q, 2, '-', S) is 2x3
Why?
cheers
Worik
Q
[,1] [,2] [,3]
[1,]123
[2,] 10 11
Thank you everybody for your help.
I am sure using the information you provided I'll be able to do better than
my current approach of using cat to trace my programmes!
cheers
Worik
[[alternative HTML version deleted]]
__
R-help@r-project.org
I have a large programme that after running half an hour or so fails with an
error
Error in x[value] - NA : only 0's may be mixed with negative subscripts
How can I find out where that error occurs?
If I have to do a binary search using error messages it will take a long
time! Is there some
:58 PM, Worik R wor...@gmail.com wrote:
I have a large programme that after running half an hour or so fails with
an error
Error in x[value] - NA : only 0's may be mixed with negative subscripts
How can I find out where that error occurs?
If I have to do a binary search using error messages
I do not understand this.
I have the same problem and I tried to reproduce it thusly
Q - 3
test - function(q=Q){
cat(q, \n)
}
test()
3
Q - 3
test - function(q=Q){
test2(q, \n)
}
test2 - function(q, a){
cat(q, a)
}
test()
3
Q - 3
test - function(q=Q){
z - paste(q, \n)
test2(z,
I have a zoo object z
z
Value
2003-11-15 2.22
2003-11-17 2.26
2003-11-19 2.28
2003-11-22 2.54
2003-11-26 2.55
I wish to find the entry 2 entries before 2003-11-26. How do I do this?
I thought I might be able to say index(z[2003-11-26]) and have it return 5
so I could then say
How can I implement a stack in R?
I want to push and pop. Every thing I push and pop will be the same
type, but not necessarily an atomic type.
cheers
Worik
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do
I have a xts object with logical data .
tail(q1)
..1
2010-02-19 TRUE
2010-02-22 FALSE
2010-02-23 FALSE
2010-02-24 FALSE
2010-02-25 FALSE
2010-02-26 FALSE
I want to build a xts that records the dates that there is a change. If
TRUE - FALSE it is down if FALSE - TRUE it is up
I
change - c(NA, diff(q1$..1))
will be 1 when ..1 goes from FALSE
to TRUE, -1 for TRUE to FALSE, 0 for no change, and NA
for the first element. You may find it convenient to
change that NA to something else or to not deal with
the first element after computing the diff.
This is very
I am sure this is trivial, but I cannot solve it.
I make a histogram. There are 5 categories 1,...,5 and 80 values and
the histogram does not evenly space the bars.
Bars 1 and 2 have no space between them and the rest are evenly spaced.
How can I get all bars evenly spaced?
The code:
Q5
I have trouble with this:
as.Date(Sep-1981, format=%b-%Y)
Returns NA
From documentation for strftime
'%b' Abbreviated month name in the current locale. (Also matches
full name on input.)
'%Y' Year with century.
What am I doing wrong?
cheers
Worik
[[alternative HTML
Friends
I cannot find this documented anyplace.
I have a data frame with, say, 2 cols
d-data.frame(x=c(1:5), y=seq(from=2, to=10, by=2))
d
x y
1 1 2
2 2 4
3 3 6
4 4 8
5 5 10
And I want to collect each row where the first col is prime. To this end I
have a function is.prime()
I want
Thanks. I have no idea how I did not try that. Sigh!
all good now!
Worik
On Wed, Sep 2, 2009 at 7:04 PM, Stefan Grosse singularit...@gmx.net wrote:
On Wed, 2 Sep 2009 17:12:18 +1200 Worik R wor...@gmail.com wrote:
WR I have a data frame, df that I want to extract some rows from
What you
Friends
I have a data frame, df that I want to extract some rows from
Here is a sample of the data
head(df)
TDate Expiry Underlie Strike CSettle PSettle Futures ExDate
TTE
1 20080102 200801 200803 0.840 0. 0 0.9207 20080104
0.005479452
2 20080102 200801 200803 0.850
This programme
for(T in 1:3){
for(j in 1:(5-1)){
for(k in (j+1):5){
for(l in (j+2):5){
print(paste(1 JKL:, j,k,l,sep= ))
}
}
}
}
Prints out (among other things)
[1] 1 JKL: 4 5 6
That is for(l in (j+2):5) sets l to 6 one more than the upper limit.
cheers
Worik
I have time series data in named vectors. They are all the same length for
the same dates.
The dates are in a separate vector.
I want to create a vector of numeric data for every named series, associated
with the dates in a data.frame.
So if...
Names - c(a, b, c)
d - data.frame(dates=Dates,
I cannot find out how to build data structures as lists of data structures.
I want to do...
r-help@r-project.org
d1 - data.frame(x=1, y=2)
d2 - data.frame(x=1, y=3)
d3 - data.frame(x=21, y=3)
q1 - data.frame(q=d1, n=a)
q2 - data.frame(q=d2, n=a)
q3 - data.frame(q=d3, n=a)
v - vector() or
I am a bit worried I am reinventing the wheel. Isn't there a calendar
system in R?
I have written a function to add months to a date and return the number of
days resulting. I am newish to R so I am hoping there is a package that
can do this sort of date arithmetic for me...
Worik
How can I increment the value of a Date class?
I want to add a day, month or year to a date.
cheers
Worik
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read
I would like to know how many years (including partial years) are between
two dates.
So difftime(20/11/1962, 20/5/1964, units=years) would be about 1.5
But units of years are not available.
cheers
Worik
[[alternative HTML version deleted]]
76 matches
Mail list logo