Re: [R] Pause script at input from terminal (interactive use)

2019-04-18 Thread Luigi Marongiu
I am realizing as well that R is not the best option for an interactive session. I changed the script to get the input from a config file; it is less elegant because the procedure now requires double the files than with CLI input, but at the end of the day is more practical when most of the answer

Re: [R] lm fails on some large input

2019-04-18 Thread Dingyuan Wang
The final goal is to make two lines and find the intersection point. I don't want to argue more about the reason. The tol suggestion is reasonable, and I'll take that. 2019/4/19 4:12, Jeff Newmiller: The fact that you think x~y is interchangeable with y~x suggests to me that you will have a di

Re: [R] lm fails on some large input

2019-04-18 Thread Fox, John
Dear Dingyuan Wang, But your question was answered clearly earlier in this thread (I forget by whom), showing that lm() provides the solution to the regression of x on y if the criterion for singularity is tightened: > lm(x ~ y) Call: lm(formula = x ~ y) Coefficients: (Intercept)y

Re: [R] power analysis for Friedman's test

2019-04-18 Thread Greg Snow
Generally you should do the power analysis before collecting any data. Since you have results it looks like you already have the data collected. But if you want to compute the power for a future study, one option is to use simulation. 1. decide what the data will look like 2. decide how you will

Re: [R] lm fails on some large input

2019-04-18 Thread Jeff Newmiller
The fact that you think x~y is interchangeable with y~x suggests to me that you will have a difficult time convincing R Core that this is a bug. I recommend that you take at leastan upper division college course in linear regression first. On April 18, 2019 9:35:55 AM PDT, Dingyuan Wang wrote:

Re: [R] lm fails on some large input

2019-04-18 Thread Dingyuan Wang
I just want to make a line out of timestamps vs some coordinates, so y~x or x~y doesn't matter. Yes, I know the answer. When trying R, I'm surprised that R can't solve that either. I first noticed that PostgreSQL can't solve it, and found that they fixed that in pg 12. https://www.postgresql

[R] power analysis for Friedman's test

2019-04-18 Thread George Karavasilis
Hello, I am running a non parametric repeated measures experiment with Friedman’s test:     Friedman rank sum test data:  glikozi and week and subject Friedman chi-squared = 18.538, df = 3, p-value = 0.0003405 How could I run a power analysis for this test in R? Thank you! -- George Kara

Re: [R] Looping with looping

2019-04-18 Thread Greg Snow
When the goal of looping is to compute something and save each iteration into a vector or list, then it is usually easier to use the lapply/sapply/replicate functions and save the result into a single list rather than a bunch of global variables. Here is a quick example that does the same computat

Re: [R] Pause script at input from terminal (interactive use)

2019-04-18 Thread Greg Snow
I am not an expert on Rscript, but I don't think that an actual terminal is ever used when using Rscript. And `interactive()` will probably always be false. So if you want the script to pause for input, you need to have some form of user interface to work with. One option is to use the tcltk pac

Re: [R] lm fails on some large input

2019-04-18 Thread Jeff Newmiller
I make a general rule not to stick time values into numerical analysis algorithms without first subtracting a reasonable epoch (to obtain difftime) and then using as.numeric.POSIXt with the units argument set explicitly so the analysis uses numeric values that I can interpret. While the explicit

Re: [R] R 3.4.4 is released

2019-04-18 Thread Jeff Newmiller
To be clear, if you encounter problems with R using RStudio, try doing "the same thing" using an interface provided in the R installed software directly... under Windows that might be through RGui or on Mac using R.app or on any platform via the terminal command line R program. If the problem go

Re: [R] Help with a setting some values of a df vector to 0 but not all values

2019-04-18 Thread Bill Poling
Thank you PIKAL Petr. From: PIKAL Petr Sent: Thursday, April 18, 2019 8:54 AM To: Bill Poling ; r-help (r-help@r-project.org) Subject: RE: Help with a setting some values of a df vector to 0 but not all values Hi seems to me simple Sample data > nozero <- c(1565, 1569, 1674, 415, 1564) >

Re: [R] lm fails on some large input

2019-04-18 Thread Fox, John
Dear Peter, > -Original Message- > From: peter dalgaard [mailto:pda...@gmail.com] > Sent: Thursday, April 18, 2019 12:23 PM > To: Fox, John > Cc: Michael Dewey ; Dingyuan Wang > ; r-help@r-project.org > Subject: Re: [R] lm fails on some large input > > Um, you need to reverse y and x the

Re: [R] lm fails on some large input

2019-04-18 Thread Berry, Charles
> On Apr 18, 2019, at 8:24 AM, Michael Dewey wrote: > > Perhaps subtract 1506705766 from y? Good advice. Some further notes follow. One can specify `tol` to have a smaller than default value e.g. m2 <- lm(x ~ y, tol=1e-12) which is accurate: plot(y,x) abline(coef=coef(m2)) Users

