Re: [R] nls problem

2020-04-02 Thread Troels Ring
Thank you – yes indeed, on suggestion from Rui I noticed that the problem was mainly that I took the parameters from “m” instead of coef(m) i.e abd -1630.71 457.68 -32.11 Instead of a b d -1630.70993 457.67555 -32.11469 And that

Re: [R] Label

2020-04-02 Thread Jim Lemon
Hi Val, library(plotrix) barpos<-barplot(dat$count, names.arg=c("A", "B", "C","D"), col="blue", ylim = c(0,30), ylab = "Count", xlab = "Grade") barlabels(barpos,dat$count,prop=1) Jim On Fri, Apr 3, 2020 at 1:31 PM Val wrote: > > Hi all, > > I have a sample

[R] Label

2020-04-02 Thread Val
Hi all, I have a sample of data set, dat <- read.table(header=TRUE, text='Lab count A 24 B 19 C 30 D 18') barplot(dat$count, names.arg=c("A", "B", "C","D"), col="blue", ylim = c(0,30), ylab = "Count", xlab = "Grade") I want add the number of counts at the top of

Re: [R] [External Email] Re: arranging multiple lattice graphs on a page

2020-04-02 Thread Richard M. Heiberger
don't forget library(latticeExtra) latticeExtra provides many very useful user-level functions. On Thu, Apr 2, 2020 at 7:52 PM Christopher W. Ryan wrote: > > Thanks, I'll take a look. I also finally came across gridExtra, which allows > me to do it as well. > > --Chris Ryan > > On April 2,

Re: [R] [External Email] Re: arranging multiple lattice graphs on a page

2020-04-02 Thread Christopher W. Ryan
Thanks, I'll take a look. I also finally came across gridExtra, which allows me to do it as well. --Chris Ryan On April 2, 2020 6:45:58 PM EDT, Bert Gunter wrote: >See ?print.trellis, especially the "split" argument. > > >Bert Gunter > >"The trouble with having an open mind is that people keep

Re: [R] repeat rows of matrix by number (k) in one colummatrix adding column j with values 1:k

2020-04-02 Thread Rasmus Liland
On 2020-04-03 07:39 +1100, Jim Lemon wrote: | | Hi Rasmus, | Very nice. The R help list is a bit like a | quiz show where the contestants must | balance the alacrity with which they press | their buttons with the confidence that they | have the correct answer. A slow motion game | of wits in

Re: [R] repeat rows of matrix by number (k) in one colummatrix adding column j with values 1:k

2020-04-02 Thread Rasmus Liland
On 2020-04-01 15:33 +1100, Jim Lemon wrote: > Hi Nevil, > It's a nasty piece of work, but: Hi! How about this one: data <- c(rep(1:4, times=3), 2, 1, 3, 2) dimnames <- list(NULL, c("x", "y", "z", "k")) ncol <- length(data)/4 M <- matrix(data=data, nrow=ncol, ncol=ncol,

Re: [R] arranging multiple lattice graphs on a page

2020-04-02 Thread Bert Gunter
See ?print.trellis, especially the "split" argument. 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 Thu, Apr 2, 2020 at 2:23 PM Christopher W. Ryan wrote: >

[R] arranging multiple lattice graphs on a page

2020-04-02 Thread Christopher W. Ryan
I would like to place two separate plots, one above the other, something like this (MWE for illustration): library(lattice) data(iris) layout(matrix(c(1,2), 2, 1, byrow = TRUE)) with(iris, (plot(Sepal.Length ~ Petal.Length))) with(iris, (plot(Sepal.Length ~ Petal.Width))) but with lattice, so

Re: [R] repeat rows of matrix by number (k) in one colummatrix adding column j with values 1:k

2020-04-02 Thread Jim Lemon
Hi Rasmus, Very nice. The R help list is a bit like a quiz show where the contestants must balance the alacrity with which they press their buttons with the confidence that they have the correct answer. A slow motion game of wits in which the prizes are self-awarded. Jim On Fri, Apr 3, 2020 at

[R] Question about nlminb function

2020-04-02 Thread Lim, Hwanggyu
Hello, My name is Hwanggyu Lim. I am working estimating parameters of non-negative function, which has local maximums. For example, the function has three parameters (e.g., f(a, b, c)) and I need to estimate them. For this, I am using nlminb optimization function and it works fine. Here is my

Re: [R] nls problem

2020-04-02 Thread J C Nash
Yes, I was waiting to see how long before it would be noticed that this is not the sort of problem for which nls() is appropriate. And I'll beat the drum again that nls() uses a simple (and generally deprecated) forward difference derivative approximation that gets into trouble a VERY high

