Re: [R] Extracting values from Surv function in survival package

2024-05-16 Thread CALUM POLWART
I don't think that gives the summary of event numbers without extra work. library(survival) fit <- survfit( Surv(time,status)~sex,data=lung) summary(fit)$n.event [1] 3 1 2 1 1 1 1 2 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 3 1 1 1 1 1 2 [38] 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Re: [R] Extracting values from Surv function in survival package

2024-05-16 Thread Göran Broström
Hi Dennis, look at the help page for summary.survfit, the Value n.event. Göran On 2024-05-15 22:41, Dennis Fisher wrote: OS X R 4.3.3 Colleagues I have created objects using the Surv function in the survival package: FIT.1 Call: survfit(formula = FORMULA1)

Re: [R] Extracting values from Surv function in survival package

2024-05-15 Thread CALUM POLWART
More difficult than it should be IMO. survminer package is often helpful. But if you want to avoid dependency: library(survival) fit <- survfit( Surv(time,status)~sex,data=lung) surfable <-summary(fit)$table surfable # just the events surfable[,"events"] On Wed, 15 May 2024, 21:42 Dennis Fishe

[R] Extracting values from Surv function in survival package

2024-05-15 Thread Dennis Fisher
OS X R 4.3.3 Colleagues I have created objects using the Surv function in the survival package: > FIT.1 Call: survfit(formula = FORMULA1) n events median 0.95LCL 0.95UCL SUBDATA$ARM=1, SUBDATA[, EXP.STRAT]=0 18 13345 156 NA SUBDATA$ARM=2, S

Re: [R] Extracting values from rows which meet a condition in R 3.0.2

2014-04-14 Thread Jim Lemon
On 04/15/2014 06:24 AM, umair durrani wrote: Hi, I have a big data frame with millions of rows and more than 20 columns. Let me first describe what the data is to make question more clear. The original data frame consists of locations, velocities and accelerations of 2169 vehicles during a 15

[R] Extracting values from rows which meet a condition in R 3.0.2

2014-04-14 Thread umair durrani
Hi, I have a big data frame with millions of rows and more than 20 columns. Let me first describe what the data is to make question more clear. The original data frame consists of locations, velocities and accelerations of 2169 vehicles during a 15 minute period. Each vehicle has a unique Vehicl

Re: [R] Extracting values from a ecdf (empirical cumulative distribution function) curve

2013-11-01 Thread Manoranjan Muthusamy
* > > Bill Dunlap > > Spotfire, TIBCO Software > > wdunlap tibco.com > > ** ** > > *From:* Manoranjan Muthusamy [mailto:ranjanmano...@gmail.com] > *Sent:* Friday, November 01, 2013 4:38 AM > *To:* William Dunlap; dulca...@bigpond.com > *Cc:* Rui Barradas; r-he

Re: [R] Extracting values from a ecdf (empirical cumulative distribution function) curve

2013-11-01 Thread William Dunlap
lap tibco.com From: Manoranjan Muthusamy [mailto:ranjanmano...@gmail.com] Sent: Friday, November 01, 2013 4:38 AM To: William Dunlap; dulca...@bigpond.com Cc: Rui Barradas; r-help@r-project.org Subject: Re: [R] Extracting values from a ecdf (empirical cumulative distribution function) curve Th

Re: [R] Extracting values from a ecdf (empirical cumulative distribution function) curve

2013-11-01 Thread Manoranjan Muthusamy
Message- > > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf > > Of Manoranjan Muthusamy > > Sent: Thursday, October 31, 2013 6:18 PM > > To: Rui Barradas > > Cc: r-help@r-project.org > > Subject: Re: [R] Extracting values f

Re: [R] Extracting values from a ecdf (empirical cumulative distribution function) curve

2013-10-31 Thread Duncan Mackay
...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Manoranjan Muthusamy Sent: Friday, 1 November 2013 11:18 To: Rui Barradas Cc: r-help@r-project.org Subject: Re: [R] Extracting values from a ecdf (empirical cumulative distribution function) curve Thank you, Barradas. It works

