Re: [R] 3D confidence ellipsoid with ellipse projections onto 2D plane

2012-02-08 Thread baptiste auguie
Hi, If you read French, you might find the following discussion interesting, http://www.forum.math.ulg.ac.be/viewthread.html?id=45765 It contains some good suggestions to project an ellipsoid onto a plane, which as I understand might be related to your question. HTH, b. On 8 February 2012

Re: [R] R equivalent of Python str()?

2012-02-08 Thread Martin Maechler
R Michael Weylandt michael.weyla...@gmail.com michael.weyla...@gmail.com on Tue, 7 Feb 2012 20:23:57 -0500 writes: Possibly as.character() is what the OP was seeking Michael or format() which is closer for numeric data On Feb 7, 2012, at 7:15 PM, jim holtman

Re: [R] Actual vs. predicted survival times

2012-02-08 Thread Bonnett, Laura
Dear David, Thank you for your input. I was under the impression that it was not possible to obtain survival times using the predict.coxph function. In a post to the R help group I noticed someone had suggested calculating survival times in the manner I have used although obviously this is

Re: [R] R equivalent of Python str()?

2012-02-08 Thread Ernest Adrogué
8-02-2012, 09:45 (+0100); Martin Maechler escriu: R Michael Weylandt michael.weyla...@gmail.com michael.weyla...@gmail.com on Tue, 7 Feb 2012 20:23:57 -0500 writes: Possibly as.character() is what the OP was seeking Michael or format() which is closer for numeric

Re: [R] R equivalent of Python str()?

2012-02-08 Thread Ernest Adrogué
8-02-2012, 04:22 (+); William Dunlap escriu: Use capture.output(print(yourData)) to capture would be printed by print as a vector of a strings (one per line of printout). Paste together if desired. This will do it!! Thanks. -- Cheers, Ernest

Re: [R] replace elements of a data frame

2012-02-08 Thread Arnaud Gaboury
names1-recode(df$names,'BO'='BOO';'CL'='CLR';'C'='CC') df1-data.frame(names1,price) df1 names1 price 1BOO10 2 CC25 3CLR20 TY for the tip. Any possibility to write this in one single line? Arnaud Gaboury   A2CT2 Ltd. -Original Message- From: Berend Hasselman

[R] remove NAs from list collectively

2012-02-08 Thread Johannes Radinger
Hi, I am importing dataframe from an Excel file (xlsx package). The columns contain acutally measurements for single species and the column-length is of variable. As it is imported as a dataframe the difference to the longest column is filled with NA. To explain it with an example, my dataframe

Re: [R] remove NAs from list collectively

2012-02-08 Thread Dimitris Rizopoulos
Two possibilities are: lapply(df, function (x) x[!is.na(x)]) and lapply(df, na.exclude) I hope it helps. Best, Dimitris On 2/8/2012 11:54 AM, Johannes Radinger wrote: Hi, I am importing dataframe from an Excel file (xlsx package). The columns contain acutally measurements for single

Re: [R] remove NAs from list collectively

2012-02-08 Thread Johannes Radinger
Hi, lapply(df, function (x) x[!is.na(x)]) thats is really great! Thank you! Original-Nachricht Datum: Wed, 08 Feb 2012 12:01:17 +0100 Von: Dimitris Rizopoulos d.rizopou...@erasmusmc.nl An: Johannes Radinger jradin...@gmx.at CC: R-help@r-project.org Betreff: Re: [R] remove

[R] optparse::parse_args, using equals sign or not

2012-02-08 Thread Benjamin Tyner
Hi We've found that when using parse_args(..., positional_arguments=FALSE), it is permissible to invoke our script with either --myfoo=bar or --myfoo bar; that is, whether or not the equals sign is present makes no difference, and in fact both usage forms are demonstrated in the optparse

[R] check for nearest value in a vector

2012-02-08 Thread Martin Batholdy
Hi, Is there a way to check which value in a vector is nearest to a given value? so for example I have vector x: x - c(1, 6, 12, 28, 33) and I would like to get the position of the element of x that is nearest to 14 (in this case the third element). thanks!

Re: [R] check for nearest value in a vector

2012-02-08 Thread Dimitris Rizopoulos
How about this: x - c(1, 6, 12, 28, 33) which.min(abs(x - 14)) I hope it helps. Best, Dimitris On 2/8/2012 1:56 PM, Martin Batholdy wrote: Hi, Is there a way to check which value in a vector is nearest to a given value? so for example I have vector x: x- c(1, 6, 12, 28, 33) and I

Re: [R] check for nearest value in a vector