Re: [R] nls problem

2020-04-02 Thread William Dunlap via R-help
Roundoff/cancelation error: compare the following. The first is equivalent to your function, the last to fitted(). > with(aedf, t(cbind(1, pH, pH^2) %*% round(coef(m), digits=2))) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]

Re: [R] disk.frame change default directory that disk.frames are saved in?

2020-04-02 Thread Rui Barradas
Hello, Às 15:53 de 02/04/20, Eric Berger escreveu: Rui wrote: " This is SO dependent," I think it's a typo. He meant to write "This is OS dependent" Right. SO is Portuguese :(. Sorry for the mess. Rui Barradas The Stack Overflow link he provided has info for both Windows and Linux. On

Re: [R] disk.frame change default directory that disk.frames are saved in?

2020-04-02 Thread Eric Berger
Rui wrote: " This is SO dependent," I think it's a typo. He meant to write "This is OS dependent" The Stack Overflow link he provided has info for both Windows and Linux. On Thu, Apr 2, 2020 at 4:59 PM Jeff Newmiller wrote: > What does SO dependent mean? Cross posted with Stack Overflow? > >

Re: [R] disk.frame change default directory that disk.frames are saved in?

2020-04-02 Thread Jeff Newmiller
What does SO dependent mean? Cross posted with Stack Overflow? The question appears to be to be about a contributed package called disk.frame, which I don't use. The examples I see explicitly call out using the tmpdir function... so simply replacing the use of not the tmpdir function with an R

Re: [R] project path in Rmd

2020-04-02 Thread Ivan Calandra
Thanks Jeff, I was just completely unaware of these options! Now I know. Best, Ivan -- Dr. Ivan Calandra TraCEr, laboratory for Traceology and Controlled Experiments MONREPOS Archaeological Research Centre and Museum for Human Behavioural Evolution Schloss Monrepos 56567 Neuwied, Germany +49

Re: [R] project path in Rmd

2020-04-02 Thread Jeff Newmiller
Where did this false dichotomy come from? The rmarkdown::render function has quite flexible parameters for compiling rmarkdown files in subdirectories without changing the current directory. And RStudio has a Global configuration to enable compiling using the Project directory as "current"

[R] ggplot stat smooth and poly

