Re: [R] rmarkdown and source call to R file.

2021-01-21 Thread Jeff Newmiller
This is off topic here... please read the Posting Guide about getting help on contributed packages. Check out the RStudio forums. FWIW you should also look carefully at ?knitr::knit_global ... I don't think it does what you seem to think it does. On January 21, 2021 10:49:17 PM PST, Georgios v

[R] rmarkdown and source call to R file.

2021-01-21 Thread Georgios via R-help
Hi! I'm new in R and this list. I made a shiny app using R studio. my files are: -server.R -ui.R -helper.R -Report.Rmd. All the files are on the same directory and helper.R is a file that contains a lot of functions used in Report.Rmd and server.R for some reason I cant call from Repo

Re: [R] Why is rm(list=ls()) bad practice?

2021-01-21 Thread Duncan Murdoch
On 21/01/2021 5:20 p.m., J C Nash wrote: In a separate thread Jeff Newmiller wrote: rm(list=ls()) is a bad practice... especially when posting examples. It doesn't clean out everything and it removes objects created by the user. This query is to ask 1) Why is it bad practice to clear the wor

Re: [R] Why is rm(list=ls()) bad practice?

2021-01-21 Thread Bert Gunter
Do you mean: rm(list = ls(all = TRUE)) ? ... or something else? 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, Jan 21, 2021 at 2:21 PM J C Nash wrote: >

Re: [R] rbind common header to file list

2021-01-21 Thread Miluji Sb
Thank you, that was it. Best, Milu On Wed, Jan 20, 2021 at 1:33 PM Eric Berger wrote: > for ( file in filelist ) > > > > On Wed, Jan 20, 2021 at 2:21 PM Miluji Sb wrote: > >> Thank you for your reply and the solution. Yes, I would like the date to >> be >> the column header for all the files

[R] Why is rm(list=ls()) bad practice?

2021-01-21 Thread J C Nash
In a separate thread Jeff Newmiller wrote: > rm(list=ls()) is a bad practice... especially when posting examples. It > doesn't clean out everything and it removes objects created by the user. This query is to ask 1) Why is it bad practice to clear the workspace when presenting an example? I'm as

Re: [R] Col names in a data frame