2012-02-08 Thread Petr PIKAL
Hi Hi, Is there a way to check which value in a vector is nearest to a given value? so for example I have vector x: x - c(1, 6, 12, 28, 33) and I would like to get the position of the element of x that is nearest to 14 (in this case the third element). Easy. Smallest difference

Re: [R] check for nearest value in a vector

2012-02-08 Thread Martin Batholdy
great, thanks! On 08.02.2012, at 14:00, Dimitris Rizopoulos wrote: How about this: x - c(1, 6, 12, 28, 33) which.min(abs(x - 14)) I hope it helps. Best, Dimitris On 2/8/2012 1:56 PM, Martin Batholdy wrote: Hi, Is there a way to check which value in a vector is nearest

Re: [R] survfit is too slow! Looking for an alternative

2012-02-08 Thread Terry Therneau
A couple of thoughts. 1. More than 1/2 the work for survfit.coxph is computing standard errors. If you don't need them adding se.fit=FALSE will help the speed. 2. Survival curves with time dependent covariates is a complex topic. To get the probability of default in each month during next 2

Re: [R] need help with understanding coxph encoding

2012-02-08 Thread Terry Therneau
Coxph is a regression model, so the coefficient for x is the change in prediction value for each 1 unit change in x. Just like regression, it won't matter if you code it as 0/1 or 1/2 or 105 vs 106. If you code it as 0 vs 10 the coefficient will be divided by 10 though. The relative hazard

[R] List to dataframe

2012-02-08 Thread Johannes Radinger
Hi, I want to melt my list and get certain deskriptive factors (length of a vector etc.) into a dataframe. Best to describe it with an example: A - seq(4) B - seq(6) C - seq(9) ls - list(A,B,C) # this is my list with vectors of different length # thats the dataframe how it should look like:

Re: [R] Actual vs. predicted survival times

2012-02-08 Thread Terry Therneau
The Cox model predicts two things: the relative hazard (death rate) associated with each variable, and a predicted survival curve for any particular variable combination. The predicted survival curve will look like a Kaplan-Meier curve: multiple small steps, and will only rarely go all the way

[R] How to start JGR in full window?

2012-02-08 Thread Iurie Malai
I want to start JGR as a full sized/maximized window automatically, but how to do this? For other applications I can add option --geometry 1440x900 to the launch command, but for JGR this do not work. Sugestions? Iurie Malai Senior Lecturer Psychology Department Ion Creanga Moldova Pedagogical

Re: [R] List to dataframe