Re: [R] lm fails on some large input

2019-04-18 Thread William Dunlap via R-help
This sort of data arises quite easily if you deal with time/dates around now. E.g., > d <- data.frame( + when = seq(as.POSIXct("2017-09-29 18:22:01"), by="secs", len=10), + measurement = log2(1:10)) > coef(lm(data=d, measurement ~ when)) (Intercept) when 2.17910611147

Re: [R] lm fails on some large input

2019-04-18 Thread peter dalgaard
Um, you need to reverse y and x there. The question was about lm(y ~ x) > X <- cbind(1, y) > solve(crossprod(X)) Error in solve.default(crossprod(X)) : system is computationally singular: reciprocal condition number = 6.19587e-35 Actually, lm can QR perfectly OK, but it gets caught by its

Re: [R] Is it possible to calculate in r the number of days and count of b in var r from the following table:

2019-04-18 Thread Bert Gunter
Yes. Have you gone through any R tutorials, yet? There are many good ones on the web, some of which are listed here: https://www.rstudio.com/online-learning/ See also the "Intro to R" tutorial that ships with R. Spending a little time with these will help you understand R's capabilities and, of c

Re: [R] lm fails on some large input

2019-04-18 Thread Fox, John
Dear Michael and Dingyuan Wang, > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Michael > Dewey > Sent: Thursday, April 18, 2019 11:25 AM > To: Dingyuan Wang ; r-help@r-project.org > Subject: Re: [R] lm fails on some large input > > Perhaps subtract

Re: [R] R 3.4.4 is released

2019-04-18 Thread Michael Dewey
Dear Stephen Questions about RStudio ae best asked in their help forums but I would definitely install the latest version of R and RStudio and do update.packages before asking Michael On 18/04/2019 13:19, Stephen Muldoon wrote: Hi, I am new to R studio. If my R studio continually asks to r

Re: [R] lm fails on some large input

2019-04-18 Thread Michael Dewey
Perhaps subtract 1506705766 from y? Saying some other software does it well implies you know what the _correct_ answer is here but I would question what that means with this sort of data-set. On 17/04/2019 07:26, Dingyuan Wang wrote: Hi, This input doesn't have any interesting properties ex

Re: [R] R 3.4.4 is released

2019-04-18 Thread Stephen Muldoon
Hi, I am new to R studio. If my R studio continually asks to restart for new packages to run, should I remove R studio and reinstall this latest version? Thanks, Stephen __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.

[R] Looping with looping

2019-04-18 Thread ani jaya
Dear R community, I'm trying to create a looping to see the effect of number of samples from one dataset. Lets say I have 10 values in a single data frame and I want to see the mean of each sampling let say from 2-9 number of sampling. But I want to do the repetition let say up to 100 for each num

[R] Is it possible to calculate in r the number of days and count of b in var r from the following table:

2019-04-18 Thread ajaykumar cp
Hello Is it possible to calculate in r the number of days and count of b in var r from the following table: id r s t u 1 a 100 1 27-06-2017 1 a 200 0 29-06-2017 1 b 300 0 01-07-2017 2 a 500 1 12-06-2017 3 b 100 0 02-07-2017 3 a 600 1 02-07-2017 4 a 200 0 12-06-2017 4 a 300 1 15-06-2017 4 b 200 0

[R] lm fails on some large input

2019-04-18 Thread Dingyuan Wang
Hi, This input doesn't have any interesting properties except y is unix time. Spreadsheets can do this well. Is this a bug that lm can't do x ~ y? R version 3.5.2 (2018-12-20) -- "Eggshell Igloo" Copyright (C) 2018 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bi

[R] Pause script at input from terminal (interactive use)

2019-04-18 Thread Luigi Marongiu
Dear all, I am trying to write an interactive script where the user type some input from the terminal. I used readline() but when I launch the file with Rscript, the function is overwritten directly, there is no waiting for the user's input. For instance, this example: VAR1 = as.numeric(readline(p

Re: [R] Help with a setting some values of a df vector to 0 but not all values

2019-04-18 Thread PIKAL Petr
Hi seems to me simple Sample data > nozero <- c(1565, 1569, 1674, 415, 1564) > test <- sample(c(1:10, nozero), 250, replace=T) > test [1] 10264 41559 1565 15692 10 1569 415 15693 [16]49 10115 1013 109 15644 108

[R] (no subject)