2021-01-21 Thread Bernard Comcast
Thanks - I had seen that parameter but did not think the ( would be illegal but now I understand why it considers it illegal. Thanks again Bernard Sent from my iPhone so please excuse the spelling!" > On Jan 21, 2021, at 4:14 PM, Duncan Murdoch wrote: > > On 21/01/2021 3:58 p.m., Bernard Mc

Re: [R] Col names in a data frame

2021-01-21 Thread Bernard Comcast
Thanks - I had seen that parameter but did not think the ( would be illegal but now I understand why it considers it illegal. Thanks again Bernard Sent from my iPhone so please excuse the spelling!" > On Jan 21, 2021, at 4:14 PM, Duncan Murdoch wrote: > > On 21/01/2021 3:58 p.m., Bernard McG

Re: [R] Col names in a data frame

2021-01-21 Thread Jan T. Kim via R-help
it looks to me that the names are cranked through make.names for data frames case while that doesn't happen for matrices. Peeking into the `colnames<-` code supports this idea, but that in turn uses `names<-` which is a primitive and so defies further easy peeking. The data.frame function provides

Re: [R] Col names in a data frame

2021-01-21 Thread Sarah Goslee
Hi, data.frame() checks names by default to ensure that column names are legal, but there's an argument to change that. >From ?data.frame() check.names: logical. If ‘TRUE’ then the names of the variables in the data frame are checked to ensure that they are syntactically va

Re: [R] Col names in a data frame

2021-01-21 Thread Duncan Murdoch
On 21/01/2021 3:58 p.m., Bernard McGarvey wrote: Here is an example piece of code to illustrate an issue: rm(list=ls()) # Clear Workspace # Data1 <- matrix(data=rnorm(9,0,1),nrow=3,ncol=3) Colnames1 <- c("(A)","(B)","(C)") colnames(Data1) <- Colnames1 print(Data1) DataFrame1 <- data.frame(Data1)

Re: [R] Col names in a data frame

2021-01-21 Thread Jeff Newmiller
rm(list=ls()) is a bad practice... especially when posting examples. It doesn't clean out everything and it removes objects created by the user. Read ?data.frame, particularly regarding the check.names parameter. The intent is to make it easier to use DF$A notation, though DF$`(A)` is usable if

[R] Col names in a data frame

2021-01-21 Thread Bernard McGarvey
Here is an example piece of code to illustrate an issue: rm(list=ls()) # Clear Workspace # Data1 <- matrix(data=rnorm(9,0,1),nrow=3,ncol=3) Colnames1 <- c("(A)","(B)","(C)") colnames(Data1) <- Colnames1 print(Data1) DataFrame1 <- data.frame(Data1) print(DataFrame1) colnames(DataFrame1) <- Colnames

[R] New Package: memify

2021-01-21 Thread Bert Gunter
The new package, memify, provides a simple way to construct and maintain functions that keep state i.e. remember their argument lists. This can be useful when one needs to repeatedly invoke the same function with only a small number of argument changes at each invocation. The package is tiny -- b

[R] [R-pkgs] simplePHENOTYPES v1.3.0

2021-01-21 Thread Bonfim Fernandes, Samuel
Hi All, I hope this message finds you well. We have released simplePHENOTYPES v1.3.0. Our package simulates single and multiple (correlated) traits in a wide range of scenarios, including additive, dominance, and epistatic (AxA, AxAxA, ...) models. Some of the new features include: - The opti

Re: [R] Plot histogram and lognormal fit on the same time

2021-01-21 Thread Rui Barradas
Hello, A solution based on Marc's first one, maybe easier? (It doesn't rely on multiplying the dlnorm values by 400 since it plots the histogram with freq = FALSE.) set.seed(2020) data <- rlnorm(100, meanlog = 1, sdlog = 1) library(MASS) f <- fitdistr(data, "lognormal") f$estimate p <- pr

Re: [R] Plot histogram and lognormal fit on the same time

2021-01-21 Thread Bert Gunter
In future, you should try to search before posting. I realize that getting good search terms can sometimes be tricky, but not in this case: 'plot density with histogram in R' or similar on rseek.org or just on your usual search platform brought up several ways to do it. As a (slightly offtopic) si

Re: [R] Plot histogram and lognormal fit on the same time

2021-01-21 Thread Marc Girondot via R-help
Two solutions not exactly equivalent ; data <- rlnorm(100, meanlog = 1, sdlog = 1) histdata <- hist(data, ylim=c(0, 100)) library(MASS) f <- fitdistr(data, "lognormal") f$estimate lines(x=seq(from=0, to=50, by=0.1), � y=dlnorm(x=seq(from=0, to=50, by=0.1), meanlog = f$estimate["meanlog"], sdl

[R] Plot histogram and lognormal fit on the same time

2021-01-21 Thread Eric Leroy
Hi, I would like to plot the histogram of data and fit it with a lognormal distribution. The ideal, would be to superimpose the fit on the histogram and write the results of the fit on the figure. Right now, I was able to plot the histogram and fit the density with a lognormal, but I can't

[R] [Rd] R 4.0.4 scheduled for February 15

2021-01-21 Thread Peter Dalgaard via R-help
Full schedule is available on https://developer.r-project.org (or https://svn.r-project.org/R-dev-web/trunk/index.html for the impatient). -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A

[R] Problem on Converting "day of year" to "year", "month" and "day" has been solved

2021-01-21 Thread Jibrin Alhassan
Dear R users, > I want to thank you all for your contributions to the problem I posted. It > has been solved. Find below the code that solved the problem. > df1 <- read.table("SWS1998_2002", header = TRUE) df1$date <- as.Date(paste(df1$year, df1$day), format = "%Y %j", origin = "1998-01-01") df2 <

Re: [R] Runs of at least 5 days with certain value in a rasterbrick in R

2021-01-21 Thread PIKAL Petr
Hallo I do not know anything about rasterbrick but what about splitting it to list according to season. If you have dates starting 1.12. and ending 28.2 as one season, diff should be 1day for each season. If you manage to correctly split your data, you can cycle through list or use lapply to ge