2012-02-08 Thread Jorge I Velez
Try list - list(1:4, 1:6, 1:9) t(sapply(list, function(x) c(length(x), sum(x 5), sum(x 5 HTH, Jorge.- On Wed, Feb 8, 2012 at 8:50 AM, Johannes Radinger wrote: Hi, I want to melt my list and get certain deskriptive factors (length of a vector etc.) into a dataframe. Best to describe

[R] decimal number format as quarter

2012-02-08 Thread Arnaud Gaboury
Hello, I have to deal with numbers with a decimal part as quarter, coming from two systems with different way to show decimals. I need to tell R these are in fact the same number. On one side my number are formatted this way : 2.2 , 2.4 and 2.6. On the other side, I have 2.25, 2.50 and 2.75.

Re: [R] 3D confidence ellipsoid with ellipse projections onto 2D plane

2012-02-08 Thread Michael Friendly
On 2/7/2012 1:29 PM, Samuel Bazzi wrote: I have a 3xN matrix of parameters obtained from N regressions where the 3 parameters are jointly statistically significant. I would like to reproduce a 3D confidence ellipsoid projecting 2D ellipses onto the XY plane as in Figure 5.2 in this

Re: [R] decimal number format as quarter

2012-02-08 Thread jim holtman
will this do it for you: x - c(2.2, 2.4, 2.6, 3.2, 3.4, 3.6) # get integer part x.i - as.integer(x) # get fractional part x.f - (x * 10) %% 10 # new result result - x.i + ifelse(x.f == 2 + , .25 + , ifelse(x.f == 4 + , .5 +

Re: [R] Actual vs. predicted survival times

2012-02-08 Thread alanm (Alan Mitchell)
Have you tried plotting obvserved survival against X*Beta? I believe the usual predictions from a cox model are just monotonic transformations of this. -Alan -Original Message- From: Bonnett, Laura [mailto:l.j.bonn...@liverpool.ac.uk] Sent: Wed 2/8/2012 1:52 AM To: 'David Winsemius' Cc:

Re: [R] decimal number format as quarter

2012-02-08 Thread Arnaud Gaboury
TY Jim, It do the trick. I was trying to play without success with the format() options. No simplest way so? Arnaud Gaboury   A2CT2 Ltd. -Original Message- From: jim holtman [mailto:jholt...@gmail.com] Sent: mercredi 8 février 2012 15:36 To: Arnaud Gaboury Cc: r-help@r-project.org

Re: [R] decimal number format as quarter

2012-02-08 Thread David Winsemius
On Feb 8, 2012, at 9:12 AM, Arnaud Gaboury wrote: Hello, I have to deal with numbers with a decimal part as quarter, coming from two systems with different way to show decimals. I need to tell R these are in fact the same number. On one side my number are formatted this way : 2.2 , 2.4

Re: [R] decimal number format as quarter

2012-02-08 Thread David Reiner
Looks like something priced in eighths; we deal with similar notation for bonds and similar instruments. x - c(2.2, 2.4, 2.6, 3.2, 3.4, 3.6) as.integer(x)+10*(x-as.integer(x))/8 [1] 2.25 2.50 2.75 3.25 3.50 3.75 Adjust the 10 and 8 if you have other denominators. -- David -Original

Re: [R] decimal number format as quarter

2012-02-08 Thread jim holtman
Here is a shorter way: x - c(2.2, 2.4, 2.6, 3.2, 3.4, 3.6) # get integer part x.i - as.integer(x) # get fractional part x.f - x %% 1 result - x.i + x.f * 1.25 result [1] 2.25 2.50 2.75 3.25 3.50 3.75 as.integer(x) + (x %% 1) * 1.25 [1] 2.25 2.50 2.75 3.25 3.50 3.75 On Wed, Feb 8, 2012

Re: [R] decimal number format as quarter

2012-02-08 Thread Arnaud Gaboury
David, You are not far indeed, as I trade commodities, and prices are the ones from grain market: Corn, wheat and Soybeans. They are quoted in 1/4, and my trading platform displays them in 2,4,6 and my statements are in 25,50,75. TY Arnaud Gaboury   A2CT2 Ltd. -Original Message-

Re: [R] decimal number format as quarter

2012-02-08 Thread peter dalgaard
On Feb 8, 2012, at 15:48 , David Reiner wrote: Looks like something priced in eighths; we deal with similar notation for bonds and similar instruments. x - c(2.2, 2.4, 2.6, 3.2, 3.4, 3.6) as.integer(x)+10*(x-as.integer(x))/8 [1] 2.25 2.50 2.75 3.25 3.50 3.75 Adjust the 10 and 8 if you

Re: [R] List to dataframe

2012-02-08 Thread Johannes Radinger
Hi, Try list - list(1:4, 1:6, 1:9) t(sapply(list, function(x) c(length(x), sum(x 5), sum(x 5 thank you...the sapply approach seems straight forward, although I don't get the names into an own column... When the list elements are named the name is used for the rownames. I'd like to

Re: [R] decimal number format as quarter

2012-02-08 Thread Gabor Grothendieck
On Wed, Feb 8, 2012 at 9:12 AM, Arnaud Gaboury arnaud.gabo...@a2ct2.com wrote: Hello, I have to deal with numbers with a decimal part as quarter, coming from two systems with different way to show decimals. I need to tell R these are in fact the same number. On one side my number are

Re: [R] decimal number format as quarter

2012-02-08 Thread Arnaud Gaboury
Thanks so much Peter. You are the man. Easy way and working for me. Arnaud Gaboury   A2CT2 Ltd. -Original Message- From: peter dalgaard [mailto:pda...@gmail.com] Sent: mercredi 8 février 2012 16:15 To: David Reiner Cc: Arnaud Gaboury; jim holtman; r-help@r-project.org Subject: Re: [R]

Re: [R] decimal number format as quarter

2012-02-08 Thread Petr Savicky
On Wed, Feb 08, 2012 at 03:12:56PM +0100, Arnaud Gaboury wrote: Hello, I have to deal with numbers with a decimal part as quarter, coming from two systems with different way to show decimals. I need to tell R these are in fact the same number. On one side my number are formatted this

[R] randomForest

2012-02-08 Thread Anirudh Kondaveeti
Hi I have a dataset with a few variables but two variables are very important. One of them is say S1 and other S2. S1 is a numeric variable and S2 is a categorical variable. Consider two cases of S1-S2 pair like S1 = 70.2, S2 = A and S1 = 70.21, S2 = B. Assume my dataset has 20 instances of the

Re: [R] List to dataframe

2012-02-08 Thread jim holtman
Does this do what you want: list - list(A=1:4, B=1:6, C=1:9) result - lapply(names(list), function(x){ + data.frame(name = x + , length = length(list[[x]]) + , gt5 = sum(list[[x]] 5) + , lt5 = sum(list[[x]] 5) + ) + }) do.call(rbind, result) name length

Re: [R] How to have columns lined up?

2012-02-08 Thread hithit168
Thanks a lot, David. Uh...this is not really an R question, but I couldn't find answer nowhere... -- View this message in context: http://r.789695.n4.nabble.com/How-to-have-columns-lined-up-tp4367928p4369262.html Sent from the R help mailing list archive at Nabble.com.

[R] library(forecast): Error in SD.test(x, m) : Insufficient data

2012-02-08 Thread Jean Jacques Dureau
I have these R code: ### time.test.data-c(2.88645418326693, 2.91546949823027, 2.94130799329234, 2.93313338038109, 2.89478957915832, 2.86029757243540, 2.78648486664669, 2.80183167535133, 2.75435512226307, 2.78992352676563,

[R] get information on .C code

2012-02-08 Thread J. Augusiak
Dear R list, I have a package downloaded and looked up a function in there. Now I find that it uses C code (.C call) to do part of its job. However, when I wanted to look that part up by using getAnywhere() I was told that no object of that name could be found. Then I tried typing C.(

Re: [R] predict.naiveBayes() bug in e1071 package

2012-02-08 Thread David Meyer
Confirmed fixed upstream. Thanks, David On 2012-02-07 18:43, Ali Tofigh wrote: Hi, I'm currently using the R package e1071 to train naive bayes classifiers and came across a bug: When the posterior probabilities of all classes are small, the result from the predict.naiveBayes function become

Re: [R] need help with understanding coxph encoding

2012-02-08 Thread summer
Thank you. The factor is useful. What if I did not factor it,and the x is listed as 2 2 1 1 1 1 2 2 2 and so on. How would I know the HR for coxph is group2/group1 or group1/group2? I understand it's just inverse but how can I identify the exact HR? -- View this message in context:

Re: [R] wilderSum

2012-02-08 Thread yuanwei
Hi Joshua, Before I found your post here, I have viewed your source code for 'wilderSum'http://cran.r-project.org/src/contrib/TTR_0.21-0.tar.gz to figure out how wilderSum works - I re-write a piece of R code to implement the algorithm as in your source code, but failed to get the right

[R] find a row identical to another

2012-02-08 Thread Francisco
Hello, I have a dataset with many rows, starting from a row that I choose I would like to find the other rows in the dataset which are identical to this row (with the same values per each column) and assign them to a variable. How could I do? Thank you

[R] Problems reading tab-delim files using read.table and read.delim

2012-02-08 Thread mails
Hello, I used read.xlsx to read in Excel files but for large files it turned out to be not very efficient. For that reason I use a programme which writes each sheet in an Excel file into tab-delim txt files. After that I tried using read.table and read.delim to read in those txt files.

[R] library(forecast): Error in SD.test(x, m) : Insufficient data

2012-02-08 Thread Jean Jacques Dureau
I have these R code: ### time.test.data-c(2.88645418326693, 2.91546949823027, 2.94130799329234, 2.93313338038109, 2.89478957915832, 2.86029757243540, 2.78648486664669, 2.80183167535133, 2.75435512226307, 2.78992352676563,

[R] Random sample from truncated distributions

2012-02-08 Thread n
Hi, How can I draw a random sample from a truncated distribution (especially lognormal)? I found the functions for truncated normal but not for many other distributions. Thanks Nikhil -- View this message in context:

[R] glm.fit and pearson's correlation coefficient

2012-02-08 Thread dzuc
I did a linear correlation of data using glm.fit and stored the output in the object f: f - glm.fit(x, y, w) I am intereseted in estimating the quality of the correlation. I am used to do it using pearson correlation coefficient r or r^2. Can I extract this coefficient from the output of glm.fit?

[R] earth package question

2012-02-08 Thread luckjiff
I’ve a question on saving a earth object to disk. Say m is the model then print(object.size(m), units=”Mb”) 163.8 Mb and save it off save(m, “tmp.rda”) and “tmp.rda” is roughly 171Mb file. I would like this to be much smaller. So I try m$bx-NULL then print(object.size(m), units=”Mb”) 14.9 Mb

Re: [R] library(forecast): Error in SD.test(x, m) : Insufficient data

2012-02-08 Thread Rainer Hurling
On 08.02.2012 15:35 (UTC+1), Jean Jacques Dureau wrote: I have these R code: ### time.test.data-c(2.88645418326693, 2.91546949823027, 2.94130799329234, 2.93313338038109, 2.89478957915832, 2.86029757243540,

Re: [R] How to have columns lined up?

2012-02-08 Thread David Winsemius
On Feb 8, 2012, at 7:32 AM, hithit168 wrote: Thanks a lot, David. Uh...this is not really an R question, but I couldn't find answer nowhere... Questions that relate to how to use editors (and this is especially so for Microsoft products) simply do NOT belong on R-help. There must be

Re: [R] units for mapproject() function result

2012-02-08 Thread William Stockhausen
Hi Ray, Thanks for responding! However, it would certainly be very non-intuitive if you're correct about the units for the projected coordinates. As I'm sure you know, in a GIS geographic coordinates are usually in degrees--although it's quite possible for these to be in radians instead, I

Re: [R] wilderSum

2012-02-08 Thread Joshua Ulrich
Yuanwei, You are correct. The initial seed value is the raw sum, starting with TTR_0.21-0. As it says in the TTR/CHANGES file (among other things): - Changed wilderSum to seed initial value with raw sum. This matches Wilder's original calculations. Thanks to Mahesh Bp for the report. HTH, --

Re: [R] Problems reading tab-delim files using read.table and read.delim

2012-02-08 Thread Jan van der Laan
I don't know if this completely solves your problem, but here are some arguments to read.table/read.delim you might try: row.names=FALSE fill=TRUE The details section also suggests using the colClasses argument as the number of columns is determined from the first 5 rows which may not be

[R] Memory allocation problem (again!)

2012-02-08 Thread Christofer Bogaso
Dear all, I know this problem was discussed many times in forum, however unfortunately I could not find any way out for my own problem. Here I am having Memory allocation problem while generating a lot of random number. Here is my description: rnorm(5*6000) Error: cannot allocate vector of

Re: [R] Problems reading tab-delim files using read.table and read.delim

2012-02-08 Thread Gabor Grothendieck
On Wed, Feb 8, 2012 at 7:09 AM, mails mails00...@gmail.com wrote: Hello, I used read.xlsx to read in Excel files but for large files it turned out to be not very efficient. For that reason I use a programme which writes each sheet in an Excel file into tab-delim txt files. Note that that is

Re: [R] Memory allocation problem (again!)

2012-02-08 Thread Justin Haynes
32 bit windows has a memory limit of 2GB. Upgrading to a computer thats less than 10 years old is the best path. But short of that, if you're just generating random data, why not do it in two or more pieces and combine them later? mat.1 - matrix(rnorm(5*2000),nrow=5) mat.2 -

Re: [R] Memory allocation problem (again!)

2012-02-08 Thread Ernest Adrogué
8-02-2012, 22:22 (+0545); Christofer Bogaso escriu: And the Session info is here: sessionInfo() R version 2.14.0 (2011-10-31) Platform: i386-pc-mingw32/i386 (32-bit) Not an expert, but I think that 32-bit applications can only address up to 2GB on Windows. -- Bye, Ernest

[R] R: Memory increase

2012-02-08 Thread oluwole oyebamiji
Hi all,      I want to do a linear regression with lm package in MASS, my data is 59199 rows by 29 column. I got this error message can not allocate a vector of size 1.5Gb. I have read some of the previous related posting on this but I couldnt still got it right. I have an Ubuntu machine of

[R] search tutorial for function tt in cox.zph

2012-02-08 Thread johann . delcourt
Hye, I am writing to request your help. I am working on survival curve analysis with Cox model (cox.zph). After to test the proportionality condition for each covariant (independence to the time), the time effect is very significant and I must adapt my model, by the addition of a function

Re: [R] library(forecast): Error in SD.test(x, m) : Insufficient data

2012-02-08 Thread Jean Jacques Dureau
Hi rainer, how can I control dependend packages? thanks jj Il 08 febbraio 2012 17:10, Rainer Hurling rhur...@gwdg.de ha scritto: On 08.02.2012 15:35 (UTC+1), Jean Jacques Dureau wrote: I have these R code: ###

Re: [R] find a row identical to another

2012-02-08 Thread Petr Savicky
On Wed, Feb 08, 2012 at 03:36:45PM +0100, Francisco wrote: Hello, I have a dataset with many rows, starting from a row that I choose I would like to find the other rows in the dataset which are identical to this row (with the same values per each column) and assign them to a variable. How

[R] Force printing of excluded axis annotations

2012-02-08 Thread Justin Fincher
Howdy, This should be simple, but I am finding that I can't find a simple solution. I have a plot to which I am manually adding the annotations to the y-axis with this command: axis(2, c(-4,-3,-2,-1,0,1,2,3,4,5,6,7),labels=c(-4,-3,-2,-1,0,1,2,3,4,5,6,7),cex.axis=8) The issue is that,

Re: [R] Random sample from truncated distributions

2012-02-08 Thread Petr Savicky
On Wed, Feb 08, 2012 at 06:17:40AM -0800, n wrote: Hi, How can I draw a random sample from a truncated distribution (especially lognormal)? I found the functions for truncated normal but not for many other distributions. Hi. A variable Y with a log-normal distribution may be obtained as

[R] Error in Rd[[which]] : subscript out of bounds

2012-02-08 Thread Ben Ganzfried
Hi-- I googled the above error and found previous postings about this error on the list. I was having a little difficulty implementing the advice though. The suggestions were to use: traceback() and checkRd(). I'm using R in the directory in which the .Rd file with the problem is located, but

[R] fixed effects with clustered standard errors

2012-02-08 Thread Millo Giovanni
Dear John, interesting. There must be a bottleneck somewhere, which possibly went unnoticed because econometricians seldom use so many data points. In fact 'plm' wasn't designed to handle only 700 Megs of data at a time; but we're happy to investigate in this direction too. E.g., I was aware of

Re: [R] get information on .C code

2012-02-08 Thread R. Michael Weylandt michael.weyla...@gmail.com
It's compiled code so you can't view it in R. Download the source from CRAN (in your browser, not through R), decompress it, and look through the src/ directory with your favorite text editor. Michael On Feb 8, 2012, at 8:51 AM, J. Augusiak jaugus...@googlemail.com wrote: Dear R list, I

[R] String position character replacement

2012-02-08 Thread Yang, Joy (NIH/NHGRI) [F]
Hi, Is there a way to efficiently replace specified indices in a string with another character? For example, if I had a vector of strings such as [1] hellohowareyoudoing [2] imgoodhowareyou [3] goodandyou [4] yesimgoodijusttoldyou [5] ohyesthatsright and had a list of positions that I want to

Re: [R] R: Memory increase

2012-02-08 Thread Uwe Ligges
On 08.02.2012 17:14, oluwole oyebamiji wrote: Hi all, I want to do a linear regression with lm package in MASS, my data is 59199 rows by 29 column. I got this error message can not allocate a vector of size 1.5Gb. I have read some of the previous related posting on this but I couldnt

Re: [R] String position character replacement

2012-02-08 Thread Jorge I Velez
Hi Joy, Perhaps not the easiest way, but the following seems to work: x - c(hellohowareyoudoing, imgoodhowareyou, goodandyou, yesimgoodijusttoldyou, ohyesthatsright) pos - list(c(3, 9), c(3,4), c(4,7), 5:9, c(2, 5, 7, 12)) sapply(1:length(pos), function(i){ xx - strsplit(x, )[[i]]

Re: [R] String position character replacement

2012-02-08 Thread Sarah Goslee
And here's an alternative solution: subchar - function(string, pos, char=-) { for(i in pos) { string - gsub(paste(^(.{, i-1, })., sep=), \\1-, string) } string } subchar(hellohowareyoudoing, 3) [1] he-lohowareyoudoing subchar(hellohowareyoudoing, c(3, 9)) [1]

Re: [R] String position character replacement

2012-02-08 Thread Gabor Grothendieck
On Wed, Feb 8, 2012 at 12:33 PM, Yang, Joy (NIH/NHGRI) [F] joy.y...@nih.gov wrote: Hi, Is there a way to efficiently replace specified indices in a string with another character? For example, if I had a vector of strings such as [1] hellohowareyoudoing [2] imgoodhowareyou [3] goodandyou

Re: [R] Setting up infile for R CMD BATCH

2012-02-08 Thread ilai
Gang, Maybe someone here has a different take on things. I'm afraid I have no more insights on this unless you explain exactly what you are trying to achieve, or more importantly why? That may help understand what the problem really is. Do you want to save an interactive session for future runs?

[R] Wriritng to a CSV file

2012-02-08 Thread Ron Michael
Dear all, let say I want to write a vector to a CSV file. So I can have following syntax:   write.csv(rnorm(10), dat.csv)   Now I want to add one more column into that existing file. If I use the same code then existing file will be destroyed. Is there any functionality to add without

Re: [R] String position character replacement

2012-02-08 Thread Yang, Joy (NIH/NHGRI) [F]
Thank you both! I was working along the lines of Jorge's method, but was taking longer than it should. Sarah's is actually a lot faster. Thanks again, Joy From: Sarah Goslee [sarah.gos...@gmail.com] Sent: Wednesday, February 08, 2012 1:30 PM To: Yang,

Re: [R] R2WinBUGS error message

2012-02-08 Thread Uwe Ligges
On 07.02.2012 15:23, anaraster wrote: Hi! I am new to BUGS and running BUGS from R. I am trying to run a regression model from R, however I have this error message: Error in file(con, wb) : cannot open the connection In addition: Warning messages: 1: In file.create(to[okay]) : cannot

[R] syntax problem with formula / nls

2012-02-08 Thread Journals
I run into a slight syntax proble while using nls that seems to require some advice from the R community I have a nonlinear regression problem where I observe the sum of the responses (y) of many individuals (X1 Xn). The properties (x1..xn) of these individuals have been measured but

Re: [R] na.action in stats::factanal() must be using formula interface and dataframe input to specify na.action?

2012-02-08 Thread Uwe Ligges
On 06.02.2012 18:42, Timothy Bates wrote: hi, Does factanal() force the user to use the formula interface if they wish to specify an na.action? Yes, as the help page says: na.action: The ‘na.action’ to be used if ‘x’ is used as a formula. Uwe Ligges v1-

Re: [R] Wriritng to a CSV file

2012-02-08 Thread Uwe Ligges
On 08.02.2012 20:14, Ron Michael wrote: Dear all, let say I want to write a vector to a CSV file. So I can have following syntax: write.csv(rnorm(10), dat.csv) Now I want to add one more column into that existing file. If I use the same code then existing file will be destroyed. Is there

Re: [R] Error in Rd[[which]] : subscript out of bounds

2012-02-08 Thread Uwe Ligges
On 08.02.2012 18:44, Ben Ganzfried wrote: Hi-- I googled the above error and found previous postings about this error on the list. I was having a little difficulty implementing the advice though. The suggestions were to use: traceback() and checkRd(). I'm using R in the directory in which

Re: [R] syntax problem with formula / nls

2012-02-08 Thread Uwe Ligges
On 08.02.2012 19:32, Journals wrote: I run into a slight syntax proble while using nls that seems to require some advice from the R community I have a nonlinear regression problem where I observe the sum of the responses (y) of many individuals (X1 Xn). The properties (x1..xn) of these

Re: [R] Force printing of excluded axis annotations

2012-02-08 Thread Uwe Ligges
On 08.02.2012 17:43, Justin Fincher wrote: Howdy, This should be simple, but I am finding that I can't find a simple solution. I have a plot to which I am manually adding the annotations to the y-axis with this command: axis(2,

Re: [R] Wriritng to a CSV file

2012-02-08 Thread Uwe Ligges
I (and you as well) should have seen that before: use write.table in order to append. The reason for that is given in ?write.table / ?write.csv: ‘write.csv’ and ‘write.csv2’ provide convenience wrappers for writing CSV files. They set ‘sep’ and ‘dec’ (see below), ‘qmethod =

Re: [R] Setting up infile for R CMD BATCH

2012-02-08 Thread Gang Chen
Sorry Elai for the confusions. Let me try to reframe my predicament. The main program myTest.R has been written in interactive mode with many readline() lines embedded. Suppose a user has already run the program once before in interactive mode with all the answers saved in a text file called

Re: [R] using file in hdfs for data mining algorithms in r

2012-02-08 Thread Uwe Ligges
On 06.02.2012 12:29, Karthi KN wrote: hi all, i am new to r It is called R - well, everything lower case, shift key is broken? , i am trying to run data mining algorithms using map reduce framework.. * *i have few basic doubts* *1. can i give file in hdfs to kmeans( ) ? ?I tried as

Re: [R] Problem with plotting a square 1 x 3 plot and placement of outer margin text

2012-02-08 Thread Uwe Ligges
On 07.02.2012 16:03, Mark Na wrote: Dear R-helpers, Please see the attached plot. The problem is that I have too much space between the x-axis label (which is mtext in an outer margin) and the plots. My par settings for this plot are:

[R] How to stop a loop for?

2012-02-08 Thread Juan Andres Hernandez
Hi all, I have some time trying to find a way to stop a loop for( ) until the user presses the enter key or any other one and the loop can continue. This could be an example: library(MASS) data - data.frame(mvrnorm(1000,rep(0,5),Sigma=diag(1,5))) for(i in 1:dim(data)[2]){

Re: [R] Hinton Diagram for a matrix of weights

2012-02-08 Thread Stephen Eglen
On 12/08/2011 03:45 AM, Xavier Fernández i Marín wrote: Hello, Although I have used a general search engine, r-seek, and browsed CRAN for contributed packages and R Gallery, I have not been able to find an implementation of Hinton Diagrams for representing weighting matrices using R.

Re: [R] How to stop a loop for?

2012-02-08 Thread R. Michael Weylandt
A somewhat common idiom is to use readline() with Please press Return to continue: as the prompt and not to store the value anywhere. Michael On Wed, Feb 8, 2012 at 2:45 PM, Juan Andres Hernandez jhernandezcabr...@gmail.com wrote: Hi all, I have some time trying to find a way to stop a loop

Re: [R] library(forecast): Error in SD.test(x, m) : Insufficient data

2012-02-08 Thread Rainer Hurling
On 08.02.2012 17:19 (UTC+1), Jean Jacques Dureau wrote: Hi rainer, how can I control dependend packages? You did not tell us very much about your installation and versions of packages you are using. On my system sessionInfo() gives me the following after loading your example:

[R] standard error for lda()

2012-02-08 Thread array chip
Hi, I am wondering if it is possible to get an estimate of standard error of the predicted posterior probability from LDA using lda() from MASS? Logistic regression using glm() would generate a standard error for predicted probability with se.fit=T argument in predict(), so would it make sense

Re: [R] Error in Rd[[which]] : subscript out of bounds

2012-02-08 Thread Ben Ganzfried
Hi Uwe, Thanks for the help. R version 2.14.0 (2011-10-31). The file in question looks like this (w/ a few minor edits for privacy): \name{curatedData-package} \alias{curatedData-package} \alias{curatedData} \docType{package} \title{Cancer Gene Expression Analysis} \description{The curatedData

Re: [R] String position character replacement

2012-02-08 Thread Petr Savicky
On Wed, Feb 08, 2012 at 01:30:55PM -0500, Sarah Goslee wrote: And here's an alternative solution: subchar - function(string, pos, char=-) { for(i in pos) { string - gsub(paste(^(.{, i-1, })., sep=), \\1-, string) } string } Hi. Try the following modification.

[R] unsparse a vector

2012-02-08 Thread Sam Steingold
Suppose I have a vector of strings: c(A1B2,A3C4,B5,C6A7B8) [1] A1B2 A3C4 B5 C6A7B8 where each string is a sequence of columnvalue pairs (fixed width, in this example both value and name are 1 character, in reality the column name is 6 chars and value is 2 digits). I need to convert it to a

Re: [R] Wriritng to a CSV file

2012-02-08 Thread Ron Michael
Okay, so I understood that appending can only happen row-wise. Therefore I tried with following code:   write.csv(matrix(1:5, 1), dat.csv) write.csv(matrix(1:5, 1), dat.csv, append = TRUE) Warning message: In write.csv(matrix(1:5, 1), dat.csv, append = TRUE) :   attempt to set 'append' ignored

[R] How indices calculated in package boot

2012-02-08 Thread Deng Nina
Hi,there, I am using R package boot to bootstrap. I have one question here: does anybody possibly know how the boot package generates the indices which is used in the statistic function? I thought indices = sample(data, replace=TRUE), but when I replaced indices with this command and used boot,

[R] How to store the p value and number of events into a matrix

2012-02-08 Thread summer
Hi, there is p value and number of events from coxph results. How can I keep record of every p value and number of events automatically if I run 100 times? Another question is how can I change the true or faulse statment to 1 and 0. such as w=12, I want the value of w to be 1 not true. Thank you.

Re: [R] unsparse a vector

2012-02-08 Thread Sam Steingold
To be clear, I can do that with nested for loops: v - c(A1B2,A3C4,B5,C6A7B8) l - strsplit(gsub((.{2}),\\1,,v),,) d - data.frame(A=vector(length=4,mode=integer), B=vector(length=4,mode=integer), C=vector(length=4,mode=integer)) for (i in 1:length(l)) { l1 -

Re: [R] Wriritng to a CSV file

2012-02-08 Thread David Winsemius
On Feb 8, 2012, at 2:29 PM, Ron Michael wrote: Okay, so I understood that appending can only happen row-wise. Therefore I tried with following code: write.csv(matrix(1:5, 1), dat.csv) write.csv(matrix(1:5, 1), dat.csv, append = TRUE) Warning message: In write.csv(matrix(1:5, 1), dat.csv,

Re: [R] units for mapproject() function result

2012-02-08 Thread William Stockhausen
Hi Ray ( all), Many apologies to Ray--apparently my intuition stinks!! The projection is based on the unit sphere (R=1), so the projected coordinates really are dimensionless--as you said! So to scale up to the earth, just multiply the projected coordinate values from mapproject by your favorite

Re: [R] unsparse a vector

2012-02-08 Thread Bert Gunter
I suspect there are cleverer ways to do it, especially using packages like stringr and gsubfn, but using base tools, you can hack it without too much effort: ?gregexpr is the key. To get started (x is your example vector of character strings): gregexpr([[:alpha:]]+[[:digit:]]+,x) [[1]] [1] 1 3

  1   2   >