[R] Optimization help

2012-07-30 Thread Megh Dal
Hi, I have following optimization problem: Min: x1 + x2 +...+ x7 subject to: x1 + x2 >= 80 x2 + x3 >= 65 x3 + x4 >= 40 all xi are ***positive integer***. Can somebody help me in this optimization problem? Thanks for your help __ R-help@r-project.org

[R] Applying ifelse() on different functions

2011-07-30 Thread Megh Dal
Dear all, I am looking for some procedure to apply 'ifelse' condition on function. I have created an alternative to lapply() function with exactly same set of arguments named lapply1(), however with different internal codes. Therefore I want something like, if (some condition) then call lapply1(

[R] Suppressing messages while executing function

2011-07-27 Thread Megh Dal
Dear all, while executing some function, there are some custom messages popping up onto the R console and I do not want to see them. While looking into the corresponding codes of those function, I see that those are coming from message() function. Is there any way to stop those messages coming

[R] Achieving 'reverse-Vech' of a matrix

2011-07-23 Thread Megh Dal
Let say i have a square matrix and applied the 'vech' operator to stack the lower triangular elements into a vector: > Mat <- matrix(1:25, 5) > Mat      [,1] [,2] [,3] [,4] [,5] [1,]    1    6   11   16   21 [2,]    2    7   12   17   22 [3,]    3    8   13   18   23 [4,]    4    9   14   19   24

[R] Seeking help on permutation

2011-07-22 Thread Megh Dal
Let say, I have a character vector of arbitrary length: Vector <- c("a", "b", "c") Using that vector I would like to create a matrix (with number of columns as 2) with all pairwise combinations of those elements, like: Vector <- c("a", "b", "c") Mat     <- rbind(c("a", "b"), c("a", "c"), c("b",

[R] String manipulation

2011-06-26 Thread Megh Dal
Dear all, I have following kind of character vector: Vec <- c("344426", "dwjjsgcj", "123sgdc", "aagha123", "sdh343asgh", "123jhd51") Now I want to split each element of this vector according to numeric and string element. For example in the 1st element of that vector, there is no string elemen

[R] 3D plot with it's quadratic approximation superimposed in same plot

2011-05-23 Thread Megh Dal
Dear all, I would like to draw a 3D plot as shown here http://en.wikipedia.org/wiki/File:NaturalLogarithmAll.png, for this function "f = exp[ 1 - x^2 - y^2]" (this function is some arbitrary!). I am aware of different 3D plotting system in R, however it would be great if I can get that kind of

[R] Custom Zero equivalent in R

2011-05-06 Thread Megh Dal
Hi all, I am to find some way on how I can tell R to use this small number 10^-20 as zero by default. This means if any number is below this then that should be treated as negative, or if I divide something by any number less than that (in absolute term) then, Inf will be displayed etc. I have

Re: [R] String manipulation

2011-02-13 Thread Megh Dal
\D+)(\\d+)(\\D+)(\\d +)", c)[[1]] [1] "ABCFR" "34564" "." "354" "IJVEOJC" "3434""." "36453" Can you please tell me how can I modify that? Thanks, On Sun, Feb 13, 2011 at 11:10 PM, Gabor Grot

[R] String manipulation

2011-02-13 Thread Megh Dal
Please consider following string: MyString <- "ABCFR34564IJVEOJC3434" Here you see that, there are 4 groups in above string. 1st and 3rd groups are for english letters and 2nd and 4th for numeric. Given a string, how can I separate out those 4 groups? Thanks for your time [[alternative

[R] Help need to define method of an s4 class

2011-02-01 Thread Megh Dal
I need some help in defining a "print" method for my new S4 class definition. So fer I have worked like this: setClass("MyClass", sealed=F, representation(slot1 = "list",#create a new class slot2= "vector", slot3 = "vector", slot4 = "vector"))

[R] Comparing lengths of different vectors simultaneously

2011-01-31 Thread Megh Dal
I am looking for an elegant way how I can test the equality of lengths of multiple vectors. For example, this is working fine: > length(rnorm(4)) == length(rnorm(5)) [1] FALSE However this is not: > length(rnorm(4)) == length(rnorm(5)) == length(rnorm(6)) Error: unexpected '==' in "length(rnorm(

[R] Downloading data from internet

2011-01-24 Thread Megh Dal
Dear all, I need to download an excel file from net, on which I have address like http://www.2shared.com/file/MMSMWv4B/MyData.html. Can I somehow directly download this file into my R workbook? Thanks, [[alternative HTML version deleted]] __ R-

[R] Where to find "rcompgen" package?

2010-12-25 Thread Megh Dal
Dear all, can somebody point me from where to download "rcompgen" package? CRAN does not seem to hold that. Installing this package through install.packages() tells this package is not available. Thanks [[alternative HTML version deleted]] __ R

[R] Extracting elements of a particular slot from S4 object

2010-11-06 Thread Megh Dal
Hi there, can anyone tell me how to extract to values of a particular slot for some S4 object? Let take following example: > library(fOptions) > val <-GBSOption(TypeFlag = "c", S = 60, X = 65, Time = 1/4, r = 0.08, b = > 0.08, sigma = 0.30) > val Title: Black Scholes Option Valuation Call:

[R] Recursive algorithm

2010-11-01 Thread Megh Dal
Dear friend, I have to construct some recursive algorithm for which I used some for loop like: res <- vector(length=1) res[1] = 0 for (i in 2:(1+1)) res[i] <- res[i-1]*some function I have noticed that this is taking too much time. Is there any way to speed up things? Thanks,

Re: [R] Problem with merging two zoo objects

2010-10-15 Thread Megh Dal
I dont know whether I am missing something or not: > head(read.zoo(file="f:/dat1.txt", header=T, sep=",", format = "%m/%d/%Y > %H:%M:%S"), tz="GMT") data.open data.high data.low data.close 2010-10-15 73.7 73.7 73.7 73.7 2010-10-15 73.8 73.8 73.8

Re: [R] Problem with merging two zoo objects

2010-10-15 Thread Megh Dal
ects do not work if the index entries in ‘order.by’ are not unique Is it a bug or a rule that for any function, placing of it's arguments matter? Thanks, --- On Sat, 10/16/10, Megh Dal wrote: > From: Megh Dal > Subject: Re: [R] Problem with merging two zoo objects > To: &

Re: [R] Problem with merging two zoo objects

2010-10-15 Thread Megh Dal
th merging two zoo objects > To: "Megh Dal" > Cc: r-h...@stat.math.ethz.ch > Date: Saturday, October 16, 2010, 12:11 AM > On Fri, Oct 15, 2010 at 2:20 PM, Megh > Dal > wrote: > > Dear all, I have following 2 zoo objects. However when > I try to merge those

[R] Problem with merging two zoo objects

2010-10-15 Thread Megh Dal
Dear all, I have following 2 zoo objects. However when I try to merge those 2 objects into one, nothing is coming as intended. Please see below the objects as well as the merged object: > dat11 V2 V3 V4 V5 2010-10-15 13:43:54 73.8 73.8 73.8 73.8 2010-10-15 13:44:15 7

Re: [R] Query on save.image()

2010-10-14 Thread Megh Dal
again the same against "envir". By putting so, what I am going to tell R? Thanks, --- On Thu, 10/14/10, Joshua Wiley wrote: > From: Joshua Wiley > Subject: Re: [R] Query on save.image() > To: "Megh Dal" > Cc: r-h...@stat.math.ethz.ch > Date: Thursday, O

[R] Query on save.image()

2010-10-14 Thread Megh Dal
Can anyone please tell me how can use save.image() function if it is placed within a function (i.e. some level up from the base level environment)? Here I experimented with following codes: #rm(list=ls()) fn <- function() { x <- rnorm(5) save.image("f:/dat.RData") } fn() However I se

[R] Formating a matrix in a exotic way

2010-09-19 Thread Megh Dal
Suppose I have following arbitrary matrix: > set.seed(1) > mat <- matrix(rnorm(6), 3, 2) > mat [,1] [,2] [1,] -0.6264538 1.5952808 [2,] 0.1836433 0.3295078 [3,] -0.8356286 -0.8204684 Now I want to make a simple object like (character type): "-0.6264538,1.5952808;0.1836433,0.3

[R] Splitting a matrix

2010-09-16 Thread Megh Dal
Hi, I was trying to split the following matrix "dat": > set.seed(1) > dat <- matrix(rnorm(4*16), 4, 16) > dat [,1] [,2] [,3][,4][,5][,6] [,7] [,8][,9] [,10] [,11] [1,] -0.6264538 0.3295078 0.5757814 -0.62124058 -0.016

[R] Spliting a text

2010-08-04 Thread Megh Dal
Hi, I want to split a text to seperate numerical and non-numerical portions of that. For example suppose I have a text "abc 3456" and I want to split in 2 parts like "abc" & "3456". Is there any function to do that? Thanks, __ R-help@r-project.org ma

[R] How to understand whether a class is a S3 class?

2010-08-01 Thread Megh Dal
Hi, is there any way to say: "this class 'x' is a S3 class?" For example what is the type of class "data.frame"? Is it a S3 class or S4? How can I get a complete list of all S3 classes currently available? Thanks, __ R-help@r-project.org mailing list

[R] Fw: Having problem to define a subclass, please help me

2010-07-30 Thread Megh Dal
bject of class "numeric" is not valid for slot "y1" in an object of class "b"; is(value, "character") is not TRUE Here my questions are: 1. Why I am getting the prototype object in next to previous example for slots x & y? 2. Why just previous exampl

[R] Having problem to define a subclass, please help me

2010-07-30 Thread Megh Dal
Here I am having problem to define a subclass, specially if I define that subclass after defining initialize() method for its superclass. Here is my code: > setClass("a", representation=list(x="numeric", y="numeric"), > prototype=list(x=rnorm(10), y=rnorm(10))) [1] "a" > setMethod("initialize",

Re: [R] Objects within environment

2010-07-21 Thread Megh Dal
Thanks Duncan, I understood. Your explanation is really great. Thank you so much for your time. --- On Wed, 7/21/10, Duncan Murdoch wrote: > From: Duncan Murdoch > Subject: Re: [R] Objects within environment > To: "Megh Dal" > Cc: r-h...@stat.math.ethz.ch > Date: Wed

Re: [R] Objects within environment

2010-07-21 Thread Megh Dal
7/21/10, Duncan Murdoch wrote: > From: Duncan Murdoch > Subject: Re: [R] Objects within environment > To: "Megh Dal" > Cc: r-h...@stat.math.ethz.ch > Date: Wednesday, July 21, 2010, 4:48 PM > On 21/07/2010 5:57 AM, Megh Dal > wrote: > > Hi all, I

[R] Objects within environment

2010-07-21 Thread Megh Dal
Hi all, I have following environments loaded with my current R session: > search() [1] ".GlobalEnv""package:stats" "package:graphics" "package:grDevices" [5] "package:utils" "package:datasets" "package:methods" "Autoloads" [9] "package:base" How can I find the ob

[R] Downloading data fron web

2010-07-20 Thread Megh Dal
Dear all, I need to download some data from this webpage: http://markets.ft.com/ft/markets/researchArchive.asp Notable thing here is that there are some "fields" to be selected to get the desired data. Is there any R facility to do this directly? Obviously I can do it manually and then just co

[R] Split a time series

2010-07-14 Thread Megh Dal
Hi all, can somebody help me to split a time series (zoo) object on monthwise. For example, suppose I have following time series object: library(zoo) dat1 <- zooreg(rnorm(300), start=as.Date("2009-01-01"), frequency=1) >From dat1, I want to create a list-object dat2 like: dat2[[1]] <- all obser

[R] Need help on index for time series object

2010-07-13 Thread Megh Dal
Dear all, Please forgive me if there is a duplicate post; my previous mail perhaps didnt reach the list... Let say I have following time series library(zoo) > dat1 <- zooreg(rnorm(10), start=as.Date("2010-01-01"), frequency=1) > dat1[c(3, 7,8)] = NA > dat1 2010-01-01 2010-01-02 2010-01-03

[R] A Statistics related question

2010-06-20 Thread Megh Dal
Hi all, good morning, My question is not really R related rather a practical problem and wondering if stat-gurus here can show some light how that can be solved with some statistical/mathematical tool. I have some 10 items on which 10,000 viewers put their views based on some 12 attributes say

Re: [R] Handling character string

2010-06-12 Thread Megh Dal
n wrote: From: jim holtman Subject: Re: [R] Handling character string To: "Megh Dal" Cc: "Erik Iverson" , r-h...@stat.math.ethz.ch Date: Saturday, June 12, 2010, 10:18 PM This is probably what you want: > sub("^[[:space:]]*", "",  "   Now is the ti

Re: [R] Handling character string

2010-06-12 Thread Megh Dal
'', str)" etc, none is working if space is at the 1st position. What would be the correct approach? Thanks, --- On Sat, 6/12/10, Erik Iverson wrote: From: Erik Iverson Subject: Re: [R] Handling character string To: "Megh Dal" Cc: r-h...@stat.math.ethz.ch Date: Saturday, June

[R] Handling character string

2010-06-11 Thread Megh Dal
Dear all, Is there any R function to say these 2 character strings "temp"  and " temp" are actually same? If I type following code R says there are indeed different : > "temp"  == " temp"[1] FALSE Is there any way out? [[alternative HTML version deleted]] ___

[R] Help needed on "switch" function

2010-06-09 Thread Megh Dal
Hi all, Here I am trying to implement the switch() function to choose value of a variable depending on the value of an input variable :   temp1 <- "1"   temp1.name <- switch(temp1,   1 == "aa",   2 == "bb",    

[R] Seeking help on Vectorize()

2010-06-02 Thread Megh Dal
Dear falks, here I have written following function :   fn <- Vectorize(function(x = 1:3, y = 3:6) {     x <- matrix(x, nrow=1)     y <- matrix(y, ncol=1)     dat <- apply(x, 2, function(xx) {   apply(y, 1, function(yy) {   retu

Re: [R] [RGL] Need help to modify current plot

2010-05-18 Thread Megh Dal
] [RGL] Need help to modify current plot To: "Megh Dal" Cc: r-h...@stat.math.ethz.ch Date: Tuesday, May 18, 2010, 3:51 PM Megh Dal wrote: > Dear folks, I have created a plot on RGL device : >  x = 1:6 > y = seq(-12, 5, by=1) > z = matrix(0, length(y), length(x)) > z[13,3

[R] [RGL] Need help to modify current plot

2010-05-18 Thread Megh Dal
Dear folks, I have created a plot on RGL device :   x = 1:6 y = seq(-12, 5, by=1) z = matrix(0, length(y), length(x)) z[13,3] = 1; z[13,4] = 1.011765 surface3d(x, y, t(z), col=rainbow(1000)) grid3d(c("x-", "y-", "z"))   Now I want to draw 2 lines along x=3 & x=4, over the surface (with different c

[R] Protecting elements within a function

2010-05-06 Thread Megh Dal
Hi all, previously I submitted this thread through Nabble which seems fail therefore sending it again suppose I have written following function :  > fn = function(x) return(x+x^2)  > fn  function(x) return(x+x^2)  Here you see, if I type only the function name all inside information of this

[R] Defining a "list"

2008-10-15 Thread Megh Dal
Can anyone please tell me how to define a "list". Suppose I want to define a list object "result" with length n then want to fill each place of "result" with different objects. For e.g. i=1 result[1] = rnorm(1) i=2 result[2] = rnorm(2) ... i=n result[n] = rnorm(n) What wo

Re: [R] Extracting subset of a vector

2008-10-11 Thread Megh Dal
ector > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Date: Sunday, October 12, 2008, 1:06 AM > Hi Megh, > Try this: > > x<-c(100,96,88,100,100,96,80,68,92,96,88,92,68,84,84,88,72,88,72,88) > x1 = sample(x, 5, replace=FALSE) > > x[ ! x %in% x1] > > HTH,

[R] Extracting subset of a vector

2008-10-11 Thread Megh Dal
I have 2 vecros : x<-c(100,96,88,100,100,96,80,68,92,96,88,92,68,84,84,88,72,88,72,88) x1 = sample(x, 5, replace=FALSE) Now i want to get remaining values of vector "x" those are not member of vector "x1". Can anyone please tell me how to do that? __ R

[R] Error in Q-Q plot

2008-10-06 Thread Megh Dal
Hi, I am trying to draw a Q-Q plot, however got following error. > library(sn) > library(car) > dat1 = rst(1000, 0, 1, 0, 2) > qq.plot(dat1, "st", 0, 1, 0, 9) Error in plot.window(...) : invalid value specified for graphical parameter "las" Can anyone please tell me why this error is coming?

Re: [R] Adding plane in a 3D scatterplot

2008-10-02 Thread Megh Dal
$year [1] "2008" $month [1] "06" $day [1] "23" $`svn rev` [1] "45970" $language [1] "R" $version.string [1] "R version 2.7.1 (2008-06-23)" --- On Thu, 10/2/08, Uwe Ligges <[EMAIL PROTECTED]> wrote: > From: Uwe Ligges <[EM

[R] Adding plane in a 3D scatterplot

2008-10-02 Thread Megh Dal
I have drawn a 3D scatter plot : library(mnormt) library(scatterplot3d) dat = cbind(rmnorm(3, rep(0,2), diag(2)), 1:3) scatterplot3d(dat) Now I want to do 2 things : 1 : In the Z-axis (i.e. height), I want to see only numbers 1,2,3, etc NOT, 1,1.5,2,2.5. 2. I want to add two Horizo

[R] error in fBasics package

2008-09-30 Thread Megh Dal
When I try to load "fBasics" package, I get following error/warning : > library(fBasics) Loading required package: fImport Loading required package: fSeries Loading required package: fBasics Loading required package: fImport Loading required package: fSeries Loading required package: fBasics Loadi

[R] Generating a valid covariance matrix

2008-09-26 Thread Megh Dal
I want to generate a valid variance-covariance matrix. One way could be to generate some random sample from multivariate normal distribution and then calculate cov. matrix. Another way could be to sample from wishart distribution itself. However both cases need a valid i.e. PD covariance matrix.

[R] Symmetric matrix

2008-09-21 Thread Megh Dal
I have following matrix : a = matrix(rnorm(36), 6) Now I want to replace the lower-triangular elements with it's upper-triangular elements. That is I want to make a symmetric matrix from a. I have tried with lower.tri() and upper.tri() function, but got desired result. Can anyone please tell m

Re: [R] Loop on vector name

2008-09-18 Thread Megh Dal
t;- rnorm(6) > dat3 <- rnorm(7) > > lis <- lapply(paste("dat", 1:3, sep = > ""), get) > lis > output <- sapply(lis, sd) > print(output) > print(str(output)) > > > > On Fri, Sep 19, 2008 at 1:44 AM, Megh Dal wrote: > > &g

Re: [R] Loop on vector name

2008-09-18 Thread Megh Dal
norm(7) > > lis <- lapply(paste("dat", 1:3, sep = > ""), get) > lis > sapply(lis, sd) > > > I hope it helps. > > Best, > Dimitris > > > Megh Dal wrote: > > [My previous message rejected, therefore I am sending > sa

[R] Loop on vector name

2008-09-17 Thread Megh Dal
[My previous message rejected, therefore I am sending same one with some modification] I have 3 vectors with object name : dat1, dat2, dat3 Now I want to create a loop, like : for (i in 1:3) { cat(sd(dati)) } How I can do this in R? Regards,

[R] Woring message in as.yearmon()

2008-09-10 Thread Megh Dal
I have following dataset: > res [,1] [,2] [,3] [1,] 19464 1.27 [2,] 19465 1.27 [3,] 19466 1.27 [4,] 19467 1.27 [5,] 19468 1.52 [6,] 19469 1.52 [7,] 1946 10 1.52 [8,] 1946 11 1.52 [9,] 1946 12 1.62 [10,] 19471 1.62 [11,] 19472 1.62 [12,] 1947

[R] How to find where is the in data

2008-09-10 Thread Megh Dal
I have following " 1975 01 7711.16" Here I need to identify where the is there and then concatenate rest of the digits without , i.e. I want to have "1975017711.16". Is there any R function? Regards, __ R-help@r-project.org mailing list https://sta

Re: [R] Compiling date

2008-09-10 Thread Megh Dal
t; Subject: Re: [R] Compiling date > To: "David Scott" <[EMAIL PROTECTED]> > Cc: "Dr Eberhard W Lisse" <[EMAIL PROTECTED]>, "Megh Dal" <[EMAIL > PROTECTED]>, [EMAIL PROTECTED] > Date: Tuesday, September 9, 2008, 11:37 PM > Is this Month-D

[R] Compiling date

2008-09-08 Thread Megh Dal
Hi, I have following kind of dataset (all are dates) in my Excel sheet. 09/08/08 09/05/08 09/04/08 09/02/08 09/01/08 29/08/2008 28/08/2008 27/08/2008 26/08/2008 25/08/2008 22/08/2008 21/08/2008 20/08/2008 18/08/2008 14/08/2008 13/08/2008 08/12/08 08/11/08 08/08/08 08/07/08 However I want to use

Re: [R] Interactive plot

2008-07-24 Thread Megh Dal
gt; Cc: [EMAIL PROTECTED] > Date: Thursday, July 24, 2008, 5:42 PM > On 7/24/2008 7:34 AM, Megh Dal wrote: > > I have created following interactive plot : > > > > library(TeachingDemos) > > plott = function(x) > >{ > > return(hist(rnorm(as.integer(10

[R] Interactive plot

2008-07-24 Thread Megh Dal
I have created following interactive plot : library(TeachingDemos) plott = function(x) { return(hist(rnorm(as.integer(1000, 10, x)), xlab=NA)) } tkexamp(plott, list(x=list('slider',from=1,to=40, resolution=0.1, init=2)), plotloc='top') Here everything works fine, but the problaem is wh

Re: [R] scatter plot using ggplot

2008-07-22 Thread Megh Dal
--- On Tue, 7/22/08, hadley wickham <[EMAIL PROTECTED]> wrote: > From: hadley wickham <[EMAIL PROTECTED]> > Subject: Re: [R] scatter plot using ggplot > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Date: Tuesday, July 22, 2008, 10:00 PM > On Tue, Jul 22, 2008

[R] scatter plot using ggplot

2008-07-22 Thread Megh Dal
I used ggplot to create a scatter plot : library(ggplot) library(mnormt) Sigma = matrix(c(1, 0.6, 0.6, 1), 2, 2) x = rmnorm(20, c(0,0), Sigma) xx = x[order(x[,1]),] y = xx[,1] z = xx[,2] qplot(z, y, type="point", main="x-y plot", xlab="x", col="blue") However I want following: 1. Plot color must

[R] How to extract folowing data?

2008-07-14 Thread Megh Dal
Hi, following data is taken from http://www.economagic.com/em-cgi/data.exe/var/west-texas-crude-long. Problem with this data is when you copy it from this site you would get something like that : 1946 063331.27 1946 079991.27 1946 087771.52 1946 096661.52 They should be interpret in follo

Re: [R] Error in defining function

2008-07-07 Thread Megh Dal
; to a function separately. > > Try this: > > funs <- c("Mean", "SD") > f <- function(fun) aggregate(data1, as.yearqtr, > get(fun)) > do.call(cbind, sapply(tolower(funs), f, simplify = FALSE)) > > > On Sun, Jul 6, 2008 at 10:43 PM, Megh D

Re: [R] Error in defining function

2008-07-06 Thread Megh Dal
ndieck <[EMAIL PROTECTED]> > Subject: Re: [R] Error in defining function > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Date: Monday, July 7, 2008, 1:23 AM > On Sun, Jul 6, 2008 at 3:19 PM, Megh Dal > <[EMAIL PROTECTED]> wrote: > > Can anyone please tell me

[R] Error in defining function

2008-07-06 Thread Megh Dal
Can anyone please tell me why I am getting this error? library(zoo) Z.index <- as.Date(sample(12450:15500, 3000)) Z.data <- matrix(rnorm(300), ncol = 1) data1 <- zoo(Z.data, Z.index) fnc = function(data1) { selection2 = select.list(c("Mean"), multiple = F) Mean = function(dataa) me

[R] Calculating quarterly statistics for time series object

2008-06-29 Thread Megh Dal
I have time series observation on daily frequencies : library(zoo) SD=1 date1 = seq(as.Date("01/01/01", format = "%m/%d/%y"), as.Date("12/31/02", format = "%m/%d/%y"), by = 1) len1 = length(date1); data1 = zoo(matrix(rnorm(len1, mean=0, sd=SD*0.5), nrow = len1),  date1) plot(data1) Now I want

[R] expand.grid() function

2008-06-23 Thread Megh Dal
Hi, I have one question on expand.grid() function. When I write following syntax :expand.grid(c("u", "l"), c("u", "l"), c("u", "l")) I get following as desired : Var1 Var2 Var3 1uuu 2luu 3ulu 4llu 5uul 6lul 7

[R] write.table() error

2008-06-05 Thread Megh Dal
Hi, I got following error in write.table() : > write.table(dataa, file="c:/data1.csv", row.names=F, col.names=T, sep=",") Error in file(file, ifelse(append, "a", "w")) : cannot open the connection In addition: Warning message: In file(file, ifelse(append, "a", "w")) : cannot open file 'c:/d

Re: [R] Creating zoo object on monthly time series

2008-06-01 Thread Megh Dal
please provide the dput output as requested. On Sun, Jun 1, 2008 at 9:59 AM, Megh Dal wrote: >> packageDescription("zoo")$Version > [1] "1.1-1" > > > Gabor Grothendieck wrote: > > You need to unambiguously specify what your data > looks like. Ple

Re: [R] Creating zoo object on monthly time series

2008-06-01 Thread Megh Dal
scription("zoo")$Version On Sun, Jun 1, 2008 at 9:37 AM, Megh Dal wrote: > I got following: > >> z <- zoo(data1[,3], as.yearmon(data1[,1], "%b-%y")) >> head(z) > Jan 0001 Jan 0002 Jan 0003 Jan 0004 Jan 0005 Jan 0006 > 1206.68 782.45 1187.00 13

Re: [R] Creating zoo object on monthly time series

2008-06-01 Thread Megh Dal
ad(z) 0001-01-01 0002-01-01 0003-01-01 0004-01-01 0005-01-01 0006-01-01 1206.68 782.451187.001398.771883.231431.80 Nowhere 1980 is coming. Any better suggestion? Gabor Grothendieck <[EMAIL PROTECTED]> wrote: On Sun, Jun 1, 2008 at 8:47 AM, Gabor Grothendieck wrote

[R] Creating zoo object on monthly time series

2008-06-01 Thread Megh Dal
Hi all, I have following monthly time series : > head(data1) V1 V2 V3 1 Nov-80 NA 1007.44 2 Dec-80 NA 982.05 3 Jan-81 NA 994.25 4 Feb-81 NA 996.31 5 Mar-81 NA 939.91 6 Apr-81 NA 923.32 Now I want to convert it to a 'zoo' object. I wrote following syntax : ss = zoo(data1[,3], as.

Re: [R] Solution of function

2008-05-09 Thread Megh Dal
Still I did not find any suggestion. Is my problem not elaborate enough? Megh Dal <[EMAIL PROTECTED]> wrote: I think I should be clear exactly what I want : take following example : a = b = seq(1, 5, by=500) v = matrix(0, nrow=length(a), ncol=length(a)) for (i in 1:le

[R] solve.QP() error

2008-05-08 Thread Megh Dal
I got following error while I was using solve.QP() in my problem: > Dmat = matrix(c(0.0001741, 0.0001280, 0.0001280, 0.0002570), nrow=2) > dvec = t(c(0,0)) > Amat = matrix(c(-1,1,0,-1,0, 1,0,1,0,-1), nrow=5) > bvec = c(-2, 1, 1, -5, -5) > solve.QP(Dmat,dvec,Amat,bvec=bvec) Error i

Re: [R] Solution of function

2008-05-07 Thread Megh Dal
uot;green"), alpha=0.7,aspect=c(1,1,0.5)) Here you see that the surface is the plot of a x'Cx for different values of components of x. And the red region is the portion of that plot that satisfy 0 wrote: Megh Dal wrote: > Hi, > > I want to find solution of function :

[R] Fwd: Re: Solution of function

2008-05-07 Thread Megh Dal
Forgot to send one copy to R help. Sorry Megh Dal <[EMAIL PROTECTED]> wrote: Date: Wed, 7 May 2008 02:45:09 -0700 (PDT) From: Megh Dal <[EMAIL PROTECTED]> Subject: Re: [R] Solution of function To: Berwin A Turlach <[EMAIL PROTECTED]> Hi Berwin, Thanks for having

[R] Solution of function

2008-05-07 Thread Megh Dal
Hi, I want to find solution of function : f(x,y) = x'Cx - a under constraints : 0 < x,y < p 0 < x-y< q where a, p,q are given constants and x = (x, y) and C is a 2X2 matrix (given) Can anyone suggest me any R function to do that? -

[R] How to put different color in some portion of a surface plot?

2008-05-06 Thread Megh Dal
Hi all, I have following problem : a = b = seq(1, 5, by=500) v = matrix(0, nrow=length(a), ncol=length(a)) for (i in 1:length(a)) { for (j in 1:length(a)) { d = c(17989*a[i], -18109*b[j]) v[i,j] = t(d) %*% matrix(c(0.0001741, 0.0001280, 0.0001280, 0.000

[R] Constructing dummy variables for months for a time series object

2008-04-25 Thread Megh Dal
I have a TS of monthly observations. head(data4) 1991(1) 1991(2) 1991(3) 1991(4) 1991(5) 1991(6) 12.00864 11.94203 11.98386 12.01900 12.19226 12.15488 Now I want to make 11 dummy variables indicating months. Therefore I did followings : For Jan : rep(c(rep(0,0), 1, rep(0,

[R] Incompleteness (or bug ?) in mAr.est for VAR estimation

2008-03-23 Thread Megh Dal
Hi all, I feel there is a incompleteness in mAr.est function in mAr package for VAR estimation. I does not cheak whether there is multicolinearity in data set. Here I used mAr.est function for following dataset : > head(log(data1) + ) V1 V2 V3 V4 V5

[R] Fwd: Re: How to create following chart for visualizing multivariate time series

2008-03-15 Thread Megh Dal
g Previously I tried with image() function [however there is also no option to put a color pallet :( ], there is a option 'zlim' to trim the not-required values. Is there any option in levelplot() function as well? I already gone through it's help file, however got nothing on th

Re: [R] How to create following chart for visualizing multivariate time series

2008-03-15 Thread Megh Dal
plot(Z) etc However I can not reproduce this example in my problem. How I can change my data matrix 'dat' to 'Z' ? If anyone show me some light it would be great for me. Regards, Megh Dal <[EMAIL PROTECTED]> wrote: Roy Mendelssohn <[EMAIL

[R] Error in extracting monthly observation from a daily time series data

2008-03-10 Thread Megh Dal
Hi all, Suppose I have following dataset : library(zoo) SD = 1 date1 = seq(as.Date("01/01/90", format = "%m/%d/%y"), as.Date("12/31/08", format = "%m/%d/%y"), by = 1) len1 = length(date1); data1 = zoo(matrix(rnorm(len1, mean=0, sd=SD*0.5), nrow = len1), date1) Now I want to extr

[R] Formating a zoo dataset .

2008-03-02 Thread Megh Dal
Suppose I have following dataset : > head(data1) Date Return 1 03/31/00 0.14230650 2 04/28/00 -0.03276228 3 05/31/00 -0.06527890 4 06/30/00 -0.04999873 5 07/31/00 -0.01447902 6 08/31/00 0.22265729 Now I convert it to zoo object : > data11 = zoo(data1[,2], as.Date(data1[,1],

[R] A question on getting all possible combinations

2008-03-01 Thread Megh Dal
Hi all, Suppose I have to letters 'u' and 'd'. Now I want to find all combinations like that : uu ud du . dd This type of combination generally required for Option Pricing in financial/derivative market. Here generally 'u' means: up-move and 'd' means down mo

Re: [R] Fwd: Re: How to create following chart for visualizing multivariate time series

2008-02-28 Thread Megh Dal
(-4*pi, 4*pi, len=27) r <- sqrt(outer(x^2, y^2, "+")) image(x, y, r, col=gray((0:32)/32)) colors <- colorRampPalette(c('red', 'yellow', 'blue')) # create you color spectrum image(x,y,r, col=colors(100)) On Thu, Feb 28, 2008 at 9:28 PM, Megh Dal wrote: >

[R] Fwd: Re: How to create following chart for visualizing multivariate time series

2008-02-28 Thread Megh Dal
ng link]. If anyone here tell me how to do that, it will be good for me. Regards, Megh Dal <[EMAIL PROTECTED]> wrote: Hi all, Can anyone here please tell me whether is it possible to produce a chart displayed in http://www.datawolf.blogspot.com/ in R for visualizing multivariate tim

Re: [R] Calculating monthly var-cov matrix on non-overlapping rooling window basis

2008-02-27 Thread Megh Dal
else(dim(data1)[1] > 1, cov, var)) Still I am getting error. What to do? Henrique Dallazuanna <[EMAIL PROTECTED]> wrote: Perhaps something like this: lapply(split(data1, format(index(data1), "%m")), cov) On 27/02/2008, Megh Dal wrote: > let create a 'zoo' obje

[R] Calculating monthly var-cov matrix on non-overlapping rooling window basis

2008-02-27 Thread Megh Dal
let create a 'zoo' object : library(zoo) date.data = seq(as.Date("01/01/01", format = "%m/%d/%y"), as.Date("06/25/02", format = "%m/%d/%y"), by = 1) len = length(date.data) data1 = zoo(matrix(rnorm(2*len), nrow = len), date.data ) head(data1) Now I want to create an 3 dimensio

[R] Stat related question : Skew Normal distribution

2008-02-20 Thread Megh Dal
Hi, I would like to ask here one stat related question. Suppose Z ~ Skew-Normal(0,1,1). Now I want to find a variable f: Z -> Y which has Y~ Skew-Normal(0,1,lambda) distribution. Can anyone give me some light how to do that? Regards, - [[a

[R] Stat related question : Skew Normal distribution

2008-02-20 Thread Megh Dal
Hi, I would like to ask here one stat related question. Suppose Z ~ Skew-Normal(0,1,1). Now I want to find a variable f: Z -> Y which has Z ~ Skew-Normal(0,1,lambda) distribution. Can anyone give me some light how to do that? Regards, - [[

[R] How to create following chart for visualizing multivariate time series

2008-02-03 Thread Megh Dal
Hi all, Can anyone here please tell me whether is it possible to produce a chart displayed in http://www.datawolf.blogspot.com/ in R for visualizing multivariate time series? If possible how? Regards, - [[alternative HTML version deleted]] __

Re: [R] Multiplying each row of a big matrix with a vector

2008-01-30 Thread Megh Dal
) +44 (0)207 004 2968 (Direct Fax) Please visit our Web site at www.ssga.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Attiglah, Mama Sent: 30 January 2008 11:32 To: Megh Dal; [EMAIL PROTECTED] Subject: Re: [R] Multiplying each row of a big matrix wit

[R] Multiplying each row of a big matrix with a vector

2008-01-29 Thread Megh Dal
I have a big matrix 'ret'. I want to multiply each row of it with a 2nd vector 'pos', resulting result, I want to save in a vector named 'port'. I wrote following code: > pos [1] 2593419 2130220 6198197 1673888 198 1784732 2052120 -7490228 -5275000 > dim(ret) [1] 500 9

[R] Help needed on Normality test

2008-01-29 Thread Megh Dal
Hi all T gurus, I would like to test if my dataset is indeed from N(0, 0.011908969). K.S. test gives following result: > ks.test(data, "pnorm", 0, 0.011908969) One-sample Kolmogorov-Smirnov test data: data D = 0.1092, p-value = 1.318e-05 alternative hypothesis: two-s

[R] Number of ways to select population members

2007-12-13 Thread Megh Dal
Hi all, Suppose I have a population of 3 alphabets : A, B, C. From this population, number of ways that any 2 can be chosen is 3 i.e. AB, AC, and BC. Is there any R function to generalize this process, for any number of alphabets/numbers and for any sub-sample size? Thanks and r

[R] Fetching datapoints from a Time Series

2007-10-24 Thread Megh Dal
Hi all, I have a time series like that : DateValue 01/03/05 -0.008471364 01/04/05 -0.008153802 01/05/05 -0.000780031 01/06/05 -0.000130064 01/07/05 -0.000650576 01/08/05 -0.000130166 01/10/05 -0.004174282 01/11/05 0.01027384 01/12/05 -0.006099558 01/13/05 -0.0

[R] Fetching datapoints from a Time Series

2007-10-24 Thread Megh Dal
Hi all, I have a time series like that : DateValue 01/03/05 -0.008471364 01/04/05 -0.008153802 01/05/05 -0.000780031 01/06/05 -0.000130064 01/07/05 -0.000650576 01/08/05 -0.000130166 01/10/05 -0.004174282 01/11/05 0.01027384 01/12/05 -0.006099558 01/13/05 -0.0

  1   2   >