Re: [R] Extracting values from a ecdf (empirical cumulative distribution function) curve

2013-10-31 Thread William Dunlap
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Manoranjan Muthusamy > Sent: Thursday, October 31, 2013 6:18 PM > To: Rui Barradas > Cc: r-help@r-project.org > Subject: Re: [R] Extracting values from a ecdf (empirical cumulative > dist

Re: [R] Extracting values from a ecdf (empirical cumulative distribution function) curve

2013-10-31 Thread Manoranjan Muthusamy
Thank you, Barradas. It works when finding y, but when I tried to find x using interpolation for a known y it gives 'NA' (for whatever y value). I couldn't find out the reason. Any help is really appreciated. Thanks, Mano On Thu, Oct 31, 2013 at 10:53 PM, Rui Barradas wrote: > Hello, > > As fo

Re: [R] Extracting values from a ecdf (empirical cumulative distribution function) curve

2013-10-31 Thread Rui Barradas
Hello, As for the problem of finding y given the ecdf and x, it's very easy, just use the ecdf: f <- ecdf(rnorm(100)) x <- rnorm(10) y <- f(x) If you want to get the x corresponding to given y, use linear interpolation. inv_ecdf <- function(f){ x <- environment(f)$x y <- env

[R] Extracting values from a ecdf (empirical cumulative distribution function) curve

2013-10-31 Thread Manoranjan Muthusamy
Hi R users, I am a new user, still learning basics of R. Is there anyway to extract y (or x) value for a known x (or y) value from ecdf (empirical cumulative distribution function) curve? Thanks in advance. Mano. [[alternative HTML version deleted]] _

Re: [R] Extracting values from grid cells using for loops

2013-05-19 Thread Bert Gunter
Also ?tapply But if you are a beginner who has done no homework -- i.e. you have made no effort to learn basics with The Intro to R tutorial or other online tutorial -- then you probably won't be able figure it out. We expect some minimal effort by posters. If you have done such homework, then it

Re: [R] Extracting values from grid cells using for loops

2013-05-19 Thread David Winsemius
On May 19, 2013, at 4:20 AM, Jess Baker wrote: > Dear list, > > I am very new to R and have been struggling with extracting data from a > netcdf file. Basically I have read in a file containing vegetation height > data organised in 0.5 degree grid cells spanning the whole globe. Each cell > c

[R] Extracting values from grid cells using for loops

2013-05-19 Thread Jess Baker
Dear list, I am very new to R and have been struggling with extracting data from a netcdf file. Basically I have read in a file containing vegetation height data organised in 0.5 degree grid cells spanning the whole globe. Each cell contains a histogram representing the height distribution and

Re: [R] extracting values

2012-09-18 Thread John Kane
o output a formatted data set that you can copy and paste into your email. John Kane Kingston ON Canada > -Original Message- > From: kari0...@uni.flinders.edu.au > Sent: Tue, 18 Sep 2012 01:18:12 + > To: r-help@r-project.org > Subject: [R] extracting values > >

[R] extracting values

2012-09-17 Thread Champika Shyamalie Kariyawasam
Hi all, I 'm doing the exercise given in the 'SDM with R' (Robert J. Hijmans and Jane Elith), chapter 4.2, regarding extracting values . I tried to do the same using my own data as well. Each cases i received the following error message ; "Error in .xyValues(x, as.matrix(y), ...) : xy should ha

Re: [R] extracting values from txt file that follow user-supplied quote

2012-06-08 Thread emorway
I'll summarize the results in terms of total run time for the suggestions that have been made as well as post the code for those that come across this post in the future. First the results (the code for which is provided second): What I tried to do using suggestions from Bert and Dan: t1 # user

Re: [R] extracting values from txt file that follow user-supplied quote

2012-06-08 Thread Gabor Grothendieck
On Wed, Jun 6, 2012 at 12:54 PM, emorway wrote: > useRs- > > I'm attempting to scan a more than 1Gb text file and read and store the > values that follow a specific key-phrase that is repeated multiple time > throughout the file.  A snippet of the text file I'm trying to read is > attached.  The t

Re: [R] extracting values from txt with regular expression

2012-06-08 Thread Gabor Grothendieck
On Thu, Jun 7, 2012 at 1:40 PM, emorway wrote: > Thanks for your suggestions.  Bert, in your response you raised my awareness > to "regular expressions".  Are regular expressions the same across various > languages?  Consider the following line of text: > > txt_line<-" PERCENT DISCREPANCY =      

Re: [R] extracting values from txt with regular expression

2012-06-08 Thread Rui Barradas
Hello, Just put the entire regexp between parenthesis. extracted <- strsplit(gsub("([+-]?(?:\\d+(?:\\.\\d*)|\\.\\d+)(?:[eE][+-]?\\d+)?)","\\1%&",txt_line),"%&") extracted sapply(strsplit(unlist(extracted), "="), "[", 2) As for speed, I believe that this might take longer. It will have to

Re: [R] extracting values from txt with regular expression

2012-06-07 Thread emorway
Hi Dan and Rui, Thank you for the suggestions, both were very helpful. Rui's code was quite fast...there is one more thing I want to explore for my own edification, but first I need some help fixing the code below, which is a slight modification to Dan's suggestion. It'll no doubt be tough to be

Re: [R] extracting values from txt file that follow user-supplied quote

2012-06-07 Thread Rui Barradas
Hello, I've just read your follow-up question on regular expressions, and I believe this, your original problem, can be made much faster. Just use readLine() differently, reading large amounts of text lines at a time. For this to work you will still need to know the total number of lines in t

Re: [R] extracting values from txt with regular expression

2012-06-07 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of emorway > Sent: Thursday, June 07, 2012 10:41 AM > To: r-help@r-project.org > Subject: [R] extracting values from txt with regular expression > > Tha

[R] extracting values from txt with regular expression

2012-06-07 Thread emorway
Thanks for your suggestions. Bert, in your response you raised my awareness to "regular expressions". Are regular expressions the same across various languages? Consider the following line of text: txt_line<-" PERCENT DISCREPANCY = 0.01 PERCENT DISCREPANCY = -0.05" It s

Re: [R] extracting values from txt file that follow user-supplied quote

2012-06-06 Thread Bert Gunter
I think 1 gb is small enough that this can be easily and efficiently done in R. The key is: regular expressions are your friend. I shall assume that the text file has been read into R as a single character string, named "mystring" . The code below could easily be modifed to work on a a vector of s

Re: [R] extracting values from txt file that follow user-supplied quote

2012-06-06 Thread Rainer Schuermann
R may not be the best tool for this. Did you look at gawk? It is also available for Windows: http://gnuwin32.sourceforge.net/packages/gawk.htm Once gawk has written a new file that only contains the lines / data you want, you could use R for the next steps. You also can run gawk from within R wi

[R] extracting values from txt file that follow user-supplied quote

2012-06-06 Thread emorway
useRs- I'm attempting to scan a more than 1Gb text file and read and store the values that follow a specific key-phrase that is repeated multiple time throughout the file. A snippet of the text file I'm trying to read is attached. The text file is a dumping ground for various aspects of the per

Re: [R] Extracting values in table

2011-08-26 Thread Bert Gunter
Ramnath: With my apologies if I'm wrong, it does not look like you have made much of an effort to learn R's basics, e.g. by working thru the "Introduction to R" tutorial distributed with R. If that is the case, why do you expect us to help? -- Bert On Fri, Aug 26, 2011 at 8:52 AM, Ramnath wrote

[R] Extracting values in table

2011-08-26 Thread Ramnath
Hi All, I am a beginner in programming in r and please do forgive me if my question seems to be silly and sometimes not understandable. 1. we have a list of elements in a list say: ls<-list("N","E","E","N","P","E","M","Q","E","M") 2. We have an another list of tables in a list say: n <- list(

Re: [R] extracting values conditonal on other values

2010-03-03 Thread Phil Spector
Toby - Thanks for the reproducible example! I think this will do what you want: both = merge(test1,test2) subset(both,time >= rise & time <= set) - Phil Spector Statistical Computing Facility

[R] extracting values conditonal on other values

2010-03-03 Thread Toby Gass
Dear R helpers, I have a dataframe (test1) containing the time of sunrise and sunset for each day of the year for 3 years. I have another dataframe (test2) containing measurements that are taken every 15 minutes, 24/7. I would like to extract all rows from test2 that occur between sunrise an

Re: [R] Extracting values from a list

2010-02-19 Thread Paul Hiemstra
chipmaney wrote: Thanks, as a follow-up, how do i extract the list element name (ie, 4-2 or 44-1) Look at names(your_list) cheers, Paul thanks, chipper Date: Thu, 18 Feb 2010 11:56:45 -0800 From: ml-node+1560750-540257540-69...@n4.nabble.com To: chipma...@hotmail.com Subject: Re: Extracti

Re: [R] Extracting values from a list

2010-02-18 Thread chipmaney
Thanks, as a follow-up, how do i extract the list element name (ie, 4-2 or 44-1) thanks, chipper Date: Thu, 18 Feb 2010 11:56:45 -0800 From: ml-node+1560750-540257540-69...@n4.nabble.com To: chipma...@hotmail.com Subject: Re: Extracting values from a list Try this: sapply(x, '[', 'p.value

Re: [R] Extracting values from a list

2010-02-18 Thread Henrique Dallazuanna
Try this: sapply(x, '[', 'p.value') On Thu, Feb 18, 2010 at 5:21 PM, chipmaney wrote: > > I have run a kruskal.test() using the by() function, which returns a list of > results like the following (subset of results): > > Herb.df$ID: 4-2 >       Kruskal-Wallis chi-squared = 18.93, df = 7, p-value

Re: [R] Extracting values from a list

2010-02-18 Thread Paul Hiemstra
chipmaney schreef: I have run a kruskal.test() using the by() function, which returns a list of results like the following (subset of results): Herb.df$ID: 4-2 Kruskal-Wallis chi-squared = 18.93, df = 7, p-value = 0.00841 ---

[R] Extracting values from a list

2010-02-18 Thread chipmaney
I have run a kruskal.test() using the by() function, which returns a list of results like the following (subset of results): Herb.df$ID: 4-2 Kruskal-Wallis chi-squared = 18.93, df = 7, p-value = 0.00841 Herb.df$ID: 44-1

Re: [R] extracting values from correlation matrix

2009-11-16 Thread jim holtman
Assuming that your data is in a dataframe 'cordata' , then following should work: cordata$cor2_value <- sapply(1:nrow(cordata), function(.row){ cor2[cordata$rowname[.row], cordata$colname[.row]] } On Mon, Nov 16, 2009 at 11:44 AM, Lee William wrote: > Hi! All, > > I have 2 correlation matric

[R] extracting values from correlation matrix

2009-11-16 Thread Lee William
Hi! All, I have 2 correlation matrices of 4000x4000 both with same row names and column names say cor1 and cor2. I have extracted some information from 1st matrix cor1 which is something like this: rowname colname cor1_value a b0.8 b a0.8 c

[R] extracting values from a "by" function

2008-07-05 Thread Daniel Stahl
Hello, I am trying to extract t and pvalues from a 1000 ttests using the by-function but everythinhg I tried did not work. Unfortunately googling "by" is not very helpful. Any help will be very appreciated. Cheers, Danile Stall *creating a data set library(MASS) dataset <- mvrnorm(160, mu, Sig

Re: [R] Tukey in R, extracting values

2008-04-10 Thread Dieter Menne
mad_bassie hotmail.com> writes: > how can i extract the values from the CI's when i use following code for a > tukey test? > the output shows three CI's and i know it should work with 'names but i > don't really know how... You forgot to post a self-running example. Chances are always better to g

[R] Tukey in R, extracting values

2008-04-10 Thread mad_bassie
hey, how can i extract the values from the CI's when i use following code for a tukey test? the output shows three CI's and i know it should work with 'names but i don't really know how... thanks library(multcomp) data1$soort<-as.factor(data1$soort) amod<-aov(waarde~soort,data=data1) g<-glht(amod