[R] simple payoff function

2010-12-11 Thread Santosh Srinivas
Just wondering if there is a better way to do this? x <- seq(4,20,1) y <- sapply(x, function(x) (max(x-10,0))) Is there a easier way to get to y? i.e. max(x-10,0) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEAS

[R] toJSON question

2010-12-11 Thread Santosh Srinivas
Hello, I am trying to use RJSONIO I have: x <- c(0,4,8,9) y <- c(3,8,5,13) z <- cbind(x,y) Any idea how to convert z into the JSON format below? I want to get the following JSON output to put into a php file. [[0, 3], [4, 8], [8, 5], [9, 13]] Thank you. __

Re: [R] Rapache on windows

2010-12-13 Thread Santosh Srinivas
; > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of Santosh Srinivas > Sent: Saturday, December 11, 2010 8:37 AM > To: r-help@r-project.org > Subject: [R] Rapache on windows > > Hello all, > > I sear

[R] Basic ggplot question

2011-01-10 Thread Santosh Srinivas
Hello R-Group, I am trying plotting simple time-series with ggplot2 because the output looks better and I've heard its richer in features. I have the following dataset. > dput(dat) structure(list(Date = structure(c(14970, 14971, 14972, 14973, 14974, 14977, 14978, 14979, 14980, 14981), class = "D

Re: [R] Basic ggplot question

2011-01-10 Thread Santosh Srinivas
2011 18:59 To: Santosh Srinivas Cc: r-help@r-project.org Subject: Re: [R] Basic ggplot question Hi, Try this, m = melt(dat, id="Date") head(m) qplot(Date, value, data=m, colour=variable, geom="line") ggplot(m) + facet_grid(variable~., scales="free_y") + geom_path

[R] snowfall

2011-01-12 Thread Santosh Srinivas
Hello, Just wondering why I am unable to run this in parallel. A dput of my dataset is attached at the end. Please use to create my data object. I want to run this function in parallel (not sure if this is an efficient implementation): #Function to calculate the time to maturity for the option r

Re: [R] Using subset to filter data table

2011-01-19 Thread Santosh Srinivas
tcc.new2 <- droplevels(tcc.new) -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ben Harrison Sent: 19 January 2011 12:24 To: r-help@r-project.org Subject: [R] Using subset to filter data table I am having difficulty understanding ho

Re: [R] which operating system + computer specifications lead to the best performance for R?

2011-01-22 Thread Santosh Srinivas
Hi Marc, I've exactly the same question and it looks like most of the heavy users from the threads I've followed use Unix/Linux/Mac. Some threads have given rationale for a 64bit system due to memory benefits but there seems to be not much buy-in from the guys here (so I'd give that a pass). The C

Re: [R] Second largest element from each matrix row

2011-04-26 Thread Santosh Srinivas
would this work (shorter)? apply(a, 1, function(x) x[order(x)[2]]) On Tue, Apr 26, 2011 at 5:31 PM, Lars Bishop wrote: > Hi, > > I need to extract the second largest element from each row of a > matrix. Below is my solution, but I think there should be a more efficient > way to accomplish the s

[R] Empty Data Frame

2011-04-27 Thread Santosh Srinivas
Dear Group, Is there a more efficient way to create a data frame structure (using rep I guess?) require(plyr) week <- rdply(10, data.frame(week = 1:52)) names(week) <- c("Year", "Week") week$Year <- week$Year + 2000 Basically trying to create a year and week data frame to start appending data t

Re: [R] Unexpected behaviour as.data.frame

2011-05-16 Thread Santosh Srinivas
Hi Ivan, Take a look dataFrame in R.utils ... is that what you want? from the help file: Examples df <- dataFrame(colClasses=c(a="integer", b="double"), nrow=10) df[,1] <- sample(1:nrow(df)) df[,2] <- rnorm(nrow(df)) print(df) Thanks, Santosh On Mon, May 16, 2011 at 1:42 PM, Ivan Calan

Re: [R] Does a data frame have indexes for columns?

2011-05-19 Thread Santosh Srinivas
Check data.table ... It benefits a lot from indexing data in data frames On Thu, May 19, 2011 at 7:41 PM, xiagao1982 wrote: > Hi all, > > I wonder if I can create indexes for columns in a data frame to speed up data > selection by matching column values, just like indexes for large tables in a

Re: [R] Plotting Data Table

2011-06-02 Thread Santosh Srinivas
Hello cmaster1331, I had asked a similar question sometime back. You may want to check out these responses that I got. A) http://code.google.com/p/gridextra/wiki/tableGrob B) 1) latex (via xtable, Hmisc, r2lh, reporttools ...) 2) html (via xtable, r2lh, R2HTML, hwritter, HTMLUtils ...) 3) graphi

