[R] Error when calling R from Python

2021-01-25 Thread Marcel Baumgartner
Dear all, my colleague posted our issue on stackoverflow: Calling R script from Python does not save log file in version 4 - Stack Overflow [https://stackoverflow.com/questions/65887485/calling-r-script-from-python-does-not-save-log-file-in-version-4] It is about this kind of call to R: R.exe -

Re: [R] How to find when a value is reached given a function?

2021-01-25 Thread Abby Spurdle
You could use a spline to interpolate the points. (And I'd consider increasing the number of points if possible, say to 200). Then use a root finder, such as uniroot(), to solve for f(i) - k Where, k (a constant), would be 1e6, based on your example. There are a number of variations on this appro

Re: [R] problem installing R and RStudio

2021-01-25 Thread Jeff Newmiller
Your installation of R seems broken. Since RStudio sometimes tries to simplify things and sometimes misses and we aren't typically up to speed with their latest procedures, please describe what you did to install R in terms related to the instructions on CRAN [1] and its install program. When yo

[R] problem installing R and RStudio

2021-01-25 Thread Carlos Gonzalez
Dear, I've just installed R and RStudio. Opening RStudio the following appears in the console. R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out" Copyright (C) 2020 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit) R is free software and comes with ABSO

Re: [R] make new collumns with conditions

2021-01-25 Thread Rui Barradas
Hello, Michael, you're is almost right. I copy&pasted the OP's data but with so many blank spaces I had to put single quotes around those values and column names. Then, when I wrote the answer, I also posted the output of dput(d_vigi) so that others that might want to give it a try would hav

Re: [R] make new collumns with conditions

2021-01-25 Thread Michael Dewey
Dear Krissie I think you misunderstood Rui's response. He was generating some fake data to test the code not suggesting you rebuild your data frame. Michael On 25/01/2021 16:01, krissievdh wrote: Hi, Thanks for your response. I do get what you're doing. However, the table I sent is just a s

Re: [R] make new collumns with conditions

2021-01-25 Thread krissievdh
Hi, So one thing i could manage to do was this: d_vigi$combi <- paste(d_vigi$Behavioral.category, d_vigi$Obs.nr, sep = "-") This created a new column with a combination of the category and the observation number. Afterwards I did this: for(id in d_vigi$combi){ d_vigi$durationpercat[d_vigi$combi

Re: [R] make new collumns with conditions

2021-01-25 Thread krissievdh
Hi, Thanks for your response. I do get what you're doing. However, the table I sent is just a small piece of the complete database. So for me to have to add in everything with structure list (c ..) by hand would be too much work. Just to give you an idea, the database is around 16000 rows and

Re: [R] make new collumns with conditions

2021-01-25 Thread Rui Barradas
Hello, Try the following. First aggregate the data, then get the totals, then the percentages. Finally, put the species in the result. agg <- aggregate(formula = `duration(s)` ~ `observation nr` + `behavior type`, data = d_vigi, FUN = sum, su

Re: [R] How to find when a value is reached given a function?

2021-01-25 Thread Luigi Marongiu
If I run this: ``` Y = c(1, 2, 4, 8, 16, 32, 64, 128) X = 0:7 plot(Y~X, log='y') model <- lm(log10(Y) ~ X) abline(model) predict(model, data.frame(Y=log10(100))) ``` I get a funny answer: ``` 1 2 3 4 5 6 7 8 4.0

Re: [R] How to find when a value is reached given a function?

2021-01-25 Thread Luigi Marongiu
Thanks, I'll check it out. I ran the simulation and I got: ``` t = 1, N = 20,000 t = 2, N = 40,000 t = 3, N = 80,000 t = 4, N = 160,000 t = 5, N = 320,000 t = 6, N = 640,000 t = 7, N = 1,280,000 ``` Hence the answer is t=6.{...} but the problem is to get that fractional value. Would be possible to

Re: [R] make new collumns with conditions

2021-01-25 Thread Michael Dewey
Dear Krissie I think you may be looking for the aggregate command. Note that this is a plain text list so if you post in HTML we do not see what you see. In this case we did not see any red numbers. Michael On 25/01/2021 13:57, krissievdh wrote: Hi, I have a dataset (d_vigi)with this kind

[R] make new collumns with conditions

2021-01-25 Thread krissievdh
Hi, I have a dataset (d_vigi)with this kind of data: behavior type duration(s) observation nr species Non-vigilant 5 1 red deer Vigilant 2 1 red deer Vigilant 2 1 red deer Non-vigilant 3 1 red deer Vigilant 7 2 red deer Vigilant 2 2 red deer Non-vigilant 1 2 red deer Unkown 2 2 red deer Now I hav

Re: [R] Calling procedures

2021-01-25 Thread Rui Barradas
Hello, I am not seeing errors, except that you haven't posted the code for pbivnorm. Do you have a variable named T somewhere? Don't abbreviate TRUE to T in more complex code. Or FALSE to F. And both functions mycdf and mycdf2 could be simplified. mycdf <- function(q,logistic=FALSE){ # **