2019-04-18 Thread Catalin Roibu
Dear R users, I want to compute a nlm for each plot an species and after that to save the regression coef for each species and plot. Thanks for your help! I tried something like this s<-data.frame(unique(ah$sp)) pl<-data.frame(unique(ah$plot)) z<-data.frame(matrix(nrow=0, ncol=5)) for(i in 1:nr

Re: [R] Help with a setting some values of a df vector to 0 but not all values

2019-04-18 Thread Bill Poling
Yes, thank you Eric, that's got it, sheesh, I knew it was simple. Many thanks. WHP From: Eric Berger Sent: Thursday, April 18, 2019 8:47 AM To: Bill Poling Cc: r-help (r-help@r-project.org) Subject: Re: [R] Help with a setting some values of a df vector to 0 but not all values df$ClaimManag

Re: [R] Help with a setting some values of a df vector to 0 but not all values

2019-04-18 Thread Eric Berger
df$ClaimManagerID[ !(df$ClaimManagerID %in% c(1565,1569,1674,415,1564))] <- 0 On Thu, Apr 18, 2019 at 3:39 PM Bill Poling wrote: > Good morning. > > #RStudio Version 1.1.456 > sessionInfo() > #R version 3.5.3 (2019-03-11) > #Platform: x86_64-w64-mingw32/x64 (64-bit) > #Running under: Windows >=

[R] Help with a setting some values of a df vector to 0 but not all values

2019-04-18 Thread Bill Poling
Good morning. #RStudio Version 1.1.456 sessionInfo() #R version 3.5.3 (2019-03-11) #Platform: x86_64-w64-mingw32/x64 (64-bit) #Running under: Windows >= 8 x64 (build 9200) I have a df column that looks like the below. #68 ID's including the 0 value I want to set all the values to 0 with the exc

Re: [R] Debugging Rmarkdown

2019-04-18 Thread Thierry Onkelinx via R-help
Dear Patrick, This is not easy to debug without a reprex I would check the content of zzz and wide.i in the loop str(wide.i) zzz <- rbind(zzz, wide.i) str(zzz) Note that the Rmd always runs in a clean environment. This might explain the difference Best regards, ir. Thierry Onkelinx Statistic

Re: [R] picewise function in nls....

2019-04-18 Thread Ivan Krylov
On Thu, 18 Apr 2019 10:36:10 + akshay kulkarni wrote: > fx <- (x1 <= -2)*(x1^2) + (x1 > -2 && x1 < 2)*(x1^3) + (x1 > = > 2)*(x1^4) > > Can I include fx in an nls call to create something like this: > > NLS1 <- nls(y ~ a*(sin(x2) + fx), start = list(a = 2)) ? For now, you can, since fx

[R] Debugging Rmarkdown

2019-04-18 Thread Patrick Connolly
I have a function that works in ESS, but it fails if I include it in an .Rmd file that I tried to knit using Rstudio. I found advice at: https://www.rstudio.com/products/rstudio/release-notes/debugging-with-rstudio/ It seems to be not referring to markdown files. Somewhere else suggested calling

Re: [R] combining data.frames with is.na & match (), two questions

2019-04-18 Thread Eric Berger
Hi Drake, Petr's suggestion to use the merge() function is good. Another (possibly overkill) approach is to use functions from the dplyr package, which is a fantastic package to get familiar with. For example, the last alternative that Petr suggests is an example of what is called a "left join" (me

Re: [R] combining data.frames with is.na & match (), two questions

2019-04-18 Thread PIKAL Petr
Hi I wonder why such combination is so complicated in your text book. Having data frames fr1 and fr2 > dput(fr1) structure(list(Fruit = structure(c(1L, 3L, 2L), .Label = c("banana", "mango", "pear"), class = "factor"), Calories = c(100L, 100L, 200L)), class = "data.frame", row.names = c("1", "2"

Re: [R] combining data.frames with is.na & match (), two questions

2019-04-18 Thread peter dalgaard
The whole thing is a merge operation, i.e. > FruitNutr <- read.table(text=" + Fruit Calories + 1 banana 100 + 2 pear 100 + 3 mango 200 + ") > FruitData <- read.table(text=" + Fruit Color Shape Juice + 1 apple red round 1 + 2 banana yellow oblong 0 + 3 pear green pear 0.5 + 4 orange orange round 1

Re: [R] combining data.frames with is.na & match (), two questions

2019-04-18 Thread Michael Dewey
Dear Drake See in-line comments On 18/04/2019 00:24, Drake Gossi wrote: Hello everyone, I'm working through this book, *Humanities Data in R* (Arnold & Tilton), and I'm just having trouble understanding this maneuver. In sum, I'm trying to combine data in two different data.frames. This data

[R] Helping for approrpriate test

2019-04-18 Thread bienvenidoz...@gmail.com
Dear All, I have in field and collect some data and i need your help for the appropriate test to analyze the data. Indeed, i collected data from 200 farmers. From cluster analysis, i found four type or clusters of farmers. During the survey, i asked all the farmers to rank the different constrai