Re: [R] Flummoxed by gsub().

2017-08-22 Thread PIKAL Petr
Hi Rolf I am not at all an expert in regex but gsub("[[:alpha:]]","",x) Works as you expected. Do not ask me why. Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Rolf Turner > Sent: Wednesday, August 23, 2017 7:46 AM > To: r-help mail

Re: [R] Flummoxed by gsub().

2017-08-22 Thread Stefan Evert
> On 23 Aug 2017, at 07:45, Rolf Turner wrote: > > My reading of ?regex led me to believe that > >gsub("[:alpha:]","",x) > > should give the result that I want. That's looking for any of the characters a, l, p, h, : . What you meant to say was gsub("[[:alpha:]]","",x) i.e. the

Re: [R] Rounding of problem with sum command in R

2017-08-22 Thread John Kane via R-help
Try options(digits=12) sum(v) BTW I don't get the same value as you did when you calculated manually. On Tuesday, August 22, 2017, 10:39:26 AM EDT, Bert Gunter wrote: ... and following up on Spencer's answer, see the "digits" argument of ?options and ?print.default. Cheers, Bert Bert Gunter

[R] Flummoxed by gsub().

2017-08-22 Thread Rolf Turner
I have a vector (say "x") of the form [1] "mung5" "mung10" "mung20" "gorp5" "gorp10" "gorp20" I want to extract just the numbers (strings of digits) that appear at the end of the strings in "x". My reading of ?regex led me to believe that gsub("[:alpha:]","",x) should give the re

[R] likert Package

2017-08-22 Thread Jeff Reichman
R- Help Forum Working with the "likert" package and find that my "bar" graphs are backwards (see attached) > summary(results) Item low neutral high meansd 4 Q4 5 15 80 2.75 0.5501196 5 Q5 20 40 40 2.20 0.7677719 1 Q1 65 305 1.40 0.5982430 3

Re: [R] splitting a dataframe in R based on multiple gene names in a specific column

