[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

[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, c)); Mat  # number of

[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 element. Therefore

[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

[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

Re: [R] String manipulation

2011-02-13 Thread Megh Dal
IJVEOJC 3434. 36453 Can you please tell me how can I modify that? Thanks, On Sun, Feb 13, 2011 at 11:10 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sun, Feb 13, 2011 at 10:27 AM, Megh Dal megh700...@gmail.com wrote: Please consider following string: MyString

[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

[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] 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] 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,

[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

Re: [R] Problem with merging two zoo objects

2010-10-15 Thread Megh Dal
: [R] Problem with merging two zoo objects To: Megh Dal megh700...@yahoo.com 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 megh700...@yahoo.com wrote: Dear all, I have following 2 zoo objects. However when I try to merge

Re: [R] Problem with merging two zoo objects

2010-10-15 Thread Megh
I have compared dat11 and x using str() function, however did not find drastic difference: str(dat11) ‘zoo’ series from 2010-10-15 13:43:54 to 2010-10-15 13:49:51 Data: num [1:7, 1:4] 73.8 73.8 73.8 73.8 73.8 73.8 73.7 73.8 73.8 73.8 ... - attr(*, dimnames)=List of 2 ..$ : chr [1:7] 7 6 5

Re: [R] Problem with merging two zoo objects

2010-10-15 Thread Megh
Thanks Gabor for pointing to my old version. However I got one more question why the argument tz= is sitting there? As you are not passing any explicit value for that, I am assuming it is redundant. Without any tz argument, I got following: head(read.zoo(file=f:/dat1.txt, header=T, sep=,,

Re: [R] Problem with merging two zoo objects

2010-10-15 Thread Megh Dal
matter? Thanks, --- On Sat, 10/16/10, Megh Dal megh700...@yahoo.com wrote: From: Megh Dal megh700...@yahoo.com Subject: Re: [R] Problem with merging two zoo objects To: Gabor Grothendieck ggrothendi...@gmail.com Cc: r-help@r-project.org Date: Saturday, October 16, 2010, 7:20 AM I dont know

Re: [R] Problem with merging two zoo objects

2010-10-15 Thread Megh Dal
the time component. Where I am going wrong? Thanks, --- On Sat, 10/16/10, Gabor Grothendieck ggrothendi...@gmail.com wrote: From: Gabor Grothendieck ggrothendi...@gmail.com Subject: Re: [R] Problem with merging two zoo objects To: Megh megh700...@yahoo.com Cc: r-help@r-project.org Date: Saturday

[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 see

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

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

[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):

[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.01619026

[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 mailing

[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

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

2010-07-31 Thread Megh
Still no reply on my query. Is it not understandable? Can I reformulate better my question? Thanks, -- View this message in context: http://r.789695.n4.nabble.com/Having-problem-to-define-a-subclass-please-help-me-tp2308170p230.html Sent from the R help mailing list archive at Nabble.com.

[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, a,

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

2010-07-30 Thread Megh Dal
understanding, all defined law for super-class should be inherited by it's sub-class, therefore no need to define again. I would be really grateful if someone clarify those. Thanks --- On Fri, 7/30/10, Megh Dal megh700...@yahoo.com wrote: From: Megh Dal megh700...@yahoo.com Subject: Having problem

[R] Objects within environment

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

Re: [R] Objects within environment

2010-07-21 Thread Megh Dal
: [R] Objects within environment To: Megh Dal megh700...@yahoo.com 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 have following environments loaded with my current R session: search() [1] .GlobalEnv

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 murdoch.dun...@gmail.com wrote: From: Duncan Murdoch murdoch.dun...@gmail.com Subject: Re: [R] Objects within environment To: Megh Dal megh700...@yahoo.com Cc

[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

[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

[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
attribute through a binary variable like 1 - positive, -1 - negative. Is their any a mathematical/statistical tool available to answer thise type of question. If anyone help me out I would be very grateful. Thanks for your attention. Megh, __ R

Re: [R] Handling character string

2010-06-12 Thread Megh Dal
/12/10, Erik Iverson er...@ccbr.umn.edu wrote: From: Erik Iverson er...@ccbr.umn.edu Subject: Re: [R] Handling character string To: Megh Dal megh700...@yahoo.com Cc: r-h...@stat.math.ethz.ch Date: Saturday, June 12, 2010, 2:36 AM Megh Dal wrote: Dear all, Is there any R function to say these 2

Re: [R] Handling character string

2010-06-12 Thread Megh Dal
...@gmail.com Subject: Re: [R] Handling character string To: Megh Dal megh700...@yahoo.com Cc: Erik Iverson er...@ccbr.umn.edu, 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 time) [1] Now is the time You need

[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) {  

[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

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

2010-05-18 Thread Megh Dal
Murdoch murdoch.dun...@gmail.com Subject: Re: [R] [RGL] Need help to modify current plot To: Megh Dal megh700...@yahoo.com 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

[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] Need help to split a given matrix is a sequential way

2010-03-30 Thread Megh
I need to split a given matrix in a sequential order. Let my matrix is : dat - cbind(sample(c(100,200), 10, T), sample(c(50,100, 150, 180), 10, T), sample(seq(20, 200, by=20), 10, T)); dat [,1] [,2] [,3] [1,] 200 100 80 [2,] 100 180 80 [3,] 200 150 180 [4,] 200 50 140

[R] R function to delete a csv file from disk

2010-03-20 Thread Megh
Is there any R function to delete a CSV file saved in disk? For example here I have created following R function : asd - function(a = 5) { dat - read.delim(file=F:/Test.csv, header=T, sep=,) res - dat[1,1]*a # Here I want to delete Test.csv return(res) } Here I am looking

Re: [R] R-Excel Macro Problem

2010-03-13 Thread Megh
Hi, I was trying to run your code in my VBA editor, however could not succeed. The execution stumbled in the line Call Rinterface.StartRServer itself. I have RCOM package installed into my R environment. Do I need to install anything else to run that? Would guys here guide me? Thanks -- View

[R] Interactive plot (histogram) in R..........possible?

2010-02-16 Thread Megh
Dear all, I am looking for some kind of interactive plot to draw a histogram for a normal distribution with different sample size. In that plot there would be some sort of scroll-bar which will take min value 10 and maximum value of 10,000 as sample size (n) from a standard normal distribution.

[R] Chainging monthly data to daily data

2010-01-01 Thread Megh
Hi, I have a zoo object with monthly frequency : library(zoo) dat - zooreg(rnorm(50), as.yearmon(2000-01-01), frequency=12) Now I want to make a zoo object with daily frequency from dat wherein value for a each day for a particular month will be value of dat at that particular month. Is there

Re: [R] Chainging monthly data to daily data

2010-01-01 Thread Megh
idea please? Megh wrote: Hi, I have a zoo object with monthly frequency : library(zoo) dat - zooreg(rnorm(50), as.yearmon(2000-01-01), frequency=12) Now I want to make a zoo object with daily frequency from dat wherein value for a each day for a particular month will be value of dat

Re: [R] [GGPLOT] Legends at different layers

2009-12-26 Thread Megh
+ scale_colour_discrete(legend = F) Hadley On Mon, Dec 7, 2009 at 11:17 AM, Megh megh700...@yahoo.com wrote: Here I have following code : dat = rnorm(100) ggplot() + geom_histogram(aes(dat, fill=..count..)) + scale_fill_gradient(Count, low=green, high=red) + opts(legend.position=none

[R] A Date related problem

2009-12-15 Thread Megh
Dear all, Please consider following date as.Date(2009-02-01). If I subtract 1 then it will give last day, similarly if I subtract 2 it will give 2nd last day. But what about if I want to get last month, 2md last month i.e. 2009-01-01 or 2008-12-01 etc or even year? Is there any automated way

[R] A GGPLOT ploting question

2009-12-07 Thread Megh
library(ggplot2) m - ggplot(movies, aes(x=rating)) m + geom_histogram() Now in x-axis instead of numbers like 2,4,6,8,10..., I want to write like 2%,4%,6%,8%,10%... Is there any way to do that through GGPLOT ? Your help will be highly appreciated. Thanks, -- View this message in context:

[R] [GGPLOT] Legends at different layers

2009-12-07 Thread Megh
Here I have following code : dat = rnorm(100) ggplot() + geom_histogram(aes(dat, fill=..count..)) + scale_fill_gradient(Count, low=green, high=red) + opts(legend.position=none) # Above is without any legend ## Now I want to place two points with legends dat1 - data.frame(c(0,0), c(1,0)); Label

Re: [R] A ggplot question

2009-12-02 Thread Megh
of them. My question is how I can remove the color-pallet. Your help will be highly appreciated. Thanks, Megh wrote: Thanks Ista for your mail. Here I wanted to have control on color-pallet. It is because, here my entire plot window is subdivided in 3 sub-plots horizontally, on basis

[R] Problem in reading data

2009-12-01 Thread Megh
In my Excel file, I have data in following format : Feb-07 38.49 Mar-07 39.95 Apr-07 37.47 May-07 35.77 Jun-07 32.96 Jul-07 33.27 I tried to copy this data as a time series using following code : library(zoo) dat - read.zoo(file=clipboard, format=%m-%y) However getting following error :

[R] A ggplot question

2009-12-01 Thread Megh
Let consider following plot : p - ggplot(mtcars, aes(mpg, wt)) p + geom_point(colour=grey50, size = 4) + geom_point(aes(colour = cyl)) Now I want R to hide the color-pallet on cyl, placed in the right edge completely. Can anyone please guide me how to do that? Thanks, -- View this

Re: [R] A ggplot question

2009-12-01 Thread Megh
? Thanks, Ista Zahn wrote: There was a recent discussion of the ggplot2 mailing list about a similar issue. The first question is how will people know what the colors mean if you remove the legend? -Ish On Tue, Dec 1, 2009 at 11:41 PM, Megh megh700...@yahoo.com wrote: Let consider

[R] How to get last day of a month?

2009-09-13 Thread megh
Is there any R function to calculate automatically the last day of a particular month? For example sep2009 should be converted to last day of September of 2009? Thanks -- View this message in context: http://www.nabble.com/How-to-get-last-day-of-a-month--tp25425645p25425645.html Sent from the

[R] Is there any month object like LETTERS ?

2009-09-11 Thread megh
There is an object LETTERS which displays all letters from a to z. Is there any similar object whicg displays the months as well in chronological order? like jan, feb,...,dec Thanks, -- View this message in context:

[R] Sorting

2009-09-11 Thread megh
I have following object : date2 [,1] [,2] [1,] apr 1992 [2,] aug 1992 [3,] dec 1992 [4,] feb 1992 [5,] jan 1992 [6,] jul 1992 [7,] jun 1992 [8,] mar 1992 [9,] may 1992 [10,] nov 1992 [11,] oct 1992 [12,] sep 1992 [13,] apr 1993 [14,] aug 1993 [15,] dec 1993

Re: [R] Special LS estimation problem

2009-08-22 Thread megh
); a Can I go ahead with this procedure? Somebody please validate this? Thanks megh wrote: Hi, I have following kind of model : Y = X1 * a1 + X2 * a2 + error Here sampled data for Y, X1, X2 are like that : Y - replicate(10, matrix(rnorm(2),2), simplify = F) X1 - replicate(10, matrix

[R] Special LS estimation problem

2009-08-21 Thread megh
Hi, I have following kind of model : Y = X1 * a1 + X2 * a2 + error Here sampled data for Y, X1, X2 are like that : Y - replicate(10, matrix(rnorm(2),2), simplify = F) X1 - replicate(10, matrix(rnorm(4),2), simplify = F) X2 - replicate(10, matrix(rnorm(4),2), simplify = F) My goal is to

Re: [R] Special LS estimation problem

2009-08-21 Thread megh
Y is 2 dimensional vector, X1 and X2 are 2x2 matrices. Ted.Harding-2 wrote: On 21-Aug-09 16:28:26, megh wrote: Hi, I have following kind of model : Y = X1 * a1 + X2 * a2 + error Here sampled data for Y, X1, X2 are like that : Y - replicate(10, matrix(rnorm(2),2), simplify = F) X1

[R] A question on operation on list

2009-07-22 Thread megh
Hi, I have created a list object like that : x = vector(list) for (i in 1:5) x[[i]] = rnorm(2) x Now I want to do two things : 1. for each i, I want to do following matrix calculation : t(x[[i]]) %*% x[[i]] i.e. for each i, I want to get a 2x2 matrix 2. Next I want to get x[[1]] + x[[2]] +

Re: [R] A question on operation on list

2009-07-22 Thread megh
Thanks for your suggestions. I need one more thing : x = y = vector(list) for (i in 1:5) x[[i]] = rnorm(2); y[[i]] = rnorm(2) Here I want to get t(x[[i]]) %*% y[[i]] for each i. Can anyone please help me? Regards, Jorge Ivan Velez wrote: Hi megh, Perhaps? # Data x = vector(list

[R] Updating an object

2009-07-21 Thread megh
Let say, I have an arbitrary vector : i=1 assign(paste(dat,i,sep=), rnorm(5)) Now I want to update that dat1 vector by ommiting last 2 elements i.e. dat1 = dat1[c(1:3)] However here my problem is, as dat1 depends on another variable i, I cannot use above syntax directly. I want to automate

[R] Strange error in qplot

2009-07-12 Thread megh
Hi all, whenever I try to plot a histogram using qplot() function of ggplot2 library, I get error like this : qplot(rnorm(1000), geom=histogram, binwidth=0.2, main = , xlab=, ylab=) Error in scale[[1]] : subscript out of bounds However if I remove ylab= argument, then it is working fine. Am I

[R] From list to matrix

2009-07-05 Thread megh
Suppose, I have following vec - vector(list, length=3) for (i in 1:3) vec[[i]] - matrix(rnorm((i+3)*2), (i+3)) vec Now I want to change the type of vec from list to a matrix with (4+5+6) rows and 2 columns. How can I do that? Thanks and regards, -- View this message in context:

[R] Help on creating a sequence of vectors

2009-06-22 Thread megh
I want to create a number of vectors like : vec1 - rnorm(1) vec2 - rnorm(2) vec3 - rnorm(3) and so on... Here I tried following : for (i in 1:10) paste(vec, i, sep=) - rnorm(i) However obviously that is not working. Here vectors I need to be seperated i.e I do not want to create a

[R] Help on apply() function

2009-04-28 Thread megh
Hi all, can you please clarify me what is the wrong with following codes : set.seed(30) z = matrix(rnorm(10), 5, 2) apply(z, 1, function(x) sum(z[x,1]*1, z[x,2]*3)) However I can not get the desired result. For example, sum(z[1,1]*1, z[1,2]*3) gives -5.822442 which is actually correct. Am I

Re: [R] Cholesky Decomposition in R

2009-03-10 Thread megh
A=matrix(c(1,1,1,1,5,5,1,5,14),nrow=3) t(eigen(A)$vector) %*% A %*% eigen(A)$vector mat1 = t(eigen(A)$vector) mat2 = diag(eigen(A)$values)# this is your diagonal matrix Manli Yan wrote: Hi everyone: I try to use r to do the Cholesky Decomposition,which is A=LDL',so far I only

[R] Diff btw percentile and quantile

2009-03-04 Thread megh
To calculate Percentile for a set of observations Excel has percentile() function. R function quantile() does the same thing. Is there any significant difference btw percentile and quantile? Regrads, -- View this message in context:

Re: [R] Diff btw percentile and quantile

2009-03-04 Thread megh
Yes, I aware of those definitions. However I wanted to know the difference btw the words Percentile and quantile, if any. Secondly your link navigates to some non-english site, which I could not understand. Dieter Menne wrote: megh megh74 at yahoo.com writes: To calculate

[R] Alternate to for-loop

2009-02-16 Thread megh
Hi, I am trying to create a vector of length 10 (say), wherein each element will be average of random sample of size 100, from a distribution, say Normal. Can anyone please tell me without creating a for loop, how I can do that? Regards, -- View this message in context:

Re: [R] Alternate to for-loop

2009-02-16 Thread megh
No, it is not homework. I obviously could do that using a for-loop, and that I already did. However I thought whether there could be a better approach as it was looking very messy and unprofessional. Uwe Ligges-3 wrote: megh wrote: Hi, I am trying to create a vector of length 10 (say

[R] Loop on characters

2009-02-10 Thread megh
Hi, suppose I have three vectors like : l1 = 1:4 l2 = 4:9 l3 = 16:67 now I want to construct a loop like : for (i in 1:3) { count1[i] = length(li) # i.e. it will take l1, l2, l3 according to value of i } Can anyone please tell me how to do that? Regards, -- View this message in

Re: [R] uniroot() problem

2009-02-09 Thread megh
. uniroot(f,c(0,100),tol=1/10^12) $root [1] 50 $f.root [1] 1.337393e+31 $iter [1] 4 $estim.prec [1] 5.186962e-13 albyn Quoting megh megh700...@yahoo.com: I have a strange problem with uniroot() function. Here is the result : uniroot(th, c(-20, 20)) $root [1] 4.216521e-05

Re: [R] uniroot() problem

2009-02-09 Thread megh
Sorry, in my previous post I forgot to include strike price, which is K = 1160 megh wrote: Thanks for this reply. Here I was trying to calculate implied volatility using BS formula. This is my code : oo = 384.40 # traded option price uu = 1563.25 # underlying price tt = 0.656

[R] Orthogonal Complement

2009-01-11 Thread megh
Is there any R function which calculate the Orthogonal Complement of a mxn matrix (with full column rank)? Thanks in advance -- View this message in context: http://www.nabble.com/Orthogonal-Complement-tp21406355p21406355.html Sent from the R help mailing list archive at Nabble.com.

[R] uniroot() problem

2008-12-30 Thread megh
I have a strange problem with uniroot() function. Here is the result : uniroot(th, c(-20, 20)) $root [1] 4.216521e-05 $f.root [1] 16.66423 $iter [1] 27 $estim.prec [1] 6.103516e-05 Pls forgive for not reproducing whole code, here my question is how f.root can be 16.66423? As it is finding

[R] Function to find the order of operation

2008-12-29 Thread megh
Is there any R function find the order of an operation? I am looking for a general R function to find for example how many basic operations (i.e. addition, multiplication and exponentiation) are performed when two square matrices are multiplied. Regards, -- View this message in context:

[R] Ploting 3D cylinder in RGL

2008-12-18 Thread megh
Dear all, I would like to draw a 3-D horizontal cylinder preferably in RGL device (because this gives the look from different angles). Basic idea is from http://www.tau.ac.il/cc/pages/docs/sas8/insight/chap18/sect3.htm. Below is the description exactly what I want to do. Please see at figure

[R] How to fetch specific part from a number of Text files?

2008-12-15 Thread megh
Hi all, I my c: drive I have possibly 1,000 notepad files, with .txt extension. They are named as the dates on which they were saved i.e. 1st file name is Volume_4-18-2008, 2nd one is Volume_4-21-2008, 3rd one Volume_4-22-2008 and so on Also, content of each file are in same format

Re: [R] How to fetch specific part from a number of Text files?

2008-12-15 Thread megh
total 1000 text files in that directory and therefore I create a vector like sel.no - c(1:1000). Next I use the i-th element of the vector sel.no to access the i-th file? With regards, Charles C. Berry wrote: On Mon, 15 Dec 2008, megh wrote: Hi all, I my c: drive I have possibly 1,000

Re: [R] How to look within .Internal ?

2008-12-07 Thread megh
https://svn.r-project.org/R/trunk/src/main is not opening for last few days. Is there any problem with this or the materials were moved to different address? Duncan Murdoch-2 wrote: On 11/19/2008 10:13 AM, megh wrote: In the optim() function there is a syntax : res - .Internal(optim(par

Re: [R] Error with lapply [addirional clarification needed]

2008-11-22 Thread megh
, fn - function(i) return(i^2) sapply(1:4, fn) [1] 1 4 9 16 Hope this helps, baptiste On 20 Nov 2008, at 16:31, megh wrote: I have written following codes, with intention to get a list with values 1,2,9,16 : fn - function(i) return(i^2) lapply(1:4, fn, i) However

[R] Error with lapply

2008-11-20 Thread megh
I have written following codes, with intention to get a list with values 1,2,9,16 : fn - function(i) return(i^2) lapply(1:4, fn, i) However I got following error : Error in FUN(1:4[[1L]], ...) : unused argument(s) (1) Can anyone please tell me what will be the correct code here? Regards, --

[R] How to look within .Internal ?

2008-11-19 Thread megh
In the optim() function there is a syntax : res - .Internal(optim(par, fn1, gr1, method, con, lower, Here how can I see the inside-codes of .Internal function ? Regards, -- View this message in context: http://www.nabble.com/How-to-look-within-.Internal---tp20581897p20581897.html Sent from

[R] Question on creating list object

2008-11-17 Thread megh
I get following result, while I write this code : lapply(1:5, function(i) c(1,2,3)^i) [[1]] [1] 1 2 3 [[2]] [1] 1 4 9 [[3]] [1] 1 8 27 [[4]] [1] 1 16 81 [[5]] [1] 1 32 243 This is fine. However my goal is : each element of this list should depend on previous element like : lis #

Re: [R] Error : unable to restore saved data in .RData

2008-11-03 Thread megh
I have got one post here http://tolstoy.newcastle.edu.au/R/help/04/10/5221.html here it is suggested to start R with a flag --no-restore-data . Can anyone please tell me how to start R like that? megh wrote: I am getting error unable to restore saved data in .RData, whenever I start R

[R] Error : unable to restore saved data in .RData

2008-11-03 Thread megh
I am getting error unable to restore saved data in .RData, whenever I start R console. I have reinstalled R with latest version but still getting same error. Once I click OK the R window crashes. Can anyone suggest me about the courses to do? Regards, -- View this message in context:

[R] Goto loop

2008-10-31 Thread megh
Is there anything like goto loop, which exists in most computer programs? e.g. I am looking for this kind of stuff : if(i 6) goto step-02 Any idea? Regards, -- View this message in context: http://www.nabble.com/%22Goto%22-loop-tp20263445p20263445.html Sent from the R help mailing list

[R] Algo. for matrix inverse

2008-10-27 Thread megh
I am looking fpr a algo to find matrix inverse. Till time I am aware of Gauss-Jordan Elimination procedure to find the same. Are there any other algo. as well? What does R use to find the inverse? -- View this message in context:

[R] VEC Operator in R

2008-10-23 Thread megh
Can anyone please tell whether there is any R function to act as VEC and VECH operator on Matrix? Yes of course, I can write a user-defined-function for that or else, I can put dim(mat) - NULL. However I am looking for some R function. Your help will be highly appreciated. Regards, -- View

Re: [R] A matrix automation problem

2008-10-22 Thread megh
? a - matrix(1:9, 3) * 10 b - matrix(1:9, 3) kronecker(b,a) -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] 801.408.8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] project.org] On Behalf Of megh

[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 would

[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? __

  1   2   >