Re: [R] Can we prepare a questionaire in R

2011-06-09 Thread Santosh Srinivas
You question has multiple answers that you can choose from and the group has been trying to help you. My suggestion would be to write it to the database using PHP and use R to extract and analyze (and write back) the data. The integration of R with web functionality is quite nascent but the Rapac

Re: [R] Finding a Diff within a Dataframe columns

2011-01-30 Thread Santosh Srinivas
Please take a look at the introduction to R too ... > df <- read.delim(textConnection(Lines),sep="") > df A B CD 1 0.1 0.7 0.9 0.80 2 0.2 0.6 0.8 0.70 3 0.4 0.8 0.7 0.76 > d['A-B'] <- with(df, A-B) Error in d["A-B"] <- with(df, A - B) : object 'd' not found > d$v1 <- with(df, A-B) Erro

Re: [R] delete rows

2011-02-06 Thread Santosh Srinivas
?subset On Mon, Feb 7, 2011 at 7:46 AM, Christopher Porter wrote: > Hello. I came across your response in an R forum and could use your help. I > have a data set with 472 rows. I want to delete rows 416 through 472. The > name of my data set is MERGE. > > I am an extreme R novice. How do I writ

[R] read.table

2011-02-22 Thread Santosh Srinivas
Hi Group, I am having a strange problem for this simple task. I am using read.table to read a plan 3 column CSV file . the file is getting read . But the first column has datetime in the csv file in the following format: 20110221.114041 But this is being read as 20110221 only . the tim

Re: [R] How to Save R library data into xls or dta format

2011-03-01 Thread Santosh Srinivas
for excel .. see library(xlsx) On Tue, Mar 1, 2011 at 2:57 PM, JoonGi wrote: > > Thanks in advance. > > I'm having a trouble with data saving. > > I want to run the same data which is in Ecdat library at different statistic > programs(excel, stata and matlab) > > The data I want to use is > > lib

Re: [R] Rearranging the data

2011-03-09 Thread Santosh Srinivas
reshape2 Like this? > require(reshape2) Loading required package: reshape2 > melt(xx) Using country as id variables country variable value 1 USAx10 2 UKx50 3 Canadax20 4 USAy40 5 UKy80 6 Canaday35 7 U

[R] Flexible rbind

2011-03-17 Thread Santosh Srinivas
Dear All, I am trying to create a empty structure that I want to fill gradually through the code. I want to use something like rbind to create the basic structure first. I am looking for a possibility to do an rbind where the columns names dont match fully (but the missing columns can be defaulte

[R] Flexible rbind

2011-03-17 Thread Santosh Srinivas
Sender: r-help-boun...@r-project.org On-Behalf-Of: santosh.srini...@gmail.com Subject: [R] Flexible rbind Message-Id: Recipient: simon.r...@barclayscapital.com ___ e at 1 Churchill Place, London, E14 5HP. This email may relate to or be sent from ot

[R] Flexible rbind

2011-03-17 Thread Santosh Srinivas
Sender: r-help-boun...@r-project.org On-Behalf-Of: santosh.srini...@gmail.com Subject: [R] Flexible rbind Message-Id: Recipient: killian.door...@barclayscapital.com ___ e at 1 Churchill Place, London, E14 5HP. This email may relate to or be sent fr

[R] Print out data frames into neat images

2011-04-17 Thread Santosh Srinivas
Hi Group, I often need to print out data frames with results of analysis into a neat little image to copy and paste into documents. I need apply formatting like bold, currency signs, number formats, header shading etc. I currently output the data into csv and format using good old excel. Any sugg

Re: [R] rownames in an apply function

2011-04-19 Thread Santosh Srinivas
Thanks. On Tue, Apr 19, 2011 at 5:16 PM, Gabor Grothendieck wrote: > On Tue, Apr 19, 2011 at 6:59 AM, santosh wrote: >> Dear Group, >> >> I am doing an apply function on a zoo object. I need the rownames to >> be passed to the function. >> Any suggestions on how to accomplish this? >> >> Here is

Re: [R] how to subtract one string from another in R

2011-06-18 Thread Santosh Srinivas
Hello Vijayan, Depending on your end goal the following could possibly help substr(string,nchar(string1)+1, nchar(string)) or strsplit(string," ") HTH, Santosh On Sat, Jun 18, 2011 at 2:06 PM, Vijayan Padmanabhan wrote: > Dear R Group > Here is what i am trying to do.. but couldnt figure ou

<    1   2