2020-04-02 Thread PIKAL Petr
Dear all I am not sure, but I believe that in past it was possible to add smoothing lines in ggplot even if some group did not have enough points to perform calculation (although I did not find any version which could deliver it). Here is the code and data library(ggplot2) p <- ggplot(test,

Re: [R] nls problem

2020-04-02 Thread Rui Barradas
Simpler: FPG2 <- function(x, model){ as.vector(cbind(1, x, x^2) %*% coef(model)) } Hope this helps, Rui Barradas Às 12:56 de 02/04/20, Rui Barradas escreveu: Hello, Sorry, disregard my previous e-mail. Instead of your FPG function try FPG <- function(pH, model) {   coef(model)[1] +

Re: [R] nls problem

2020-04-02 Thread Rui Barradas
Hello, Sorry, disregard my previous e-mail. Instead of your FPG function try FPG <- function(pH, model) { coef(model)[1] + coef(model)[2]*pH + coef(model)[3]*pH^2 } FPG(aedf$pH, m) fitted(m) Hope this helps, Rui Barradas Às 12:30 de 02/04/20, Rui Barradas escreveu: Hello, Tip: in a

Re: [R] project path in Rmd (Ivan Calandra)

2020-04-02 Thread Ivan Calandra
Thanks Tim, that's exactly what I needed. I came across the here package before, but I didn't see the point of using it since RStudio already deals with relative paths and sets up the working directory where the file is. I didn't notice the functionality of getting the project directory with the

Re: [R] nls problem

2020-04-02 Thread Rui Barradas
Hello, Tip: in a formula, pH^2 = pH*pH is an interaction. pH^2 = pH*pH = pH + pH + pH:pH = pH Try I(pH^2) Hope this helps, Rui Barradas Às 12:07 de 02/04/20, Troels Ring escreveu: Dear friends - I'm on Win10 with R 6.3.1 and have a very simple problem with nls which apparently gives a

[R] nls problem

2020-04-02 Thread Troels Ring
Dear friends - I'm on Win10 with R 6.3.1 and have a very simple problem with nls which apparently gives a decent fit to the parable below, even without starting values. But when I then think I know the meaning of the three parameters a, b, and d it goes very wrong. I guess I am again overlooking

Re: [R] project path in Rmd (Ivan Calandra)

2020-04-02 Thread Howard, Tim G (DEC) via R-help
You also should be able to reference locations from the 'root' of your project using the here() package. https://here.r-lib.org/ Best, Tim Howard > Date: Thu, 2 Apr 2020 10:21:47 +0100 > From: Rui Barradas > To: Ivan Calandra > Cc: "r-help@r-project.org" > Subject: Re: [R] project

Re: [R] disk.frame change default directory that disk.frames are saved in?

2020-04-02 Thread Rui Barradas
Hello, This is SO dependent, see if this StackOverflow post can be of help. https://stackoverflow.com/questions/17107206/change-temporary-directory Hope this helps, Rui Barradas Às 10:16 de 02/04/20, nevil amos escreveu: I would like to change the default directory within which all disk

Re: [R] project path in Rmd

2020-04-02 Thread Ivan Krylov
On Thu, 2 Apr 2020 11:02:56 +0200 Ivan Calandra wrote: > I do not know this ".." command (could you please show me how to use > it in a relative path?), but it sounds like a good start. Each '..' in the path moves you up one level in the directory tree. Here I use '..' once to access the

Re: [R] project path in Rmd

2020-04-02 Thread Rui Barradas
Hello, This is not an answer to the original problem, it's about '..'. (And a bit more.) About '..', see if the following sequence of instructions can help. Subdirectories '~/tmp' and '~/snap' exist on my PC, change to '~/analysis/scripts' or to what makes sense on yours. od <- getwd()

[R] disk.frame change default directory that disk.frames are saved in?

2020-04-02 Thread nevil amos
I would like to change the default directory within which all disk frames are saved to a directory on an SSD, which is not the drive there the r tempdir is located. for example instead of saving all disk.frames in tempdir the are all saved in ./media/SSDdrive/DF? Thanks [[alternative

Re: [R] project path in Rmd

2020-04-02 Thread Ivan Calandra
What about searching for the .Rproj file and using its path as the new working directory using setwd()? But I know that it is indeed not recommended in knitted files (FAQ #5 ). And I do not know how to search up the folder structure anyway... Ivan -- Dr. Ivan

Re: [R] project path in Rmd

2020-04-02 Thread Ivan Calandra
I do not know this ".." command (could you please show me how to use it in a relative path?), but it sounds like a good start. But it implies that I know in advance how many folders up the parent directory is. I guess in most cases it will always be the same, but it would be even better if it

Re: [R] project path in Rmd

2020-04-02 Thread Ivan Krylov
On Thu, 2 Apr 2020 10:30:29 +0200 Ivan Calandra wrote: > The problem I then have is to specify the path for 'raw_data' and > 'derived_data' <...> And these folders are not subfolders of > the working directory '~/analysis/scripts'. > I would like to avoid absolute paths of course Is there a

Re: [R] project path in Rmd

2020-04-02 Thread Ivan Calandra
So what you're saying is that I should have scripts in the project directory and not in a subfolder within it, right? But what if I need (or at least want) to? Ivan -- Dr. Ivan Calandra TraCEr, laboratory for Traceology and Controlled Experiments MONREPOS Archaeological Research Centre and

Re: [R] project path in Rmd

2020-04-02 Thread Jeff Newmiller
Make it so. Outside R. At the command line, use cd before you start R. This should feel natural. In a GUI file browser, double clicking on a file type assigned to a program by default sets the containing directory to be current directory before kicking off the program, so double-clicking on an

Re: [R] project path in Rmd

2020-04-02 Thread Jeff Newmiller
I recommend not using setwd. Then you can always assume your current working directory is your project directory and reference relative to that. On April 2, 2020 1:30:29 AM PDT, Ivan Calandra wrote: >Dear useRs, > >I believe this is R code so appropriate for this list, but let me know >if this

Re: [R] project path in Rmd

2020-04-02 Thread Ivan Calandra
Hi Jeff, But if I do not use setwd(), the current working directory is NOT the project directory. That's what my problem is about... I guess I was not clear in my email... Ivan -- Dr. Ivan Calandra TraCEr, laboratory for Traceology and Controlled Experiments MONREPOS Archaeological Research

[R] project path in Rmd

2020-04-02 Thread Ivan Calandra
Dear useRs, I believe this is R code so appropriate for this list, but let me know if this relates more to RStudio itself. I am working on an RStudio project. In that project directory, I have a folder called 'analysis' and in there a folder called 'scripts' ('~/analysis/scripts'). My data files