2017-08-22 Thread Jim Lemon
Hi Bogdan, Messy, and very specific to your problem: df.sample.gene<-read.table( text="Chr Start End Ref Alt Func.refGene Gene.refGene 284 chr2 16080996 16080996 C T ncRNA_exonic GACAT3 448 chr2 113979920 113979920 C T ncRNA_exonic LINC01191,LOC100499194 465 chr2 1312793

[R] splitting a dataframe in R based on multiple gene names in a specific column

2017-08-22 Thread Bogdan Tanasa
I would appreciate please a suggestion on how to do the following : i'm working with a dataframe in R that contains in a specific column multiple gene names, eg : > df.sample.gene[15:20,2:8] Chr Start End Ref Alt Func.refGene Gene.refGene284 chr2 16080996 16080996 C T ncRNA_e

Re: [R] boot.stepAIC fails with computed formula

2017-08-22 Thread Bert Gunter
OK, here's the problem. Continuing with your example: strt1 <- lm(y1 ~1, dat) strt2 <- lm(frm1,dat) > strt1 Call: lm(formula = y1 ~ 1, data = dat) Coefficients: (Intercept) 41.73 > strt2 Call: lm(formula = frm1, data = dat) Coefficients: (Intercept) 41.73 Note that the formula

Re: [R] Convert Factor to Date

2017-08-22 Thread Spencer Graves
On 2017-08-22 2:04 PM, Patrick Casimir wrote: > > This is large data set Spencer. What about when the dates change as below: > � Have you tried what I suggested?� What were the results? Spencer > > COL1 COL2 > Jan-141-Aug-16 > Feb-141-Aug-16 > Mar-141-Aug-16 > Apr

Re: [R] Convert Factor to Date

2017-08-22 Thread Patrick Casimir
This is large data set Spencer. What about when the dates change as below: COL1COL2 Jan-14 1-Aug-16 Feb-14 1-Aug-16 Mar-14 1-Aug-16 Apr-14 1-Aug-16 May-14 1-Aug-16 Jun-14 1-Aug-16 Jul-14 1-Aug-16 Aug-14 1-Aug-16 Sep-14 1-Aug-16 Oct-14 1-Aug-16 Nov-14 1-Aug-16 Dec-14 1-Aug-16 Jan-1

Re: [R] Error in .jnew(“java/io/FileOutputStream”, jFile)

2017-08-22 Thread Martin Møller Skarbiniks Pedersen
On 22 August 2017 at 17:51, Александр Мащенко wrote: > > > I don't know R absolutely, but I have to do this work for my diploma. So I'm sorry for strange message below. Please, help me anybody decides this issue. [...] > > write.xlsx(ab_ret, "C:\\Users\\Sapl\\Desktop\\NATA\\code\\Results\\Create

Re: [R] Convert Factor to Date

2017-08-22 Thread Spencer Graves
On 2017-08-22 1:30 PM, Patrick Casimir wrote: Dear R Fellows, I Have a dataset( data1) with 2 columns of date showing a class of factor. How to convert them to date? Then compare them, keep the greater date only in a new column. Using as.Date to change the class to Date but the data becomes

[R] Convert Factor to Date

2017-08-22 Thread Patrick Casimir
Dear R Fellows, I Have a dataset( data1) with 2 columns of date showing a class of factor. How to convert them to date? Then compare them, keep the greater date only in a new column. Using as.Date to change the class to Date but the data becomes NA. Much Thanks COL1COL2 Apr-16 1-Nov-16

Re: [R] boot.stepAIC fails with computed formula

2017-08-22 Thread Bert Gunter
SImplify your call to lm using the "." argument instead of manipulating formulas. > strt <- lm(y1 ~ ., data = dat) and you do not need to explicitly specify the "1+" on the rhs for lm, so > frm2<-as.formula(paste(trg," ~ ", paste(xvars,collapse = "+"))) works fine, too. Anyway, doing this gives

Re: [R] boot.stepAIC fails with computed formula

2017-08-22 Thread Bert Gunter
Failed? What was the error message? Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Aug 22, 2017 at 8:17 AM, Stephen O'hagan wrote: > I'm

Re: [R] How to benchmark speed of load/readRDS correctly

2017-08-22 Thread William Dunlap via R-help
Note that if you force a garbage collection each iteration the times are more stable. However, on the average it is faster to let the garbage collector decide when to leap into action. mb_gc <- microbenchmark::microbenchmark(gc(), { x <- as.list(sin(1:5e5)); x <- unlist(x) / cos(1:5e5) ; sum(x) }

Re: [R] boot.stepAIC fails with computed formula

2017-08-22 Thread Steve O'Hagan
The error is "the model fit failed in 50 bootstrap samples Error: non-character argument" Cheers, SOH. On 22/08/2017 17:52, Bert Gunter wrote: Failed? What was the error message? Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking t

Re: [R] Wilcoxon signed-rank test

2017-08-22 Thread Bert Gunter
This query is offtopic for this list, as it is about statistics, not R programming. stats.stackexchange.com is a good venue for statistics questions. However, you are confused. Wilcoxon does NOT test for differences in population means. e.g. Consider the 2 samples: A: 5,6,7 B: 1,2, 50 Cheers,

[R] Wilcoxon signed-rank test

2017-08-22 Thread Karolis Uziela
Hi, I am using wilcox.test function to test the difference between the means of two samples. The data points are paired, so I am using a paired test. There is one strange case. Sample A has a higher mean than a sample B. However, wilcox.test function says that sample B has a significantly higher

Re: [R] How to benchmark speed of load/readRDS correctly

2017-08-22 Thread Jeff Newmiller
Caching happens, both within the operating system and within the C standard library. Ostensibly the intent for those caches is to help performance, but you are right that different low-level caching algorithms can be a poor match for specific application level use cases such as copying files or

Re: [R] How to benchmark speed of load/readRDS correctly

2017-08-22 Thread William Dunlap via R-help
The large value for maximum time may be due to garbage collection, which happens periodically. E.g., try the following, where the unlist(as.list()) creates a lot of garbage. I get a very large time every 102 or 51 iterations and a moderately large time more often mb <- microbenchmark::microbenc

[R] Error in .jnew(“java/io/FileOutputStream”, jFile)

2017-08-22 Thread Александр Мащенко
I don't know R absolutely, but I have to do this work for my diploma. So I'm sorry for strange message below. Please, help me anybody decides this issue. If you need any information, I'll show you all what you need. **error**: > #save > #csv >file.create("C:\\Users\\Sapl\\Desktop\\NATA\\code\\Res

[R] boot.stepAIC fails with computed formula

2017-08-22 Thread Stephen O'hagan
I'm trying to use boot.stepAIC for feature selection; I need to be able to specify the name of the dependent variable programmatically, but this appear to fail: In R-Studio with MS R Open 3.4: library(bootStepAIC) #Fake data n<-200 x1 <- runif(n, -3, 3) x2 <- runif(n, -3, 3) x3 <- runif(n, -3

Re: [R] Rounding of problem with sum command in R

2017-08-22 Thread Bert Gunter
... and following up on Spencer's answer, see the "digits" argument of ?options and ?print.default. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

Re: [R] Rounding of problem with sum command in R

2017-08-22 Thread Spencer Graves
On 2017-08-22 9:26 AM, niharika singhal wrote: Hello I have a vector v=c(0.0886,0.1744455,0.1379778,0.1209769,0.1573065,0.1134463,0.2074027) when i do sum(v) or 0.0886+0.1744455+0.1379778+0.1209769+0.1573065+0.1134463+0.2074027 i am getting output as 1 No:  That's only the display:

[R] Rounding of problem with sum command in R

2017-08-22 Thread niharika singhal
Hello I have a vector v=c(0.0886,0.1744455,0.1379778,0.1209769,0.1573065,0.1134463,0.2074027) when i do sum(v) or 0.0886+0.1744455+0.1379778+0.1209769+0.1573065+0.1134463+0.2074027 i am getting output as 1 But if i add them manually i get 1.0026 I do not want to round of my value since

Re: [R] How to benchmark speed of load/readRDS correctly

2017-08-22 Thread J C Nash
Not convinced Jeff is completely right about this not concerning R, since I've found that the application language (R, perl, etc.) makes a difference in how files are accessed by/to OS. He is certainly correct that OS (and versions) are where the actual reading and writing happens, but sometimes

Re: [R] How to benchmark speed of load/readRDS correctly

2017-08-22 Thread Jeff Newmiller
You need to study how reading files works in your operating system. This question is not about R. -- Sent from my phone. Please excuse my brevity. On August 22, 2017 5:53:09 AM PDT, raphael.fel...@agroscope.admin.ch wrote: >Dear all > >I was thinking about efficient reading data into R and tried

[R] How to benchmark speed of load/readRDS correctly

2017-08-22 Thread raphael.felber
Dear all I was thinking about efficient reading data into R and tried several ways to test if load(file.Rdata) or readRDS(file.rds) is faster. The files file.Rdata and file.rds contain the same data, the first created with save(d, ' file.Rdata', compress=F) and the second with saveRDS(d, ' file

Re: [R] My very first loop!! I failed. May I have some start-up aid?

2017-08-22 Thread Dagmar
Dear Jeff, Thank you! You helped me a lot! Tagmarie Am 19.08.2017 um 08:11 schrieb Jeff Newmiller: Thank you for providing the example code... for the request of running it multiple times it would have helped if you could have confirmed that the example ran through without errors... there we