Re: [R] Help in Recursive Function for steps reconstruction in Clusters Analysis - HCA: Single Link
For now, I've been able to think of a temporary solution... until I can think of a better teaching solution: The same function f(): # f <- function(xmd) { rs <- NULL xmd1 <- 9 xmd2 <- 9 if (xmd[1] > 0) { xmd1 <- f(r$merge[ xmd[1], ]) } else { xmd1 <- xmd[1] } if (xmd[2] > 0) { xmd2 <- f(r$merge[ xmd[2], ]) } else { xmd2 <- xmd[2] } return( rbind( rs, rbind( xmd1, xmd2 ) ) ) } Didactic example to illustrate the chain behavior of the "Single Link" Algorithm n <- 100 d <- matrix( runif( n * 2 ), n, 2 ) r <- hclust( dist( d ), met='single' ) plot( d, cex=1, col=1 ) for( i in 1:( nrow( d ) - 1 ) ){ p <- as.numeric( abs( f( r$merge[ i, ] ) ) ) points( d[ p,], col=i, cex=2, pch=19 ) cat(' Step: ', i, '\n' ) flush.console() Sys.sleep( .2 ) } Em 26/10/2024 16:14, Cleber Borges escreveu: Hello everybody, I'm trying to build a function to illustrate, in 2D, the sequence of the "Single Link" algorithm (the purpose is merely didactic). The idea is to have the scatter of points on a graph. Iteratively, build the segments (with the "segments()" function, for each step). I simulated a data set "d", and created an object "r" using the command: r <- hclust( dist( d ), met='single' ) My problem: I created a recursive function, "f()", to find the shortest distances. It is defined below. But the return has only one column, while I thought there would be two columns. What I get: ### # Testing f() f( c(2, 3) ) is the fourth step of hclust [,1] xmd1 -6 xmd2 -10 xmd1 -3 xmd1 -4 xmd2 -5 What I expected: ## # xmd1 xmd2 # -6 -10 # -3 -5 # -4 -5 If anyone can help me with this recursive function, I would appreciate it in advance. I've never used recursion before, so I don't have a good grasp of how it works. Thank you very much in advance, Cleber. All details are below: d <- scan() 0.986 0.900 -1.331 1.503 -0.220 -0.752 0.102 -0.071 -0.171 0.018 -0.782 0.490 1.154 -0.074 -0.768 -1.529 1.761 -1.396 -0.730 0.910 d <- matrix( d, 10, byrow=T ) r <- hclust( dist( d ), met='single' ) r$merge # [,1] [,2] # [1,] -4 -5 # [2,] -6 -10 # [3,] -3 1 # [4,] 2 3 # [5,] -2 4 # [6,] -8 5 # [7,] -1 -7 # [8,] 6 7 # [9,] -9 8 f <- function(xmd) { rs <- NULL xmd1 <- 9 xmd2 <- 9 if (xmd[1] > 0) { xmd1 <- f(r$merge[ xmd[1], ]) } else { xmd1 <- xmd[1] } if (xmd[2] > 0) { xmd2 <- f(r$merge[ xmd[2], ]) } else { xmd2 <- xmd[2] } return( rbind( rs, rbind( xmd1, xmd2 ) ) ) } # Testing f() f( c(2, 3) ) # result of f() # [,1] # xmd1 -6 # xmd2 -10 # xmd1 -3 # xmd1 -4 # xmd2 -5 # My expectative: # xmd1 xmd2 # -6 -10 # -3 -5 # -4 -5 # Testing f() f( c( 6, 7) ) # result of f() # [,1] # xmd1 -8 # xmd1 -2 # xmd1 -6 # xmd2 -10 # xmd1 -3 # xmd1 -4 # xmd2 -5 # xmd1 -1 # xmd2 -7 # My expectative: # xmd1 xmd2 # -8 -10 # -2 -10 # -6 -10 # -3 -5 # -4 -5 # -1 -7 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide https://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help in Recursive Function for steps reconstruction in Clusters Analysis - HCA: Single Link
On 2024-10-26 3:14 p.m., Cleber Borges via R-help wrote: Hello everybody, I'm trying to build a function to illustrate, in 2D, the sequence of the "Single Link" algorithm (the purpose is merely didactic). The idea is to have the scatter of points on a graph. Iteratively, build the segments (with the "segments()" function, for each step). I simulated a data set "d", and created an object "r" using the command: r <- hclust( dist( d ), met='single' ) My problem: I created a recursive function, "f()", to find the shortest distances. It is defined below. But the return has only one column, while I thought there would be two columns. I suspect you used rbind() where you should have used cbind() in your f, here: return( rbind( rs, rbind( xmd1, xmd2 ) ) ) which should have been return( rbind( rs, cbind( xmd1, xmd2 ) ) ) There may be other places where this change is needed; I haven't tried running your code. Duncan Murdoch __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide https://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help in Recursive Function for steps reconstruction in Clusters Analysis - HCA: Single Link
Hello everybody, I'm trying to build a function to illustrate, in 2D, the sequence of the "Single Link" algorithm (the purpose is merely didactic). The idea is to have the scatter of points on a graph. Iteratively, build the segments (with the "segments()" function, for each step). I simulated a data set "d", and created an object "r" using the command: r <- hclust( dist( d ), met='single' ) My problem: I created a recursive function, "f()", to find the shortest distances. It is defined below. But the return has only one column, while I thought there would be two columns. What I get: ### # Testing f() f( c(2, 3) ) is the fourth step of hclust [,1] xmd1 -6 xmd2 -10 xmd1 -3 xmd1 -4 xmd2 -5 What I expected: ## # xmd1 xmd2 # -6 -10 # -3 -5 # -4 -5 If anyone can help me with this recursive function, I would appreciate it in advance. I've never used recursion before, so I don't have a good grasp of how it works. Thank you very much in advance, Cleber. All details are below: d <- scan() 0.986 0.900 -1.331 1.503 -0.220 -0.752 0.102 -0.071 -0.171 0.018 -0.782 0.490 1.154 -0.074 -0.768 -1.529 1.761 -1.396 -0.730 0.910 d <- matrix( d, 10, byrow=T ) r <- hclust( dist( d ), met='single' ) r$merge # [,1] [,2] # [1,] -4 -5 # [2,] -6 -10 # [3,] -3 1 # [4,] 2 3 # [5,] -2 4 # [6,] -8 5 # [7,] -1 -7 # [8,] 6 7 # [9,] -9 8 f <- function(xmd) { rs <- NULL xmd1 <- 9 xmd2 <- 9 if (xmd[1] > 0) { xmd1 <- f(r$merge[ xmd[1], ]) } else { xmd1 <- xmd[1] } if (xmd[2] > 0) { xmd2 <- f(r$merge[ xmd[2], ]) } else { xmd2 <- xmd[2] } return( rbind( rs, rbind( xmd1, xmd2 ) ) ) } # Testing f() f( c(2, 3) ) # result of f() # [,1] # xmd1 -6 # xmd2 -10 # xmd1 -3 # xmd1 -4 # xmd2 -5 # My expectative: # xmd1 xmd2 # -6 -10 # -3 -5 # -4 -5 # Testing f() f( c( 6, 7) ) # result of f() # [,1] # xmd1 -8 # xmd1 -2 # xmd1 -6 # xmd2 -10 # xmd1 -3 # xmd1 -4 # xmd2 -5 # xmd1 -1 # xmd2 -7 # My expectative: # xmd1 xmd2 # -8 -10 # -2 -10 # -6 -10 # -3 -5 # -4 -5 # -1 -7 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide https://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [EXTERNAL] R-help Digest, Vol 260, Issue 19
I think that Stevie Pederson has the right idea, but it is not obvious what the threshold should be. Example: > n <- 2428716; sum(rep(1/n,n)) - 1 [1] -3.297362e-14 I assume that equally large errors in the other direction are also possible. Regards, Jorgen Harmse. -- Message: 1 Date: Wed, 23 Oct 2024 15:56:00 +1030 From: Stevie Pederson To: r-help@r-project.org Subject: [R] OSX-specific Bug in randomForest Message-ID: Content-Type: text/plain; charset="utf-8" Hi, It appears there is an OSX-specific bug in the function `randomForest.default()` Going by the source code at https://github.com/cran/randomForest/blob/master/R/randomForest.default.R the bug is on line 103 If the vector `cutoff` is formed using `cutoff <- rep(1/9, 9)` (line #101) the test on line 103 will fail on OSX as the sum is greater than 1 due to machine precision errors. sum(rep(1 / 9, 9)) - 1 # [1] 2.220446e-16 This will actually occur for a scenario when the number of factor levels (nclass) is 9, 11, 18, 20 etc.The problem does not occur on Linux, and I haven't tested on WIndows. A suggestion may be to change the opening test if (sum(cutoff) > 1 || ...) to if (sum(cutoff) - 1 > .Machine$double.eps || ... however, I'm sure there's a more elegant way to do this Thanks in advance [[alternative HTML version deleted]] *** [[alternative HTML version deleted]] ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide https://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help needed! Pre-processing the dataset before splitting - model building - model tuning - performance evaluation
Às 06:04 de 24/09/2024, Bekzod Akhmuratov escreveu: Below is the link for a dataset on focus. I want to split the dataset into training and test set, use training set to build the model and model tune, use test set to evaluate performance. But before doing that I want to make sure that original dataset doesn't have noise, collinearity to address, no major outliers so that I have to transform the data using techniques like Box-Cox and looking at VIF to eliminate highly correlated predictors. https://www.kaggle.com/datasets/joaofilipemarques/google-advanced-data-analytics-waze-user-data When I fit the original dataset into regression model with Minitab, I get attached result for residuals. It doesn't look normal. Does it mean there is high correlation or the dataset in have nonlinear response and predictors? How should I approach this? What would be my strategy if I use in Python, Minitab, and R. Explaining it in all softwares are appraciated if possible. ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide https://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hello, R-Help is a list of questions and answers about R code, not to suggest analysis strategies. Anyhow, I suggest that you read the Python notebook at the bottom of the Kaggle page, it addresses your main question and if you have doubts translating the Python code to R code, ask us more specific questions on those doubts. Hope this helps, Rui Barradas -- Este e-mail foi analisado pelo software antivírus AVG para verificar a presença de vírus. www.avg.com ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide https://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help needed! Pre-processing the dataset before splitting - model building - model tuning - performance evaluation
Below is the link for a dataset on focus. I want to split the dataset into training and test set, use training set to build the model and model tune, use test set to evaluate performance. But before doing that I want to make sure that original dataset doesn't have noise, collinearity to address, no major outliers so that I have to transform the data using techniques like Box-Cox and looking at VIF to eliminate highly correlated predictors. https://www.kaggle.com/datasets/joaofilipemarques/google-advanced-data-analytics-waze-user-data When I fit the original dataset into regression model with Minitab, I get attached result for residuals. It doesn't look normal. Does it mean there is high correlation or the dataset in have nonlinear response and predictors? How should I approach this? What would be my strategy if I use in Python, Minitab, and R. Explaining it in all softwares are appraciated if possible. ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide https://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help on date objects...
Às 05:23 de 28/07/2024, akshay kulkarni escreveu: Dear members, WHy is the following code returning NA instead of the date? as.Date("2022-01-02", origin = "1900-01-01", format = "%y%d%m") [1] NA Thanking you, Yours sincerely, AKSHAY M KULKARNI [[alternative HTML version deleted]] ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hello, There are several reasons for your result. 1. You have 4 digits year but format %y (lower case = 2 digits year) It should be %Y 2. Your date has '-' as separator but your format doesn't have a separator. Also, though less important: 1. You don't need argument origin. This is only needed with numeric to date coercion. 2. Are you sure the format is -DD-MM, year-day-month? as.Date("2022-01-02", format = "%Y-%d-%m") #> [1] "2022-02-01" # note the origin is not your posted origin date, # see the examples on Windows and Excel # dates in help("as.Date") as.Date(19024, origin = "1970-01-01") #> [1] "2022-02-01" Hope this helps, Rui Barradas -- Este e-mail foi analisado pelo software antivírus AVG para verificar a presença de vírus. www.avg.com ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help on date objects...
as.Date("2022-01-02", origin="1900-01-01", format="%Y-%d-%m") On Sun, Jul 28, 2024 at 7:24 AM akshay kulkarni wrote: > Dear members, > WHy is the following code returning NA > instead of the date? > > > > as.Date("2022-01-02", origin = "1900-01-01", format = "%y%d%m") > [1] NA > > > Thanking you, > Yours sincerely, > AKSHAY M KULKARNI > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help on date objects...
Dear members, WHy is the following code returning NA instead of the date? > as.Date("2022-01-02", origin = "1900-01-01", format = "%y%d%m") [1] NA Thanking you, Yours sincerely, AKSHAY M KULKARNI [[alternative HTML version deleted]] ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help trying to understand R documentation on libraries paths
I am not going to search the sources for it (your problem, your work ;-) ), but the wording would be consistent with a call like .libPaths(c(Sys.getenv("R_LIBS"), Sys.getenv("R_LIBS_USER"))) -pd > On 17 Jun 2024, at 13:40 , Iago Giné Vázquez wrote: > > Thanks, > > Regarding .libPaths, I am asking for the call to `.libPaths()`, so I > understand there is no `new` in the call, as in the documentation I cited. > > Iago > > De: peter dalgaard > Enviat el: dilluns, 17 de juny de 2024 13:26 > Per a: Iago Giné Vázquez > A/c: r-help@r-project.org > Tema: Re: [R] Help trying to understand R documentation on libraries paths > > (Inline) > > > On 17 Jun 2024, at 09:51 , Iago Giné Vázquez wrote: > > > > Hi, > > > > 1 - On help(".libPaths", help_type = "text") one can read: > > > > First, '.Library.site' is initialized from 'R_LIBS_SITE'. > > > > However, I have > > > >> Sys.getenv("R_LIBS_SITE") > > [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/site-library" > >> .Library.site > > character(0) > > > > Is this consistent? > > It is implied that R_LIBS_SITE should point to an existing directory. I see > the same thing on Mac: > > > .Library.site > character(0) > > Sys.getenv("R_LIBS_SITE") > [1] "/Library/Frameworks/R.framework/Resources/site-library" > > list.files(Sys.getenv("R_LIBS_SITE")) > character(0) > > I.e., R_LIBS_SITE is where a site library _if any_ should live. If it is not > there, there is no poin in searching it. Unless you actually have a > site-library, I don't think there is a problem. > > > > > 2 - Next, on the same help document, one can read: > > > > Then, '.libPaths()' is called with the combination > > of the directories given by 'R_LIBS' and 'R_LIBS_USER'. > > > > > > This time, I get > >> Sys.getenv("R_LIBS") > > [1] "" > >> Sys.getenv("R_LIBS_USER") > > [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.0/library" > >> .libPaths() > > [1] "C:/Users/i.gine/AppData/Local/Programs/R/R-4.4.0/library" > > "C:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/library" > > > > > > Later is written: > > > > Function '.libPaths' always uses the values of '.Library' and > > '.Library.site' in the base namespace. > > > > and indeed > > > >> .Library > > [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/library" > > > > > > Then, shouldn't be this specified above together with "directories given by > > 'R_LIBS' and 'R_LIBS_USER'"? > > > > The logic of .libPath() is > > > .libPaths > function (new, include.site = TRUE) > { > if (!missing(new)) { > new <- Sys.glob(path.expand(new)) > paths <- c(new, if (include.site) .Library.site, .Library) > paths <- paths[dir.exists(paths)] > .lib.loc <<- unique(normalizePath(paths, "/")) > } > else .lib.loc > } > > so if you "call it with" new=something, then (.Library.site, .Library) is > automagically appended, unless you expressly tell it not to. > > -pd > > > > > Am I understanding it wrongly? Otherwise, what do you think on the current > > way this help page is explained? > > > > Thank you for your help and time. > > > > Best regards, > > > > Iago > > > > [[alternative HTML version deleted]] > > > > ______ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > -- > Peter Dalgaard, Professor, > Center for Statistics, Copenhagen Business School > Solbjerg Plads 3, 2000 Frederiksberg, Denmark > Phone: (+45)38153501 > Office: A 4.23 > Email: pd@cbs.dk Priv: pda...@gmail.com -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help trying to understand R documentation on libraries paths
Thanks, Regarding .libPaths, I am asking for the call to `.libPaths()`, so I understand there is no `new` in the call, as in the documentation I cited. Iago De: peter dalgaard Enviat el: dilluns, 17 de juny de 2024 13:26 Per a: Iago Gin� V�zquez A/c: r-help@r-project.org Tema: Re: [R] Help trying to understand R documentation on libraries paths (Inline) > On 17 Jun 2024, at 09:51 , Iago Gin� V�zquez wrote: > > Hi, > > 1 - On help(".libPaths", help_type = "text") one can read: > > First, '.Library.site' is initialized from 'R_LIBS_SITE'. > > However, I have > >> Sys.getenv("R_LIBS_SITE") > [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/site-library" >> .Library.site > character(0) > > Is this consistent? It is implied that R_LIBS_SITE should point to an existing directory. I see the same thing on Mac: > .Library.site character(0) > Sys.getenv("R_LIBS_SITE") [1] "/Library/Frameworks/R.framework/Resources/site-library" > list.files(Sys.getenv("R_LIBS_SITE")) character(0) I.e., R_LIBS_SITE is where a site library _if any_ should live. If it is not there, there is no poin in searching it. Unless you actually have a site-library, I don't think there is a problem. > > 2 - Next, on the same help document, one can read: > > Then, '.libPaths()' is called with the combination > of the directories given by 'R_LIBS' and 'R_LIBS_USER'. > > > This time, I get >> Sys.getenv("R_LIBS") > [1] "" >> Sys.getenv("R_LIBS_USER") > [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.0/library" >> .libPaths() > [1] "C:/Users/i.gine/AppData/Local/Programs/R/R-4.4.0/library" > "C:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/library" > > > Later is written: > > Function '.libPaths' always uses the values of '.Library' and > '.Library.site' in the base namespace. > > and indeed > >> .Library > [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/library" > > > Then, shouldn't be this specified above together with "directories given by > 'R_LIBS' and 'R_LIBS_USER'"? > The logic of .libPath() is > .libPaths function (new, include.site = TRUE) { if (!missing(new)) { new <- Sys.glob(path.expand(new)) paths <- c(new, if (include.site) .Library.site, .Library) paths <- paths[dir.exists(paths)] .lib.loc <<- unique(normalizePath(paths, "/")) } else .lib.loc } so if you "call it with" new=something, then (.Library.site, .Library) is automagically appended, unless you expressly tell it not to. -pd > > Am I understanding it wrongly? Otherwise, what do you think on the current > way this help page is explained? > > Thank you for your help and time. > > Best regards, > > Iago > >[[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd@cbs.dk Priv: pda...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help trying to understand R documentation on libraries paths
(Inline) > On 17 Jun 2024, at 09:51 , Iago Giné Vázquez wrote: > > Hi, > > 1 - On help(".libPaths", help_type = "text") one can read: > > First, '.Library.site' is initialized from 'R_LIBS_SITE'. > > However, I have > >> Sys.getenv("R_LIBS_SITE") > [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/site-library" >> .Library.site > character(0) > > Is this consistent? It is implied that R_LIBS_SITE should point to an existing directory. I see the same thing on Mac: > .Library.site character(0) > Sys.getenv("R_LIBS_SITE") [1] "/Library/Frameworks/R.framework/Resources/site-library" > list.files(Sys.getenv("R_LIBS_SITE")) character(0) I.e., R_LIBS_SITE is where a site library _if any_ should live. If it is not there, there is no poin in searching it. Unless you actually have a site-library, I don't think there is a problem. > > 2 - Next, on the same help document, one can read: > > Then, '.libPaths()' is called with the combination > of the directories given by 'R_LIBS' and 'R_LIBS_USER'. > > > This time, I get >> Sys.getenv("R_LIBS") > [1] "" >> Sys.getenv("R_LIBS_USER") > [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.0/library" >> .libPaths() > [1] "C:/Users/i.gine/AppData/Local/Programs/R/R-4.4.0/library" > "C:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/library" > > > Later is written: > > Function '.libPaths' always uses the values of '.Library' and > '.Library.site' in the base namespace. > > and indeed > >> .Library > [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/library" > > > Then, shouldn't be this specified above together with "directories given by > 'R_LIBS' and 'R_LIBS_USER'"? > The logic of .libPath() is > .libPaths function (new, include.site = TRUE) { if (!missing(new)) { new <- Sys.glob(path.expand(new)) paths <- c(new, if (include.site) .Library.site, .Library) paths <- paths[dir.exists(paths)] .lib.loc <<- unique(normalizePath(paths, "/")) } else .lib.loc } so if you "call it with" new=something, then (.Library.site, .Library) is automagically appended, unless you expressly tell it not to. -pd > > Am I understanding it wrongly? Otherwise, what do you think on the current > way this help page is explained? > > Thank you for your help and time. > > Best regards, > > Iago > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd@cbs.dk Priv: pda...@gmail.com __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help trying to understand R documentation on libraries paths
Hi, 1 - On help(".libPaths", help_type = "text") one can read: First, '.Library.site' is initialized from 'R_LIBS_SITE'. However, I have > Sys.getenv("R_LIBS_SITE") [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/site-library" > .Library.site character(0) Is this consistent? 2 - Next, on the same help document, one can read: Then, '.libPaths()' is called with the combination of the directories given by 'R_LIBS' and 'R_LIBS_USER'. This time, I get > Sys.getenv("R_LIBS") [1] "" > Sys.getenv("R_LIBS_USER") [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.0/library" > .libPaths() [1] "C:/Users/i.gine/AppData/Local/Programs/R/R-4.4.0/library" "C:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/library" Later is written: Function '.libPaths' always uses the values of '.Library' and '.Library.site' in the base namespace. and indeed > .Library [1] "c:/Users/i.gine/AppData/Local/Programs/R/R-4.4.1/library" Then, shouldn't be this specified above together with "directories given by 'R_LIBS' and 'R_LIBS_USER'"? Am I understanding it wrongly? Otherwise, what do you think on the current way this help page is explained? Thank you for your help and time. Best regards, Iago [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R-help Digest, Vol 255, Issue 17
You might be interested in the `Rdatasets` package, https://vincentarelbundock.github.io/Rdatasets/ which lists over 2200 datasets from various packages. What is the context of the `lottery` dataset. I seem to recall smth to do with the NJ Lottery -Michael 1. Availability of Sdatasets (Avro Alo) -- Message: 1 Date: Sun, 19 May 2024 08:58:20 + From: Avro Alo To: "r-help@r-project.org" Subject: [R] Availability of Sdatasets Message-ID: <8I3Bj0m1IzC35J4nEoROCf1yZD66oeLHFLtxsXKSty3vplcl5gKp-_XmdSvEbG0UYtxv8g0Jw0ihsR5x0MS0QdF7DOmooZ2C9BJVqUUlNSQ=@protonmail.com> Content-Type: text/plain; charset="utf-8" >From the mention in R-intro I went to look at The new S language book. In chapter 1 it has a lottery dataset. So naturally I thought it is pre-supplied with R. But I didn't fount, made a google search and found the package that has the dataset, https://docs.tibco.com/pub/enterprise-runtime-for-R/6.1.1/doc/html/Language_Reference/Sdatasets/00Index.html This package is very interesting on it's own. But how can I get it? Also, shouldn't regular R installation have this too? Thanks! (first time posting here) -- Subject: Digest Footer ___ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- End of R-help Digest, Vol 255, Issue 17 ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help - Package: stats - function ar.ols
The data came through fine, the program was a miss. Can you paste the program into a ".txt" document like a notepad file and send that? You could also paste it into your email IF your email is configured to send text and NOT html. TIm -Original Message----- From: R-help On Behalf Of Pedro Gavronski. Sent: Friday, February 23, 2024 5:00 AM To: Rui Barradas Cc: r-help@r-project.org; r-help-requ...@r-project.org Subject: Re: [R] help - Package: stats - function ar.ols [External Email] Hello, Thanks for the reply Rui and for pointing out that I forgot to attach my code. Please find attached in this email my code and data. Thanks in advance. Best regards, Pedro Gerhardt Gavronski. On Fri, Feb 23, 2024 at 5:50 AM Rui Barradas wrote: > > Às 16:34 de 22/02/2024, Pedro Gavronski. escreveu: > > Hello, > > > > My name is Pedro and it is nice to meet you all. I am having trouble > > understanding a message that I receive when use function ar.ols from > > package stats, it says that "Warning message: > > In ar.ols(x = dtb[2:6966, ], demean = FALSE, intercept = TRUE, > > prewhite = TRUE) : > >model order: 2 singularities in the computation of the > > projection matrix results are only valid up to model order 1, which > > I do not know what it means, if someone could clarify it, I would > > really appreciate it. > > > > Attached to this email you will find my code and data I used to run > > this formula. > > > > Thanks in advance. > > > > Best regards, Pedro. > > > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://st/ > > at.ethz.ch%2Fmailman%2Flistinfo%2Fr-help&data=05%7C02%7Ctebert%40ufl > > .edu%7C0afd65836d774adc099408dc349f53c7%7C0d4da0f84a314d76ace60a6233 > > 1e1b84%7C0%7C0%7C638443106144255449%7CUnknown%7CTWFpbGZsb3d8eyJWIjoi > > MC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C > > %7C&sdata=12OGc13jk3Lejmcvx5WH8Bko8JSpRxbtW3mzL3OIjyk%3D&reserved=0 > > PLEASE do read the posting guide > > http://www/ > > .r-project.org%2Fposting-guide.html&data=05%7C02%7Ctebert%40ufl.edu% > > 7C0afd65836d774adc099408dc349f53c7%7C0d4da0f84a314d76ace60a62331e1b8 > > 4%7C0%7C0%7C638443106144262387%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wL > > jAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&s > > data=fAVz0iQ0zS5pmrxrzNeazRrrv%2FyjFdWvwMfgjhibdEA%3D&reserved=0 > > and provide commented, minimal, self-contained, reproducible code. > Hello, > > Thanks for the data but the code is missing from the attachment. > Can you please post your code? In an attachment or directly in the > e-mail body. > > Rui Barradas > > > -- > Este e-mail foi analisado pelo software antivírus AVG para verificar a > presença de vírus. > http://www.a/ > vg.com%2F&data=05%7C02%7Ctebert%40ufl.edu%7C0afd65836d774adc099408dc34 > 9f53c7%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C638443106144266047 > %7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6I > k1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=rdqEhXdZ5%2FThzbhuKgspNaBPyhf > aC%2BWh7MFq4iq%2BxVE%3D&reserved=0 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help - Package: stats - function ar.ols
Às 16:34 de 22/02/2024, Pedro Gavronski. escreveu: Hello, My name is Pedro and it is nice to meet you all. I am having trouble understanding a message that I receive when use function ar.ols from package stats, it says that "Warning message: In ar.ols(x = dtb[2:6966, ], demean = FALSE, intercept = TRUE, prewhite = TRUE) : model order: 2 singularities in the computation of the projection matrix results are only valid up to model order 1, which I do not know what it means, if someone could clarify it, I would really appreciate it. Attached to this email you will find my code and data I used to run this formula. Thanks in advance. Best regards, Pedro. ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hello, Thanks for the data but the code is missing from the attachment. Can you please post your code? In an attachment or directly in the e-mail body. Rui Barradas -- Este e-mail foi analisado pelo software antivírus AVG para verificar a presença de vírus. www.avg.com ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help
I agree that the posting guide is due for updating. If the mailing list maintainers were willing I think r-consult might not be a terrible idea. I do think the center of gravity has moved to Cross Validated, and it might be minimally sufficient to point people there (or Math Overflow for probability/math questions) rather than starting a new group. On 2024-02-21 12:53 p.m., Joakim Linde wrote: Lisa, this seems to be fairly straight forward to do in R and I'm happy to help you get started. However, please be aware that you do have to have knowledge of statistics to do the analysis/modeling. Rolf, Jeff, I do appreciate your view that this is not a R probelm. It's more a 'how to use R' / 'help me get started' problem. The posting guidelines point to "Usenet groups sci.stat.consult (applied statistics and consulting) and sci.stat.math (mathematical stat and probability)." Since Google announced [1] that Google groups will not support new usenet content starting tomorrow, would it make sense to have a r-consult mailing list or tag it [consult] on r-help? Regards, Joakim [1]: https://support.google.com/groups/answer/11036538 On Wed, Feb 21, 2024, at 1:28 AM, Jeff Newmiller via R-help wrote: Regarding 1 and 2, please read the Posting Guide mentioned at the bottom of every R-help post. R does not equal statistics... and education about statistics is way too ambitious to include in this mailing list that is about a tool that happens to be useful for statisticians. There are forums online that do cater to statistical methods (e.g. Cross Validated or many results from a search engine)... but such conversations can be extensive so as Rolf suggests this is a good time to learn what resources your educational institutions can provide... online forums may be too limiting when your questions are so vague. On February 20, 2024 2:14:58 PM PST, Rolf Turner wrote: On Mon, 19 Feb 2024 17:39:23 +0100 Lisa Hupfer via R-help wrote: I am writing my master thesis in which I compared two cultures . So for my statistics I need to compare Age,Sex,Culture as well as have a look at the tasks scores . Anyone familiar with this ? I’d love to share my script so you guide me where I did wrong . (1) This post is far too vague to be appropriate for this list. (2) You should learn some statistics; probably linear modelling. (3) You should talk to your thesis advisor. (4) Please see fortunes::fortune(285). cheers, Rolf Turner -- Sent from my phone. Please excuse my brevity. ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help
Lisa, this seems to be fairly straight forward to do in R and I'm happy to help you get started. However, please be aware that you do have to have knowledge of statistics to do the analysis/modeling. Rolf, Jeff, I do appreciate your view that this is not a R probelm. It's more a 'how to use R' / 'help me get started' problem. The posting guidelines point to "Usenet groups sci.stat.consult (applied statistics and consulting) and sci.stat.math (mathematical stat and probability)." Since Google announced [1] that Google groups will not support new usenet content starting tomorrow, would it make sense to have a r-consult mailing list or tag it [consult] on r-help? Regards, Joakim [1]: https://support.google.com/groups/answer/11036538 On Wed, Feb 21, 2024, at 1:28 AM, Jeff Newmiller via R-help wrote: > Regarding 1 and 2, please read the Posting Guide mentioned at the > bottom of every R-help post. R does not equal statistics... and > education about statistics is way too ambitious to include in this > mailing list that is about a tool that happens to be useful for > statisticians. > > There are forums online that do cater to statistical methods (e.g. > Cross Validated or many results from a search engine)... but such > conversations can be extensive so as Rolf suggests this is a good time > to learn what resources your educational institutions can provide... > online forums may be too limiting when your questions are so vague. > > On February 20, 2024 2:14:58 PM PST, Rolf Turner > wrote: >> >>On Mon, 19 Feb 2024 17:39:23 +0100 >>Lisa Hupfer via R-help wrote: >> >>> I am writing my master thesis in which I compared two cultures . So >>> for my statistics I need to compare Age,Sex,Culture as well as have a >>> look at the tasks scores . >>> >>> Anyone familiar with this ? >>> I’d love to share my script so you guide me where I did wrong . >> >>(1) This post is far too vague to be appropriate for this list. >> >>(2) You should learn some statistics; probably linear modelling. >> >>(3) You should talk to your thesis advisor. >> >>(4) Please see fortunes::fortune(285). >> >>cheers, >> >>Rolf Turner >> >> > > -- > Sent from my phone. Please excuse my brevity. > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help
Regarding 1 and 2, please read the Posting Guide mentioned at the bottom of every R-help post. R does not equal statistics... and education about statistics is way too ambitious to include in this mailing list that is about a tool that happens to be useful for statisticians. There are forums online that do cater to statistical methods (e.g. Cross Validated or many results from a search engine)... but such conversations can be extensive so as Rolf suggests this is a good time to learn what resources your educational institutions can provide... online forums may be too limiting when your questions are so vague. On February 20, 2024 2:14:58 PM PST, Rolf Turner wrote: > >On Mon, 19 Feb 2024 17:39:23 +0100 >Lisa Hupfer via R-help wrote: > >> I am writing my master thesis in which I compared two cultures . So >> for my statistics I need to compare Age,Sex,Culture as well as have a >> look at the tasks scores . >> >> Anyone familiar with this ? >> I’d love to share my script so you guide me where I did wrong . > >(1) This post is far too vague to be appropriate for this list. > >(2) You should learn some statistics; probably linear modelling. > >(3) You should talk to your thesis advisor. > >(4) Please see fortunes::fortune(285). > >cheers, > >Rolf Turner > > -- Sent from my phone. Please excuse my brevity. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help
On Mon, 19 Feb 2024 17:39:23 +0100 Lisa Hupfer via R-help wrote: > I am writing my master thesis in which I compared two cultures . So > for my statistics I need to compare Age,Sex,Culture as well as have a > look at the tasks scores . > > Anyone familiar with this ? > I’d love to share my script so you guide me where I did wrong . (1) This post is far too vague to be appropriate for this list. (2) You should learn some statistics; probably linear modelling. (3) You should talk to your thesis advisor. (4) Please see fortunes::fortune(285). cheers, Rolf Turner -- Honorary Research Fellow Department of Statistics University of Auckland Stats. Dep't. (secretaries) phone: +64-9-373-7599 ext. 89622 Home phone: +64-9-480-4619 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help
I am writing my master thesis in which I compared two cultures . So for my statistics I need to compare Age,Sex,Culture as well as have a look at the tasks scores . Anyone familiar with this ? I’d love to share my script so you guide me where I did wrong . Regards __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help
Hi Kimmo, The code you sent has worked for me. Thank you very much. *Jibrin Adejoh Alhassan (Ph.D)* Department of Physics and Astronomy, University of Nigeria, Nsukka On Mon, Feb 5, 2024 at 7:40 AM Kimmo Elo wrote: > Hi, > > the command line with 'text' should be: > > text(-8,-8, expression(R^2 * " = 0.62, r = 0.79, N = 161"), cex = 2 ) > > Best, > > Kimmo > > su, 2024-02-04 kello 17:16 +0100, Jibrin Alhassan kirjoitti: > > Here is the script I used to plot the graph indicating the text I > > wanted to > > insert. The line in the script that I have issues with is: text(-8,- > > 8, > > "R^2= 0.62", r = 0.79, N = 161", cex = 2 > > R^2= 0.62 is not producing R squared = 0.62. > > Thanks. > > Sys.setenv( TZ="GMT" ) > > dt <- read.table("CLMXAPTY_sim", col.names = c("FDcli", "FDapt")) > > FDcli=dt$FDcli > > FDapt=dt$FDapt > > setEPS() > > postscript(file = "cliapt2.eps") > > par(mar = c(4.3, 4.3, 1.3, 1.3), oma = c(1, 1, 1 , 1)) > > plot(FDapt,FDcli, pch = 16, cex.lab = 1.6, cex.axis = 1.4, cex.main > > = 0.8, > > font.lab = 1.7, font.axis = 1.7, col = "red",main = "Simultaneous > > Events > > at CLMX and APTY",ylab="CLMX",xlab="APTY") > > text(-8,-8, "R^2= 0.62", r = 0.79, N = 161", cex = 2 ) > > abline(lm(FDcli ~ FDapt, col="black")) > > dev.off() > > *Jibrin Adejoh Alhassan (Ph.D)* > > Department of Physics and Astronomy, > > University of Nigeria, Nsukka > > > > > > On Sun, Feb 4, 2024 at 5:03 PM Jibrin Alhassan > > > > wrote: > > > > > Hi Elo, > > > It gave this error message: > > > CR_plot2.R:14:37: unexpected string constant > > > 13: plot(FDapt,FDcli, pch = 16, cex.lab = 1.6, cex.axis = 1.4, > > > cex.main = > > > 0.8, font.lab = 1.7, font.axis = 1.7, col = "red",main = > > > "Simultaneous > > > Events at CLMX and APTY",ylab="CLMX",xlab="APTY") > > > 14: text(-8,-8, "expression(R^2*"= 0.62"), r = 0.79, N = 161" > > > ^ > > > *Jibrin Adejoh Alhassan (Ph.D)* > > > Department of Physics and Astronomy, > > > University of Nigeria, Nsukka > > > > > > > > > On Sun, Feb 4, 2024 at 4:45 PM Jibrin Alhassan > > > > > > wrote: > > > > > > > Thank you Zhao for the code. When I replotted the graph after > > > > inserting > > > > the code in my script, it gave me this error message without > > > > plotting the > > > > graph: > > > > Warning message: > > > > In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) > > > > : > > > > extra argument ‘col’ will be disregarded. > > > > My regards. > > > > *Jibrin Adejoh Alhassan (Ph.D)* > > > > Department of Physics and Astronomy, > > > > University of Nigeria, Nsukka > > > > > > > > > > > > On Sun, Feb 4, 2024 at 3:21 PM Jinsong Zhao > > > > wrote: > > > > > > > > > ?plotmath > > > > > > > > > > expression(R^2==0.62) > > > > > > > > > > On 2024/2/4 18:10, Jibrin Alhassan wrote: > > > > > > I have done a scatter plot in R. I want to insert the > > > > > > coefficient of > > > > > > determination R^2 = 0.62 as a text in the plot. I have tried > > > > > > to write > > > > > R^2 > > > > > > but could not produce R2. I would appreciate it if someone > > > > > > could help > > > > > me > > > > > > with the syntax. I have tried: expression(paste("", R^2,"=", > > > > > > 0.62)), > > > > > but > > > > > > it did not produce R squared, rather it gave me error > > > > > > messages. Thanks. > > > > > > Jibrin Alhassan > > > > > > *Jibrin Adejoh Alhassan (Ph.D)* > > > > > > Department of Physics and Astronomy, > > > > > > University of Nigeria, Nsukka > > > > > > > > > > > > [[alternative HTML version deleted]] > > > > > > > > > > > > __ > > > > > > R-help@r-project.org mailing lis
Re: [R] Help
Hi, the command line with 'text' should be: text(-8,-8, expression(R^2 * " = 0.62, r = 0.79, N = 161"), cex = 2 ) Best, Kimmo su, 2024-02-04 kello 17:16 +0100, Jibrin Alhassan kirjoitti: > Here is the script I used to plot the graph indicating the text I > wanted to > insert. The line in the script that I have issues with is: text(-8,- > 8, > "R^2= 0.62", r = 0.79, N = 161", cex = 2 > R^2= 0.62 is not producing R squared = 0.62. > Thanks. > Sys.setenv( TZ="GMT" ) > dt <- read.table("CLMXAPTY_sim", col.names = c("FDcli", "FDapt")) > FDcli=dt$FDcli > FDapt=dt$FDapt > setEPS() > postscript(file = "cliapt2.eps") > par(mar = c(4.3, 4.3, 1.3, 1.3), oma = c(1, 1, 1 , 1)) > plot(FDapt,FDcli, pch = 16, cex.lab = 1.6, cex.axis = 1.4, cex.main > = 0.8, > font.lab = 1.7, font.axis = 1.7, col = "red",main = "Simultaneous > Events > at CLMX and APTY",ylab="CLMX",xlab="APTY") > text(-8,-8, "R^2= 0.62", r = 0.79, N = 161", cex = 2 ) > abline(lm(FDcli ~ FDapt, col="black")) > dev.off() > *Jibrin Adejoh Alhassan (Ph.D)* > Department of Physics and Astronomy, > University of Nigeria, Nsukka > > > On Sun, Feb 4, 2024 at 5:03 PM Jibrin Alhassan > > wrote: > > > Hi Elo, > > It gave this error message: > > CR_plot2.R:14:37: unexpected string constant > > 13: plot(FDapt,FDcli, pch = 16, cex.lab = 1.6, cex.axis = 1.4, > > cex.main = > > 0.8, font.lab = 1.7, font.axis = 1.7, col = "red",main = > > "Simultaneous > > Events at CLMX and APTY",ylab="CLMX",xlab="APTY") > > 14: text(-8,-8, "expression(R^2*"= 0.62"), r = 0.79, N = 161" > > ^ > > *Jibrin Adejoh Alhassan (Ph.D)* > > Department of Physics and Astronomy, > > University of Nigeria, Nsukka > > > > > > On Sun, Feb 4, 2024 at 4:45 PM Jibrin Alhassan > > > > wrote: > > > > > Thank you Zhao for the code. When I replotted the graph after > > > inserting > > > the code in my script, it gave me this error message without > > > plotting the > > > graph: > > > Warning message: > > > In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) > > > : > > > extra argument ‘col’ will be disregarded. > > > My regards. > > > *Jibrin Adejoh Alhassan (Ph.D)* > > > Department of Physics and Astronomy, > > > University of Nigeria, Nsukka > > > > > > > > > On Sun, Feb 4, 2024 at 3:21 PM Jinsong Zhao > > > wrote: > > > > > > > ?plotmath > > > > > > > > expression(R^2==0.62) > > > > > > > > On 2024/2/4 18:10, Jibrin Alhassan wrote: > > > > > I have done a scatter plot in R. I want to insert the > > > > > coefficient of > > > > > determination R^2 = 0.62 as a text in the plot. I have tried > > > > > to write > > > > R^2 > > > > > but could not produce R2. I would appreciate it if someone > > > > > could help > > > > me > > > > > with the syntax. I have tried: expression(paste("", R^2,"=", > > > > > 0.62)), > > > > but > > > > > it did not produce R squared, rather it gave me error > > > > > messages. Thanks. > > > > > Jibrin Alhassan > > > > > *Jibrin Adejoh Alhassan (Ph.D)* > > > > > Department of Physics and Astronomy, > > > > > University of Nigeria, Nsukka > > > > > > > > > > [[alternative HTML version deleted]] > > > > > > > > > > ______ > > > > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, > > > > > see > > > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > > > PLEASE do read the posting guide > > > > http://www.R-project.org/posting-guide.html > > > > > and provide commented, minimal, self-contained, reproducible > > > > > code. > > > > > > > > __ > > > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, > > > > see > > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > > PLEASE do read the posting guide > > > > http://www.R-project.org/posting-guide.html > > > > and provide commented, minimal, self-contained, reproducible > > > > code. > > > > > > > > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help
Many thanks. On Mon, Feb 5, 2024, 1:06 AM Rolf Turner wrote: > > Please see fortunes::fortune(285). > > cheers, > > Rolf Turner > > -- > Honorary Research Fellow > Department of Statistics > University of Auckland > Stats. Dep't. (secretaries) phone: > +64-9-373-7599 ext. 89622 > Home phone: +64-9-480-4619 > [[alternative HTML version deleted]] ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help
Please see fortunes::fortune(285). cheers, Rolf Turner -- Honorary Research Fellow Department of Statistics University of Auckland Stats. Dep't. (secretaries) phone: +64-9-373-7599 ext. 89622 Home phone: +64-9-480-4619 ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help
On Sun, 4 Feb 2024 at 17:26, Jibrin Alhassan wrote: > > Here is the script I used to plot the graph indicating the text I wanted to > insert. The line in the script that I have issues with is: text(-8,-8, > "R^2= 0.62", r = 0.79, N = 161", cex = 2 > R^2= 0.62 is not producing R squared = 0.62. > Thanks. This works for me: curve(dnorm, from=-3, to=3, main="Normal Distribution") text(x=0, y=0.1, cex=1.5, expression(R^2 == 0.62)) if you are used to write expression using LaTeX math , then maybe you like the latex2exp package: curve(dnorm, from=-3, to=3, main="Normal Distribution") text(0, 0.1, latex2exp::TeX("$R^2 = 0.62$")) Regards Martin __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help
Here is the script I used to plot the graph indicating the text I wanted to insert. The line in the script that I have issues with is: text(-8,-8, "R^2= 0.62", r = 0.79, N = 161", cex = 2 R^2= 0.62 is not producing R squared = 0.62. Thanks. Sys.setenv( TZ="GMT" ) dt <- read.table("CLMXAPTY_sim", col.names = c("FDcli", "FDapt")) FDcli=dt$FDcli FDapt=dt$FDapt setEPS() postscript(file = "cliapt2.eps") par(mar = c(4.3, 4.3, 1.3, 1.3), oma = c(1, 1, 1 , 1)) plot(FDapt,FDcli, pch = 16, cex.lab = 1.6, cex.axis = 1.4, cex.main = 0.8, font.lab = 1.7, font.axis = 1.7, col = "red",main = "Simultaneous Events at CLMX and APTY",ylab="CLMX",xlab="APTY") text(-8,-8, "R^2= 0.62", r = 0.79, N = 161", cex = 2 ) abline(lm(FDcli ~ FDapt, col="black")) dev.off() *Jibrin Adejoh Alhassan (Ph.D)* Department of Physics and Astronomy, University of Nigeria, Nsukka On Sun, Feb 4, 2024 at 5:03 PM Jibrin Alhassan wrote: > Hi Elo, > It gave this error message: > CR_plot2.R:14:37: unexpected string constant > 13: plot(FDapt,FDcli, pch = 16, cex.lab = 1.6, cex.axis = 1.4, cex.main = > 0.8, font.lab = 1.7, font.axis = 1.7, col = "red",main = "Simultaneous > Events at CLMX and APTY",ylab="CLMX",xlab="APTY") > 14: text(-8,-8, "expression(R^2*"= 0.62"), r = 0.79, N = 161" > ^ > *Jibrin Adejoh Alhassan (Ph.D)* > Department of Physics and Astronomy, > University of Nigeria, Nsukka > > > On Sun, Feb 4, 2024 at 4:45 PM Jibrin Alhassan > wrote: > >> Thank you Zhao for the code. When I replotted the graph after inserting >> the code in my script, it gave me this error message without plotting the >> graph: >> Warning message: >> In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : >> extra argument ‘col’ will be disregarded. >> My regards. >> *Jibrin Adejoh Alhassan (Ph.D)* >> Department of Physics and Astronomy, >> University of Nigeria, Nsukka >> >> >> On Sun, Feb 4, 2024 at 3:21 PM Jinsong Zhao wrote: >> >>> ?plotmath >>> >>> expression(R^2==0.62) >>> >>> On 2024/2/4 18:10, Jibrin Alhassan wrote: >>> > I have done a scatter plot in R. I want to insert the coefficient of >>> > determination R^2 = 0.62 as a text in the plot. I have tried to write >>> R^2 >>> > but could not produce R2. I would appreciate it if someone could help >>> me >>> > with the syntax. I have tried: expression(paste("", R^2,"=", 0.62)), >>> but >>> > it did not produce R squared, rather it gave me error messages. Thanks. >>> > Jibrin Alhassan >>> > *Jibrin Adejoh Alhassan (Ph.D)* >>> > Department of Physics and Astronomy, >>> > University of Nigeria, Nsukka >>> > >>> > [[alternative HTML version deleted]] >>> > >>> > __ >>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >>> > https://stat.ethz.ch/mailman/listinfo/r-help >>> > PLEASE do read the posting guide >>> http://www.R-project.org/posting-guide.html >>> > and provide commented, minimal, self-contained, reproducible code. >>> >>> __ >>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >>> https://stat.ethz.ch/mailman/listinfo/r-help >>> PLEASE do read the posting guide >>> http://www.R-project.org/posting-guide.html >>> and provide commented, minimal, self-contained, reproducible code. >>> >> [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help
Hi Elo, It gave this error message: CR_plot2.R:14:37: unexpected string constant 13: plot(FDapt,FDcli, pch = 16, cex.lab = 1.6, cex.axis = 1.4, cex.main = 0.8, font.lab = 1.7, font.axis = 1.7, col = "red",main = "Simultaneous Events at CLMX and APTY",ylab="CLMX",xlab="APTY") 14: text(-8,-8, "expression(R^2*"= 0.62"), r = 0.79, N = 161" ^ *Jibrin Adejoh Alhassan (Ph.D)* Department of Physics and Astronomy, University of Nigeria, Nsukka On Sun, Feb 4, 2024 at 4:45 PM Jibrin Alhassan wrote: > Thank you Zhao for the code. When I replotted the graph after inserting > the code in my script, it gave me this error message without plotting the > graph: > Warning message: > In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : > extra argument ‘col’ will be disregarded. > My regards. > *Jibrin Adejoh Alhassan (Ph.D)* > Department of Physics and Astronomy, > University of Nigeria, Nsukka > > > On Sun, Feb 4, 2024 at 3:21 PM Jinsong Zhao wrote: > >> ?plotmath >> >> expression(R^2==0.62) >> >> On 2024/2/4 18:10, Jibrin Alhassan wrote: >> > I have done a scatter plot in R. I want to insert the coefficient of >> > determination R^2 = 0.62 as a text in the plot. I have tried to write >> R^2 >> > but could not produce R2. I would appreciate it if someone could help me >> > with the syntax. I have tried: expression(paste("", R^2,"=", 0.62)), >> but >> > it did not produce R squared, rather it gave me error messages. Thanks. >> > Jibrin Alhassan >> > *Jibrin Adejoh Alhassan (Ph.D)* >> > Department of Physics and Astronomy, >> > University of Nigeria, Nsukka >> > >> > [[alternative HTML version deleted]] >> > >> > __ >> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> > https://stat.ethz.ch/mailman/listinfo/r-help >> > PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> > and provide commented, minimal, self-contained, reproducible code. >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help
Hi, maybe this works: expression(R^2 * "= 0.62") HTH, Kimmo 4. helmik. 2024, 16.11, Jibrin Alhassan mailto:jibrin.alhas...@unn.edu.ng>> kirjoitti: I have done a scatter plot in R. I want to insert the coefficient of determination R^2 = 0.62 as a text in the plot. I have tried to write R^2 but could not produce R2. I would appreciate it if someone could help me with the syntax. I have tried: expression(paste("", R^2,"=", 0.62)), but it did not produce R squared, rather it gave me error messages. Thanks. Jibrin Alhassan *Jibrin Adejoh Alhassan (Ph.D)* Department of Physics and Astronomy, University of Nigeria, Nsukka [[alternative HTML version deleted]] R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help
Thank you Zhao for the code. When I replotted the graph after inserting the code in my script, it gave me this error message without plotting the graph: Warning message: In lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : extra argument ‘col’ will be disregarded. My regards. *Jibrin Adejoh Alhassan (Ph.D)* Department of Physics and Astronomy, University of Nigeria, Nsukka On Sun, Feb 4, 2024 at 3:21 PM Jinsong Zhao wrote: > ?plotmath > > expression(R^2==0.62) > > On 2024/2/4 18:10, Jibrin Alhassan wrote: > > I have done a scatter plot in R. I want to insert the coefficient of > > determination R^2 = 0.62 as a text in the plot. I have tried to write R^2 > > but could not produce R2. I would appreciate it if someone could help me > > with the syntax. I have tried: expression(paste("", R^2,"=", 0.62)), but > > it did not produce R squared, rather it gave me error messages. Thanks. > > Jibrin Alhassan > > *Jibrin Adejoh Alhassan (Ph.D)* > > Department of Physics and Astronomy, > > University of Nigeria, Nsukka > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > ______ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help
?plotmath expression(R^2==0.62) On 2024/2/4 18:10, Jibrin Alhassan wrote: I have done a scatter plot in R. I want to insert the coefficient of determination R^2 = 0.62 as a text in the plot. I have tried to write R^2 but could not produce R2. I would appreciate it if someone could help me with the syntax. I have tried: expression(paste("", R^2,"=", 0.62)), but it did not produce R squared, rather it gave me error messages. Thanks. Jibrin Alhassan *Jibrin Adejoh Alhassan (Ph.D)* Department of Physics and Astronomy, University of Nigeria, Nsukka [[alternative HTML version deleted]] ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help
I have done a scatter plot in R. I want to insert the coefficient of determination R^2 = 0.62 as a text in the plot. I have tried to write R^2 but could not produce R2. I would appreciate it if someone could help me with the syntax. I have tried: expression(paste("", R^2,"=", 0.62)), but it did not produce R squared, rather it gave me error messages. Thanks. Jibrin Alhassan *Jibrin Adejoh Alhassan (Ph.D)* Department of Physics and Astronomy, University of Nigeria, Nsukka [[alternative HTML version deleted]] ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet
Hi Tim This is brilliant - thank you!! I've had to tweak the basePath line a bit (I am on a Linux machine), but having done that, the code works as intended. This is a truly helpful contribution that gives me ideas about how to work it through for the missing fields, which is one of the major sticking points I kept bumping up against. Thank you so much for this. All the best Andy On 05/01/2024 13:59, Howard, Tim G (DEC) wrote: Here's a simplified version of how I would do it, using `textreadr` but otherwise base functions. I haven't done it all, but have a few examples of finding the correct row then extracting the right data. I made a duplicate of the file you provided, so this loops through the two identical files, extracts a few parts, then sticks those parts in a data frame. # library(textreadr) # recommend not using setwd(), but instead just include the # path as follows basePath <- file.path("C:","temp") files <- list.files(path=basePath, pattern = "docx$") length(files) # 2 # initialize a list to put the data in myList <- vector(mode = "list", length = length(files)) for(i in 1:length(files)){ fileDat <- read_docx(file.path(basePath, files[[i]])) # get the data you want, here one line per item to make it clearer # assume consistency among articles ttl <- fileDat[[1]] src <- fileDat[[2]] dt <- fileDat[[3]] aut <- fileDat[grepl("Byline:",fileDat)] aut <- trimws(sub("Byline:","",aut), whitespace = "[\\h\\v]") pg <- fileDat[grepl("Pg.",fileDat)] pg <- as.integer(sub(".*Pg. ([[:digit:]]+)","\\1",pg)) len <- fileDat[grepl("Length:", fileDat)] len <- as.integer(sub("Length:.{1}([[:digit:]]+) .*","\\1",len)) myList[[i]] <- data.frame("title"=ttl, "source"=src, "date"=dt, "author"=aut, "page"=pg, "length"=len) } # roll up the list to a data frame. Many ways to do this. myDF <- do.call("rbind",myList) # Hope that helps. Tim -- Date: Thu, 4 Jan 2024 12:59:59 + From: Andy To: r-help@r-project.org Subject: Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet Message-ID: Content-Type: text/plain; charset="utf-8"; Format="flowed" Hi folks Thanks for your help and suggestions - very much appreciated. I now have some working code, using this file I uploaded for public access: https://docs/. google.com%2Fdocument%2Fd%2F1QwuaWZk6tYlWQXJ3WLczxC8Cda6zVER k%2Fedit%3Fusp%3Dsharing%26ouid%3D103065135255080058813%26rtpof% 3Dtrue%26sd%3Dtrue&data=05%7C02%7Ctim.howard%40dec.ny.gov%7C8f2 952a3ae474d4da14908dc0ddd95fd%7Cf46cb8ea79004d108ceb80e8c1c81ee7 %7C0%7C0%7C638400492578674983%7CUnknown%7CTWFpbGZsb3d8eyJWIj oiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3 000%7C%7C%7C&sdata=%2BpYrk6cJA%2BDUn9szLbd2Y7R%2F30UNY2TFSJN HcwkHa9Y%3D&reserved=0 The small code segment that now works is as follows: ### # Load libraries library(textreadr) library(tcltk) library(tidyverse) #library(officer) #library(stringr) #for splitting and trimming raw data #library(tidyr) #for converting to wide format # I'd like to keep this as it enables more control over the selected directories filepath <- setwd(tk_choose.dir()) # The following correctly lists the names of all 9 files in my test directory files <- list.files(filepath, ".docx") files length(files) # Ideally, I'd like to skip this step by being able to automatically read in the name of each file, but one step at a time: filename <- "Now they want us to charge our electric cars from litter bins.docx" # This produces the file content as output when run, and identifies the fields that I want to extract. read_docx(filename) %>% str_split(",") %>% unlist() %>% str_trim() ### What I'd like to try and accomplish next is to extract the data from selected fields and append to a spreadsheet (Calc or Excel) under specific columns, or if it is easier to write a CSV which I can then use later. The fields I want to extract are illustrated with reference to the above file, viz.: The title: "Now they want us to charge our electric cars from litter bins" The name of the newspaper: "Mail on Sunday (London)" The publication date: "September 24, 2023" (in date format, preferably separated into month and year (day is not important)) The section: "NEWS" The page number(s): "16" (as numeric) The length: "515" (as numeric) The author: "Anna Mikhailova" The subject: from the Subject
Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet
Hi folks Thanks for your help and suggestions - very much appreciated. I now have some working code, using this file I uploaded for public access: https://docs.google.com/document/d/1QwuaWZk6tYlWQXJ3WLczxC8Cda6zVERk/edit?usp=sharing&ouid=103065135255080058813&rtpof=true&sd=true The small code segment that now works is as follows: ### # Load libraries library(textreadr) library(tcltk) library(tidyverse) #library(officer) #library(stringr) #for splitting and trimming raw data #library(tidyr) #for converting to wide format # I'd like to keep this as it enables more control over the selected directories filepath <- setwd(tk_choose.dir()) # The following correctly lists the names of all 9 files in my test directory files <- list.files(filepath, ".docx") files length(files) # Ideally, I'd like to skip this step by being able to automatically read in the name of each file, but one step at a time: filename <- "Now they want us to charge our electric cars from litter bins.docx" # This produces the file content as output when run, and identifies the fields that I want to extract. read_docx(filename) %>% str_split(",") %>% unlist() %>% str_trim() ### What I'd like to try and accomplish next is to extract the data from selected fields and append to a spreadsheet (Calc or Excel) under specific columns, or if it is easier to write a CSV which I can then use later. The fields I want to extract are illustrated with reference to the above file, viz.: The title: "Now they want us to charge our electric cars from litter bins" The name of the newspaper: "Mail on Sunday (London)" The publication date: "September 24, 2023" (in date format, preferably separated into month and year (day is not important)) The section: "NEWS" The page number(s): "16" (as numeric) The length: "515" (as numeric) The author: "Anna Mikhailova" The subject: from the Subject section, but this is to match a value e.g. GREENWASHING >= 50% (here this value is 51% so would be included). A match moves onto select the highest value under the section "Industry" (here it is ELECTRIC MOBILITY (91%)) and appends this text and % value. If no match with 'Greenwashing', then appends 'Null' and moves onto the next file in the directory. ### The theory I am working with is if I can figure out how to extract these fields and append correctly, then the rest should just be wrapping this up in a for loop. However, I am struggling to get my head around the extraction and append part. If I can get it to work for one of these fields, I suspect that I can repeat the basic syntax to extract and append the remaining fields. Therefore, if someone can either suggest a syntax or point me to a useful tutorial, that would be splendid. Thank you in anticipation. Best wishes Andy __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet
If you do something like this for i in $(pandoc --list-output-formats); do pandoc -f docx -t $i -o test.$i Now\ they\ want\ us\ to\ charge\ our\ electric\ cars\ from\ litter\ bins.docx; done you get approximately 65 formats, from which you can pick one which you can write a little parser for. The dokuwiki one for example uses long lines which makes parsing easier. el On 2023-12-30 13:57 , Andy wrote: > Good idea, El - thanks. > > The link is > https://docs.google.com/document/d/1QwuaWZk6tYlWQXJ3WLczxC8Cda6zVERk/edit?usp=sharing&ouid=103065135255080058813&rtpof=true&sd=true > > This is helpful. > > From the article, which is typical of Lexis+ output, I want to > extract the following fields and append to a Calc/ Excel spreadsheet. > Given the volume of articles I have to work through, if this can be > iterative and semi-automatic, that would be a god send and I might be > able to do some actual research on the articles before I reach my > pensionable age. :-) > > Title Newspaper Date Section and page number Length Byline Subject > (only if the threshold of coverage for a specific subject is >> =50% is reached (e.g. Greenwashing (51%)) - if not, enter 'nil' and >> > move onto the next article in the folder > > This is the ambition. I am clearly a long way short of that though. > > Many thanks. Andy __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet
В Sat, 30 Dec 2023 12:18:52 + Andy пишет: > filepath <- setwd(tk_choose.dir()) Since you're using tcltk, you can get a file path in one step using tk_choose.files(). (Use multi = FALSE to choose only one file.) > full_filename <- paste(filepath, filename, sep="/") There's also file.path(), which results in slightly more compact, self-documenting code. Nowadays, using '/' as the directory separator can be considered portable, one notable exception being some Windows cmd.exe built-ins (where '/' is interpreted as flag specifier). Perl5 documentation mentions Classic MacOS using ':' as the directory separator (and many other operating systems supporting or emulating Unix-style '/' separators), but that hasn't been relevant for a long while. > Error in x$doc_obj : $ operator is invalid for atomic vectors Which line of code produces the error? What is the argument of docx_summary() at this point? Since you're learning R, I can recommend a couple of free books: Visual Statistics [1] to study the basics of R and The R Inferno [2] for when you get stuck. -- Best regards, Ivan [1] http://web.archive.org/web/20230415001551/http://ashipunov.info/shipunov/school/biol_240/en/visual_statistics.pdf [2] https://www.burns-stat.com/documents/books/the-r-inferno/ __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet
Sorry, I was being too quick. You have to pay attention to the pipe operator You were advised to do the following content <- read_docx(full_filename) |> docx_summary() which should have worked but I think you left out the |> operator. Alternatively tmp <- read_docx(full_filename) content <- docx_summary(tmp) On Sat, Dec 30, 2023 at 2:37 PM Andy wrote: > An update: Running this block of code: > > # Load libraries > library(tcltk) > library(tidyverse) > library(officer) > > filepath <- setwd(tk_choose.dir()) > > filename <- "Now they want us to charge our electric cars from litter > bins.docx" > > #full_filename <- paste0(filepath, filename) > full_filename <- paste(filepath, filename, sep="/") > > if (!file.exists(full_filename)) { >message("File missing") > } else { >content <- read_docx(full_filename) |> > docx_summary() ># this reads docx for the full filename and ># passes it ( |> command) to the next line ># which summarises it. ># the result is saved in a data frame object ># called content which we shall show some ># heading into from > >head(content) > } > > > Results in this error now:Error in x$doc_obj : $ operator is invalid for > atomic vectors > > Thank you. > > > > On 30/12/2023 12:12, Andy wrote: > > Hi Eric > > > > Thanks for that. That seems to fix one problem (the lack of a > > separator), but introduces a new one when I complete the function > > Calum proposed:Error in docx_summary() : argument "x" is missing, with > > no default > > > > The whole code so far looks like this: > > > > > > # Load libraries > > library(tcltk) > > library(tidyverse) > > library(officer) > > > > filepath <- setwd(tk_choose.dir()) > > > > filename <- "Now they want us to charge our electric cars from litter > > bins.docx" > > #full_filename <- paste0(filepath, filename) # Calum's original > suggestion > > > > full_filename <- paste(filepath, filename, sep="/") # Eric's proposed fix > > > > #lets double check the file does exist! # The rest here is Calum's > > suggestion > > if (!file.exists(full_filename)) { > > message("File missing") > > } else { > > content <- read_docx(full_filename) > > docx_summary() > > # this reads docx for the full filename and > > # passes it ( |> command) to the next line > > # which summarises it. > > # the result is saved in a data frame object > > # called content which we shall show some > > # heading into from > > > > head(content) > > } > > > > > > Running this, results in the error cited above. > > > > Thanks as always :-) > > > > > > > > > > On 30/12/2023 11:58, Eric Berger wrote: > >> full_filename <- paste(filepath, filename,sep="/") > > > > > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet
An update: Running this block of code: # Load libraries library(tcltk) library(tidyverse) library(officer) filepath <- setwd(tk_choose.dir()) filename <- "Now they want us to charge our electric cars from litter bins.docx" #full_filename <- paste0(filepath, filename) full_filename <- paste(filepath, filename, sep="/") if (!file.exists(full_filename)) { message("File missing") } else { content <- read_docx(full_filename) |> docx_summary() # this reads docx for the full filename and # passes it ( |> command) to the next line # which summarises it. # the result is saved in a data frame object # called content which we shall show some # heading into from head(content) } Results in this error now:Error in x$doc_obj : $ operator is invalid for atomic vectors Thank you. On 30/12/2023 12:12, Andy wrote: > Hi Eric > > Thanks for that. That seems to fix one problem (the lack of a > separator), but introduces a new one when I complete the function > Calum proposed:Error in docx_summary() : argument "x" is missing, with > no default > > The whole code so far looks like this: > > > # Load libraries > library(tcltk) > library(tidyverse) > library(officer) > > filepath <- setwd(tk_choose.dir()) > > filename <- "Now they want us to charge our electric cars from litter > bins.docx" > #full_filename <- paste0(filepath, filename) # Calum's original suggestion > > full_filename <- paste(filepath, filename, sep="/") # Eric's proposed fix > > #lets double check the file does exist! # The rest here is Calum's > suggestion > if (!file.exists(full_filename)) { > message("File missing") > } else { > content <- read_docx(full_filename) > docx_summary() > # this reads docx for the full filename and > # passes it ( |> command) to the next line > # which summarises it. > # the result is saved in a data frame object > # called content which we shall show some > # heading into from > > head(content) > } > > > Running this, results in the error cited above. > > Thanks as always :-) > > > > > On 30/12/2023 11:58, Eric Berger wrote: >> full_filename <- paste(filepath, filename,sep="/") > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet
docx_summary(content) You should read documentation e.g. ?docx_summary and check the examples section On Sat, Dec 30, 2023 at 2:12 PM Andy wrote: > Hi Eric > > Thanks for that. That seems to fix one problem (the lack of a separator), > but introduces a new one when I complete the function Calum proposed: > Error in docx_summary() : argument "x" is missing, with no default > > The whole code so far looks like this: > > > # Load libraries > library(tcltk) > library(tidyverse) > library(officer) > > filepath <- setwd(tk_choose.dir()) > > filename <- "Now they want us to charge our electric cars from litter > bins.docx" > #full_filename <- paste0(filepath, filename) # Calum's original suggestion > > full_filename <- paste(filepath, filename, sep="/") # Eric's proposed fix > > #lets double check the file does exist! # The rest here is Calum's > suggestion > if (!file.exists(full_filename)) { > message("File missing") > } else { > content <- read_docx(full_filename) > docx_summary() > # this reads docx for the full filename and > # passes it ( |> command) to the next line > # which summarises it. > # the result is saved in a data frame object > # called content which we shall show some > # heading into from > > head(content) > } > > > Running this, results in the error cited above. > > Thanks as always :-) > > > > > On 30/12/2023 11:58, Eric Berger wrote: > > full_filename <- paste(filepath, filename,sep="/") > > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet
Hi Eric Thanks for that. That seems to fix one problem (the lack of a separator), but introduces a new one when I complete the function Calum proposed:Error in docx_summary() : argument "x" is missing, with no default The whole code so far looks like this: # Load libraries library(tcltk) library(tidyverse) library(officer) filepath <- setwd(tk_choose.dir()) filename <- "Now they want us to charge our electric cars from litter bins.docx" #full_filename <- paste0(filepath, filename) # Calum's original suggestion full_filename <- paste(filepath, filename, sep="/") # Eric's proposed fix #lets double check the file does exist! # The rest here is Calum's suggestion if (!file.exists(full_filename)) { message("File missing") } else { content <- read_docx(full_filename) docx_summary() # this reads docx for the full filename and # passes it ( |> command) to the next line # which summarises it. # the result is saved in a data frame object # called content which we shall show some # heading into from head(content) } Running this, results in the error cited above. Thanks as always :-) On 30/12/2023 11:58, Eric Berger wrote: > full_filename <- paste(filepath, filename,sep="/") [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet
full_filename <- paste(filepath, filename,sep="/") On Sat, Dec 30, 2023 at 1:45 PM Andy wrote: > Thanks Ivan and Calum > > I continue to appreciate your support. > > Calum, I entered the code snippet you provided, and it returns 'file > missing'. Looking at this, while the object 'full_filename' exists, what > is happening is that the path from getwd() is being appended to the > title of the article, but without the '/' between the end of the path > name (here 'TEST' and the name of the article. In other words, > full_filename is reading "~/TESTNow they want us to charge our electric > cars from litter bins.docx", so logically, this file doesn't exist. To > work, the '/' needs to be inserted to differentiate between the end of > the path name and the start of the article name. I've tried both paste0, > as you suggested, and paste but neither do the trick. > > Is this a result of me using the tkinter folder selection that you > remarked on? I wanted to keep that so that the selection is interactive, > but if there are better ways of doing this I am open to suggestions. > > Thanks again, both. > > Best wishes > Andrew > > > On 29/12/2023 22:25, CALUM POLWART wrote: > > > > > > help(read_docx) says that the function only imports one docx file. In > > order to read multiple files, use a for loop or the lapply function. > > > > > > I told you people will suggest better ways to loop!! > > > > > > > > docx_summary(read_docx("Now they want us to charge our electric cars > > from litter bins.docx")) should work. > > > > > > Ivan thanks for spotting my fail! Since the OP is new to all this I'm > > going to suggest a little tweak to this code which we can then build > > into a for loop: > > > > filepath <- getwd() #you will want to change this later. You are doing > > something with tcl to pick a directory which seems rather fancy! But > > keep doing it for now or set the directory here ending in a / > > > > filename <- "Now they want us to charge our electric cars from litter > > bins.docx" > > > > full_filename <- paste0(filepath, filename) > > > > #lets double check the file does exist! > > if (!file.exists(full_filename)) { > > message("File missing") > > } else { > > content <- read_docx(full_filename) |> > > docx_summary() > > # this reads docx for the full filename and > > # passes it ( |> command) to the next line > > # which summarises it. > > # the result is saved in a data frame object > > # called content which we shall show some > > # heading into from > > > >head(content) > > } > > > > Let's get this bit working before we try and loop > > > > [[alternative HTML version deleted]] > > ______ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet
Good idea, El - thanks. The link is https://docs.google.com/document/d/1QwuaWZk6tYlWQXJ3WLczxC8Cda6zVERk/edit?usp=sharing&ouid=103065135255080058813&rtpof=true&sd=true This is helpful. From the article, which is typical of Lexis+ output, I want to extract the following fields and append to a Calc/ Excel spreadsheet. Given the volume of articles I have to work through, if this can be iterative and semi-automatic, that would be a god send and I might be able to do some actual research on the articles before I reach my pensionable age. :-) Title Newspaper Date Section and page number Length Byline Subject (only if the threshold of coverage for a specific subject is >=50% is reached (e.g. Greenwashing (51%)) - if not, enter 'nil' and move onto the next article in the folder This is the ambition. I am clearly a long way short of that though. Many thanks. Andy On 30/12/2023 00:08, Dr Eberhard W Lisse wrote: Andy, you can always open a public Dropbox or Google folder and post the link. el On 29/12/2023 22:37, Andy wrote: Thanks - I'll have a look at these options too. I'm happy to send over a sample document, but wasn't aware if attachments are allowed. The documents come Lexis+, so require user credentials to log in, but I could upload the file somewhere if that would help? Any ideas for a good location to do so? [...] ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet
Thanks Ivan and Calum I continue to appreciate your support. Calum, I entered the code snippet you provided, and it returns 'file missing'. Looking at this, while the object 'full_filename' exists, what is happening is that the path from getwd() is being appended to the title of the article, but without the '/' between the end of the path name (here 'TEST' and the name of the article. In other words, full_filename is reading "~/TESTNow they want us to charge our electric cars from litter bins.docx", so logically, this file doesn't exist. To work, the '/' needs to be inserted to differentiate between the end of the path name and the start of the article name. I've tried both paste0, as you suggested, and paste but neither do the trick. Is this a result of me using the tkinter folder selection that you remarked on? I wanted to keep that so that the selection is interactive, but if there are better ways of doing this I am open to suggestions. Thanks again, both. Best wishes Andrew On 29/12/2023 22:25, CALUM POLWART wrote: > > > help(read_docx) says that the function only imports one docx file. In > order to read multiple files, use a for loop or the lapply function. > > > I told you people will suggest better ways to loop!! > > > > docx_summary(read_docx("Now they want us to charge our electric cars > from litter bins.docx")) should work. > > > Ivan thanks for spotting my fail! Since the OP is new to all this I'm > going to suggest a little tweak to this code which we can then build > into a for loop: > > filepath <- getwd() #you will want to change this later. You are doing > something with tcl to pick a directory which seems rather fancy! But > keep doing it for now or set the directory here ending in a / > > filename <- "Now they want us to charge our electric cars from litter > bins.docx" > > full_filename <- paste0(filepath, filename) > > #lets double check the file does exist! > if (!file.exists(full_filename)) { > message("File missing") > } else { > content <- read_docx(full_filename) |> > docx_summary() > # this reads docx for the full filename and > # passes it ( |> command) to the next line > # which summarises it. > # the result is saved in a data frame object > # called content which we shall show some > # heading into from > > head(content) > } > > Let's get this bit working before we try and loop > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet
Andy, you can always open a public Dropbox or Google folder and post the link. el On 29/12/2023 22:37, Andy wrote: > Thanks - I'll have a look at these options too. > > I'm happy to send over a sample document, but wasn't aware if > attachments are allowed. The documents come Lexis+, so require user > credentials to log in, but I could upload the file somewhere if > that would help? Any ideas for a good location to do so? [...] ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet
help(read_docx) says that the function only imports one docx file. In > order to read multiple files, use a for loop or the lapply function. > I told you people will suggest better ways to loop!! > > docx_summary(read_docx("Now they want us to charge our electric cars > from litter bins.docx")) should work. > Ivan thanks for spotting my fail! Since the OP is new to all this I'm going to suggest a little tweak to this code which we can then build into a for loop: filepath <- getwd() #you will want to change this later. You are doing something with tcl to pick a directory which seems rather fancy! But keep doing it for now or set the directory here ending in a / filename <- "Now they want us to charge our electric cars from litter bins.docx" full_filename <- paste0(filepath, filename) #lets double check the file does exist! if (!file.exists(full_filename)) { message("File missing") } else { content <- read_docx(full_filename) |> docx_summary() # this reads docx for the full filename and # passes it ( |> command) to the next line # which summarises it. # the result is saved in a data frame object # called content which we shall show some # heading into from head(content) } Let's get this bit working before we try and loop > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet
В Fri, 29 Dec 2023 20:17:41 + Andy пишет: > doc_in <- read_docx(files) > > Results in this error:Error in filetype %in% c("docx") && > grepl("^([fh]ttp)", file) :'length = 9' in coercion to 'logical(1)' help(read_docx) says that the function only imports one docx file. In order to read multiple files, use a for loop or the lapply function. > content <- officer::docx_summary("Now they want us to charge our > electric cars from litter bins.docx") # A title of one of the articles > > The error returned is:Error in x$doc_obj : $ operator is invalid for > atomic vectors A similar problem here. help(docx_summary) says that the function accepts "rdocx" objects returned by read_docx, not file paths. A string in R is indeed an atomic vector of type character, length 1. docx_summary(read_docx("Now they want us to charge our electric cars from litter bins.docx")) should work. -- Best regards, Ivan __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet
Thanks - I'll have a look at these options too. I'm happy to send over a sample document, but wasn't aware if attachments are allowed. The documents come Lexis+, so require user credentials to log in, but I could upload the file somewhere if that would help? Any ideas for a good location to do so? On 29/12/2023 20:25, Dr Eberhard W Lisse wrote: I would also look at https://pandoc.org perhaps which can export a number of formats... And for spreadsheets https://github.com/jqnatividad/qsv is my goto weapon. Can also read and write XLSX and others. A sample document or two would always be helpful... el On 29/12/2023 21:01, CALUM POLWART wrote: It sounded like he looked at officeR but I would agree content <- officer::docx_summary("filename.docx") Would get the text content into an object called content. That object is a data.frame so you can then manipulate it. To be more specific, we might need an example of the DF [...] On Fri, Dec 29, 2023 at 10:14 AM Andy wrote: [...] I'd like to be able to accomplish the following: (1) Append the title, the month, the author, the number of words, and page number(s) to a spreadsheet (2) Read each article and extract keywords (in the docs, these are listed in 'Subject' section as a list of keywords with a percentage showing the extent to which the keyword features in the article (e.g., FAST FASHION (72%)) and to append the keyword and the % coverage to the same row in the spreadsheet. However, I want to ensure that the keyword coverage meets the threshold of >= 50%; if not, then pass onto the next article in the directory. Rinse and repeat for the entire directory. [...] ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet
I would also look at https://pandoc.org perhaps which can export a number of formats... And for spreadsheets https://github.com/jqnatividad/qsv is my goto weapon. Can also read and write XLSX and others. A sample document or two would always be helpful... el On 29/12/2023 21:01, CALUM POLWART wrote: > It sounded like he looked at officeR but I would agree > > content <- officer::docx_summary("filename.docx") > > Would get the text content into an object called content. > > That object is a data.frame so you can then manipulate it. > To be more specific, we might need an example of the DF [...] >> On Fri, Dec 29, 2023 at 10:14 AM Andy >> wrote: [...] >>> I'd like to be able to accomplish the following: >>> >>> (1) Append the title, the month, the author, the number of >>> words, and page number(s) to a spreadsheet >>> >>> (2) Read each article and extract keywords (in the docs, >>> these are listed in 'Subject' section as a list of >>> keywords with a percentage showing the extent to which the >>> keyword features in the article (e.g., FAST FASHION (72%)) >>> and to append the keyword and the % coverage to the same >>> row in the spreadsheet. However, I want to ensure that >>> the keyword coverage meets the threshold of >= 50%; if >>> not, then pass onto the next article in the directory. >>> Rinse and repeat for the entire directory. [...] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet
, which is now deprecated; others use >> either the officer or the officedown packages. However, these packages don't >> appear to do what I want the program to do, at least not in any of the >> examples I have found, nor in the vignettes and relevant package manuals >> I've looked at. >> >> The first point is, is what I am intending to do even possible using R? If >> it is, then where do I start with this? If these docx files were converted >> to UTF-8 plain text, would that make the task easier? >> >> I am not a confident coder, and am really only just getting my head around R >> so appreciate a steep learning curve ahead, but of course, I don't know what >> I don't know, so any pointers in the right direction would be a big help. >> >> Many thanks in anticipation >> >> Andy >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet
It sounded like he looked at officeR but I would agree content <- officer::docx_summary("filename.docx") Would get the text content into an object called content. That object is a data.frame so you can then manipulate it. To be more specific, we might need an example of the DF You can loop this easily with a for statement although there are people who prefer a non-for approach to iteration in R. For can be slow. But if you don't need to do this very quickly I'd stick with for if you are used to programming On Fri, 29 Dec 2023, 18:35 jim holtman, wrote: > checkout the 'officer' package > > Thanks > > Jim Holtman > *Data Munger Guru* > > > *What is the problem that you are trying to solve?Tell me what you want to > do, not how you want to do it.* > > > On Fri, Dec 29, 2023 at 10:14 AM Andy wrote: > > > Hello > > > > I am trying to work through a problem, but feel like I've gone down a > > rabbit hole. I'd very much appreciate any help. > > > > The task: I have several directories of multiple (some directories, up > > to 2,500+) *.docx files (newspaper articles downloaded from Lexis+) that > > I want to iterate through to append to a spreadsheet only those articles > > that satisfy a condition (i.e., a specific keyword is present for >= 50% > > coverage of the subject matter). Lexis+ has a very specific structure > > and keywords are given in the row "Subject". > > > > I'd like to be able to accomplish the following: > > > > (1) Append the title, the month, the author, the number of words, and > > page number(s) to a spreadsheet > > > > (2) Read each article and extract keywords (in the docs, these are > > listed in 'Subject' section as a list of keywords with a percentage > > showing the extent to which the keyword features in the article (e.g., > > FAST FASHION (72%)) and to append the keyword and the % coverage to the > > same row in the spreadsheet. However, I want to ensure that the keyword > > coverage meets the threshold of >= 50%; if not, then pass onto the next > > article in the directory. Rinse and repeat for the entire directory. > > > > So far, I've tried working through some Stack Overflow-based solutions, > > but most seem to use the textreadr package, which is now deprecated; > > others use either the officer or the officedown packages. However, these > > packages don't appear to do what I want the program to do, at least not > > in any of the examples I have found, nor in the vignettes and relevant > > package manuals I've looked at. > > > > The first point is, is what I am intending to do even possible using R? > > If it is, then where do I start with this? If these docx files were > > converted to UTF-8 plain text, would that make the task easier? > > > > I am not a confident coder, and am really only just getting my head > > around R so appreciate a steep learning curve ahead, but of course, I > > don't know what I don't know, so any pointers in the right direction > > would be a big help. > > > > Many thanks in anticipation > > > > Andy > > > > ______ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet
textreadr would be the obvious approach. When you say it is depreciated do you mean it's not available on cran? Sometimes maintaining a package on cran in just a pain in the ass. devtools::install_github("trinker/textreadr") Should let you install it. In theory docx files are actually just zip files (you can unzip them) and you may find there is then a specific file in the zip that is readable with on of R's General text file readers. Alternatively, read_docx from: https://www.rdocumentation.org/packages/qdapTools May be worth a look. What platform are you on. Certainly options to command line convert files to txt and do from there. On Fri, 29 Dec 2023, 18:25 Roy Mendelssohn - NOAA Federal via R-help, < r-help@r-project.org> wrote: > Hi Andy: > > I don’t have an answer but I do have what I hope is some friendly advice. > Generally the more information you can provide, the more likely you will > get help that is useful. In your case you say that you tried several > packages and they didn’t do what you wanted. Providing that code, as well > as why they didn’t do what you wanted (be specific) would greatly > facilitate things. > > Happy new year, > > -Roy > > > > On Dec 29, 2023, at 10:14 AM, Andy wrote: > > > > Hello > > > > I am trying to work through a problem, but feel like I've gone down a > rabbit hole. I'd very much appreciate any help. > > > > The task: I have several directories of multiple (some directories, up > to 2,500+) *.docx files (newspaper articles downloaded from Lexis+) that I > want to iterate through to append to a spreadsheet only those articles that > satisfy a condition (i.e., a specific keyword is present for >= 50% > coverage of the subject matter). Lexis+ has a very specific structure and > keywords are given in the row "Subject". > > > > I'd like to be able to accomplish the following: > > > > (1) Append the title, the month, the author, the number of words, and > page number(s) to a spreadsheet > > > > (2) Read each article and extract keywords (in the docs, these are > listed in 'Subject' section as a list of keywords with a percentage showing > the extent to which the keyword features in the article (e.g., FAST FASHION > (72%)) and to append the keyword and the % coverage to the same row in the > spreadsheet. However, I want to ensure that the keyword coverage meets the > threshold of >= 50%; if not, then pass onto the next article in the > directory. Rinse and repeat for the entire directory. > > > > So far, I've tried working through some Stack Overflow-based solutions, > but most seem to use the textreadr package, which is now deprecated; others > use either the officer or the officedown packages. However, these packages > don't appear to do what I want the program to do, at least not in any of > the examples I have found, nor in the vignettes and relevant package > manuals I've looked at. > > > > The first point is, is what I am intending to do even possible using R? > If it is, then where do I start with this? If these docx files were > converted to UTF-8 plain text, would that make the task easier? > > > > I am not a confident coder, and am really only just getting my head > around R so appreciate a steep learning curve ahead, but of course, I don't > know what I don't know, so any pointers in the right direction would be a > big help. > > > > Many thanks in anticipation > > > > Andy > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > ______ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet
checkout the 'officer' package Thanks Jim Holtman *Data Munger Guru* *What is the problem that you are trying to solve?Tell me what you want to do, not how you want to do it.* On Fri, Dec 29, 2023 at 10:14 AM Andy wrote: > Hello > > I am trying to work through a problem, but feel like I've gone down a > rabbit hole. I'd very much appreciate any help. > > The task: I have several directories of multiple (some directories, up > to 2,500+) *.docx files (newspaper articles downloaded from Lexis+) that > I want to iterate through to append to a spreadsheet only those articles > that satisfy a condition (i.e., a specific keyword is present for >= 50% > coverage of the subject matter). Lexis+ has a very specific structure > and keywords are given in the row "Subject". > > I'd like to be able to accomplish the following: > > (1) Append the title, the month, the author, the number of words, and > page number(s) to a spreadsheet > > (2) Read each article and extract keywords (in the docs, these are > listed in 'Subject' section as a list of keywords with a percentage > showing the extent to which the keyword features in the article (e.g., > FAST FASHION (72%)) and to append the keyword and the % coverage to the > same row in the spreadsheet. However, I want to ensure that the keyword > coverage meets the threshold of >= 50%; if not, then pass onto the next > article in the directory. Rinse and repeat for the entire directory. > > So far, I've tried working through some Stack Overflow-based solutions, > but most seem to use the textreadr package, which is now deprecated; > others use either the officer or the officedown packages. However, these > packages don't appear to do what I want the program to do, at least not > in any of the examples I have found, nor in the vignettes and relevant > package manuals I've looked at. > > The first point is, is what I am intending to do even possible using R? > If it is, then where do I start with this? If these docx files were > converted to UTF-8 plain text, would that make the task easier? > > I am not a confident coder, and am really only just getting my head > around R so appreciate a steep learning curve ahead, but of course, I > don't know what I don't know, so any pointers in the right direction > would be a big help. > > Many thanks in anticipation > > Andy > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet
Hi Andy: I don’t have an answer but I do have what I hope is some friendly advice. Generally the more information you can provide, the more likely you will get help that is useful. In your case you say that you tried several packages and they didn’t do what you wanted. Providing that code, as well as why they didn’t do what you wanted (be specific) would greatly facilitate things. Happy new year, -Roy > On Dec 29, 2023, at 10:14 AM, Andy wrote: > > Hello > > I am trying to work through a problem, but feel like I've gone down a rabbit > hole. I'd very much appreciate any help. > > The task: I have several directories of multiple (some directories, up to > 2,500+) *.docx files (newspaper articles downloaded from Lexis+) that I want > to iterate through to append to a spreadsheet only those articles that > satisfy a condition (i.e., a specific keyword is present for >= 50% coverage > of the subject matter). Lexis+ has a very specific structure and keywords are > given in the row "Subject". > > I'd like to be able to accomplish the following: > > (1) Append the title, the month, the author, the number of words, and page > number(s) to a spreadsheet > > (2) Read each article and extract keywords (in the docs, these are listed in > 'Subject' section as a list of keywords with a percentage showing the extent > to which the keyword features in the article (e.g., FAST FASHION (72%)) and > to append the keyword and the % coverage to the same row in the spreadsheet. > However, I want to ensure that the keyword coverage meets the threshold of >= > 50%; if not, then pass onto the next article in the directory. Rinse and > repeat for the entire directory. > > So far, I've tried working through some Stack Overflow-based solutions, but > most seem to use the textreadr package, which is now deprecated; others use > either the officer or the officedown packages. However, these packages don't > appear to do what I want the program to do, at least not in any of the > examples I have found, nor in the vignettes and relevant package manuals I've > looked at. > > The first point is, is what I am intending to do even possible using R? If it > is, then where do I start with this? If these docx files were converted to > UTF-8 plain text, would that make the task easier? > > I am not a confident coder, and am really only just getting my head around R > so appreciate a steep learning curve ahead, but of course, I don't know what > I don't know, so any pointers in the right direction would be a big help. > > Many thanks in anticipation > > Andy > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help request: Parsing docx files for key words and appending to a spreadsheet
Hello I am trying to work through a problem, but feel like I've gone down a rabbit hole. I'd very much appreciate any help. The task: I have several directories of multiple (some directories, up to 2,500+) *.docx files (newspaper articles downloaded from Lexis+) that I want to iterate through to append to a spreadsheet only those articles that satisfy a condition (i.e., a specific keyword is present for >= 50% coverage of the subject matter). Lexis+ has a very specific structure and keywords are given in the row "Subject". I'd like to be able to accomplish the following: (1) Append the title, the month, the author, the number of words, and page number(s) to a spreadsheet (2) Read each article and extract keywords (in the docs, these are listed in 'Subject' section as a list of keywords with a percentage showing the extent to which the keyword features in the article (e.g., FAST FASHION (72%)) and to append the keyword and the % coverage to the same row in the spreadsheet. However, I want to ensure that the keyword coverage meets the threshold of >= 50%; if not, then pass onto the next article in the directory. Rinse and repeat for the entire directory. So far, I've tried working through some Stack Overflow-based solutions, but most seem to use the textreadr package, which is now deprecated; others use either the officer or the officedown packages. However, these packages don't appear to do what I want the program to do, at least not in any of the examples I have found, nor in the vignettes and relevant package manuals I've looked at. The first point is, is what I am intending to do even possible using R? If it is, then where do I start with this? If these docx files were converted to UTF-8 plain text, would that make the task easier? I am not a confident coder, and am really only just getting my head around R so appreciate a steep learning curve ahead, but of course, I don't know what I don't know, so any pointers in the right direction would be a big help. Many thanks in anticipation Andy __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R-help Digest, Vol 250, Issue 13
Kevin, Maybe also look at what air quality monitoring is being done in area. https://cran.r-project.org/web/packages/RAQSAPI/vignettes/RAQSAPIvignette.html Depends what and how near, but might be something relevant there? Karl Dr Karl Ropkins Transport Studies | Environment | University of Leeds -- Message: 2 Date: Tue, 12 Dec 2023 07:52:59 -0800 From: Bert Gunter To: Kevin Zembower Cc: R-help email list Subject: Re: [R] Advice on starting to analyze smokestack emissions? Message-ID: Content-Type: text/plain; charset="utf-8" You might also try the R-Sig-ecology list, though I would agree that it's not clearly related. Still, air pollution effects...? -- Bert On Tue, Dec 12, 2023 at 3:15 AM Kevin Zembower via R-help < r-help@r-project.org> wrote: > Hello, all, > > [Originally sent to r-sig-geo list, with no response. Cross-posting > here, in the hope of a wider audience. Anyone with any experience in > this topic? Thanks.] > > I'm trying to get started analyzing the concentrations of smokestack > emissions. I don't have any professional background or training for > this; I'm just an old, retired guy who thinks playing with numbers is > fun. > > A local funeral home in my neighborhood (less than 1200 ft from my > home) is proposing to construct a crematorium for human remains. I have > some experience with the tidycensus package and thought it might be > interesting to construct a model for the changes in concentrations of > the pollutants from the smokestack and, using recorded wind speeds and > directions, see which US Census blocks would be affected. > > I have the US Government EPA SCREEN3 output on how concentration varies > with distance from the smokestack. > See > https://www.epa.gov/scram/air-quality-dispersion-modeling-screening-models#screen3 > if curious. As a first task, I'd like to see if I can calculate similar > results in R. I'm aware of the 'plume' steady-state Gaussian dispersion > package > (https://rdrr.io/github/holstius/plume/f/inst/doc/plume-intro.pdf), but > am a little concerned that this package was last updated 11 years ago. > > Do you have any recommendations for me on how to get started analyzing > this problem? Is 'plume' still the way to go? I'm aware that there are > many atmospheric dispersion models from the US EPA, but I was hoping to > keep my work within R, which I'm really enjoying using and learning > about. Are SCREEN3 and 'plume' comparable? Is this the best R list to > ask questions about this topic? > > Thanks for any advice or guidance you have for me. > > -Kevin > > > > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.r-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] -- Message: 3 Date: Tue, 12 Dec 2023 21:19:12 + (UTC) From: varin sacha To: "r-help@r-project.org" , Ben Bolker Subject: Re: [R] ggplot2: Get the regression line with 95% confidence bands Message-ID: <68588390.888662.1702415952...@mail.yahoo.com> Content-Type: text/plain; charset="utf-8" Dear Ben, Dear Daniel, Dear Rui, Dear Bert, Here below my R code. I really appreciate all your comments. My R code is perfectly working but there is still something I would like to improve. The X-axis is showing 2012.5 ; 2015.0 ; 2017.5 ; 2020.0 I would like to see on X-axis only the year (2012 ; 2015 ; 2017 ; 2020). How to do? # library(ggplot2) df=data.frame(year= c(2012,2015,2018,2022), score=c(495,493, 495, 474)) ggplot(df, aes(x = year, y = score)) + geom_point() + geom_smooth(method = "lm", formula = y ~ x) + labs(title = "Standard linear regression for France", x = "Year", y = "PISA score in mathematics") + scale_y_continuous(limits=c(470,500),oob=scales::squish) # Le lundi 11 décembre 2023 à 23:38:06 UTC+1, Ben Bolker a écrit : On 2023-12-11 5:27 p.m., Daniel Nordlund wrote: > On 12/10/2023 2:50 PM, Rui Barradas wrote: >> Às 22:35 de 10/12/2023, varin sacha via R-help escreveu: >>> >>> Dear R-experts, >>> >>> Here below my R code, as my X-axis is "year", I must be missing one >>> or more steps! I am trying to get the regression line with the 95% >>> confidence bands around the regression line. Any help would be >>> appreciated. >>> >>> Best, >>> S. >&
Re: [R] Virus alert because of an R-help e-mail
No attachments. Most are deleted by ETH mailman ... because they might contain viruses. -- Bert On Tue, Oct 31, 2023 at 8:59 AM David Croll wrote: > I just received a virus warning from my e-mail provider, GMX. See the > attached image below. > > The virus detection can be spurious - but the e-mail was automatically > deleted by GMX. > > With the best regards, > > > David > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Virus alert because of an R-help e-mail
I just received a virus warning from my e-mail provider, GMX. See the attached image below. The virus detection can be spurious - but the e-mail was automatically deleted by GMX. With the best regards, David __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with plotting and date-times for climate data
Change geom_point(aes(y = tmax_mean, color = "blue")) to geom_point(aes(y = tmax_mean), color = "blue") if you want blue points. aes(color = ) does not set the color of the points. aes(color = ) takes a column (best if it is a factor) and uses that for different colors. /Martin On Tue, Sep 12, 2023, 22:50 Kevin Zembower via R-help wrote: > Hello, > > I'm trying to calculate the mean temperature max from a file of climate > date, and plot it over a range of days in the year. I've downloaded the > data, and cleaned it up the way I think it should be. However, when I > plot it, the geom_smooth line doesn't show up. I think that's because > my x axis is characters or factors. Here's what I have so far: > > library(tidyverse) > > data <- read_csv("Ely_MN_Weather.csv") > > start_day = yday(as_date("2023-09-22")) > end_day = yday(as_date("2023-10-15")) > > d <- as_tibble(data) %>% > select(DATE,TMAX,TMIN) %>% > mutate(DATE = as_date(DATE), >yday = yday(DATE), >md = sprintf("%02d-%02d", month(DATE), mday(DATE)) >) %>% > filter(yday >= start_day & yday <= end_day) %>% > mutate(md = as.factor(md)) > > d_sum <- d %>% > group_by(md) %>% > summarize(tmax_mean = mean(TMAX, na.rm=TRUE)) > > ## Here's the filtered data: > dput(d_sum) > > > structure(list(md = structure(1:25, levels = c("09-21", "09-22", > "09-23", "09-24", "09-25", "09-26", "09-27", "09-28", "09-29", > "09-30", "10-01", "10-02", "10-03", "10-04", "10-05", "10-06", > "10-07", "10-08", "10-09", "10-10", "10-11", "10-12", "10-13", > "10-14", "10-15"), class = "factor"), tmax_mean = c(65, > 62.2, > 61.3, 63.9, 64.3, 60.1, 62.3, 60.5, 61.9, > 61.2, 63.7, 59.5, 59.6, 61.6, > 59.4, 58.8, 55.9, 58.125, > 58, 55.7, 57, 55.4, 49.8, > 48.75, 43.7)), class = c("tbl_df", "tbl", "data.frame" > ), row.names = c(NA, -25L)) > > > ggplot(data = d_sum, aes(x = md)) + > geom_point(aes(y = tmax_mean, color = "blue")) + > geom_smooth(aes(y = tmax_mean, color = "blue")) > ===== > My questions are: > 1. Why isn't my geom_smooth plotting? How can I fix it? > 2. I don't think I'm handling the month and day combination correctly. > Is there a way to encode month and day (but not year) as a date? > 3. (Minor point) Why does my graph of tmax_mean come out red when I > specify "blue"? > > Thanks for any advice or guidance you can offer. I really appreciate > the expertise of this group. > > -Kevin > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with plotting and date-times for climate data
can be modeled as a function of > > > temperature. These are often called growing degree day models (or > > > some version of that). This is number of thermal units needed for > > > the organism to develop to the next stage (e.g. instar for an > > > insect, or fruit/flower formation for a plant). However, better > > > accuracy is obtained if the model includes both min and max > > > thresholds. > > > > > > All I have done is provide an example where min and max could have > > > a real world use. I use max(temp) over some interval and then > > > update an accumulated thermal units variable based on the outcome. > > > That detail is not evident in the original request. > > > > > > Tim > > > > > > -Original Message- > > > From: R-help On Behalf Of Richard > > > O'Keefe > > > Sent: Wednesday, September 13, 2023 9:58 AM > > > To: Kevin Zembower > > > Cc: r-help@r-project.org > > > Subject: Re: [R] Help with plotting and date-times for climate data > > > > > > [External Email] > > > > > > Off-topic, but what is a "mean temperature max" > > > and what good would it do you to know you if you did? > > > I've been looking at a lot of weather station data and for no > > > question I've ever had (except "would the newspapers get excited > > > about this") was "max" (or min) the answer. Considering the way > > > that temperature can change by several degrees in a few minutes, or > > > a few metres -- I meant horizontally when I wrote that, but as you > > > know your head and feet don't experience the same temperature, > > > again by more than one degree -- I am at something of a loss to > > > ascribe much practical significance to TMAX. Are you sure this is > > > the analysis you want to do? Is this the most informative data you > > > can get? > > > > > > On Wed, 13 Sept 2023 at 08:51, Kevin Zembower via R-help < > > > r-help@r-project.org> wrote: > > > > > > > Hello, > > > > > > > > I'm trying to calculate the mean temperature max from a file of > > > > climate date, and plot it over a range of days in the year. I've > > > > downloaded the data, and cleaned it up the way I think it should > > > > be. > > > > However, when I plot it, the geom_smooth line doesn't show up. I > > > > think > > > > that's because my x axis is characters or factors. Here's what I > > > > have so far: > > > > > > > > library(tidyverse) > > > > > > > > data <- read_csv("Ely_MN_Weather.csv") > > > > > > > > start_day = yday(as_date("2023-09-22")) end_day = > > > > yday(as_date("2023-10-15")) > > > > > > > > d <- as_tibble(data) %>% > > > > select(DATE,TMAX,TMIN) %>% > > > > mutate(DATE = as_date(DATE), > > > > yday = yday(DATE), > > > > md = sprintf("%02d-%02d", month(DATE), mday(DATE)) > > > > ) %>% > > > > filter(yday >= start_day & yday <= end_day) %>% > > > > mutate(md = as.factor(md)) > > > > > > > > d_sum <- d %>% > > > > group_by(md) %>% > > > > summarize(tmax_mean = mean(TMAX, na.rm=TRUE)) > > > > > > > > ## Here's the filtered data: > > > > dput(d_sum) > > > > > > > > > structure(list(md = structure(1:25, levels = c("09-21", "09- > > > > > 22", > > > > "09-23", "09-24", "09-25", "09-26", "09-27", "09-28", "09-29", > > > > "09-30", "10-01", "10-02", "10-03", "10-04", "10-05", "10-06", > > > > "10-07", "10-08", "10-09", "10-10", "10-11", "10-12", "10-13", > > > > "10-14", "10-15"), class = "factor"), tmax_mean = c(65, > > > > 62.2, 61.3, 63.9, 64.3, 60.1, > > > > 62.3, 60.5, 61.9, 61.2, 63.7, 59.5, 59.6, > > > > 61.6, 59.4, 58.8, &
Re: [R] Help with plotting and date-times for climate data
Dear Kevin, You could try the National Weather Service. I can get "International Falls" and other locations, though Ely is not specifically listed. h**ps://www.weather.gov/wrh/climate?wfo=dlh Replace the ** with tt and it should give the right link. There is a menu. Select your location, Select a product (I selected temperature) Select a year, and period of interest. Select go. If you scroll over the figure a popup with numbers appears. The weather data in R is possible as well. I would start by filtering the data to remove dates outside my range of interest. Then extract the date (say Day). Group_by the day and apply a max function to the grouped data. Then plot the result. Tim -Original Message- From: Kevin Zembower Sent: Wednesday, September 13, 2023 3:26 PM To: Ebert,Timothy Aaron ; Richard O'Keefe Cc: r-help@r-project.org Subject: Re: [R] Help with plotting and date-times for climate data [External Email] Hi, Tim, I actually did see this chart when I was doing some research, but rejected it because it was difficult to interpolate the graph for the three week period I was interested it. I didn't discover until just now that I could click on the labels on the x-axis to expand the graph. Unfortunately, downloading the data from this site costs $95/month. Also, I found the raw data (from the NWS, for free) and decided to exercise my R skills to see if I could produce the exact graph I wanted. Thanks for taking the time to research this. -Kevin On Wed, 2023-09-13 at 18:21 +, Ebert,Timothy Aaron wrote: > Hi Kevin, > > https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fweat > herspark.com%2Fy%2F11610%2FAverage-Weather-in-Ely-Minnesota-United-Sta > tes-Year-Round&data=05%7C01%7Ctebert%40ufl.edu%7C3c23bc8b4af14d747e2f0 > 8dbb48f37af%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C6383022994410 > 38779%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJB > TiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=CE%2FYdcJbtKhZZ6VeRlI > 55gEfwy8m2i1yhO9iUgB%2BkUc%3D&reserved=0 > Just scroll down. I think what you are looking for is the first graph, > but there are about a dozen other graphs on various meteorological > metrics. > >Another option would be to use larger cities (Duluth, > International Falls, Thunder Bay) and take a metal average. There is a > lake effect for two of these more than the other. > >All good? > Tim > > -Original Message- > From: Kevin Zembower > Sent: Wednesday, September 13, 2023 2:05 PM > To: Ebert,Timothy Aaron ; Richard O'Keefe > > Cc: r-help@r-project.org > Subject: Re: [R] Help with plotting and date-times for climate data > > [External Email] > > Well, I looked for this, on both the NWS and WeatherUnderground, but > couldn't find what I was looking for. Didn't check Weather.com, but if > you can find a chart of the average high and low temperatures in Ely, > MN between about the middle of September to the middle of October, > I'll buy you a beer. > > -Kevin > > On Wed, 2023-09-13 at 17:39 +, Ebert,Timothy Aaron wrote: > > I admire the dedication to R and data science, but the Weather > > Channel might be a simpler approach. Weather.com. I can search for > > (city > > name) > > and either weather (current values) or climate. It depends on how > > far away the trip will be. > > > > -Original Message- > > From: Kevin Zembower > > Sent: Wednesday, September 13, 2023 1:22 PM > > To: Richard O'Keefe ; Ebert,Timothy Aaron > > > > Cc: r-help@r-project.org > > Subject: Re: [R] Help with plotting and date-times for climate data > > > > [External Email] > > > > Tim, Richard, y'all are reading too much into this. I believe that > > TMAX is the high temperature of the day, and TMIN is the low. I'm > > trying to compute the average or median high and low temperatures > > for the data I have (2011 to present). I'm going on a trip to this > > area, and want to know how to pack. > > > > Thanks for your interest. > > > > -Kevin > > > > On Thu, 2023-09-14 at 03:07 +1200, Richard O'Keefe wrote: > > > I am well aware of the physiological implications of temperature, > > > and that is *why* I view recorded TMIN and TMAX at a single point > > > with an extremely jaundiced eye. TMAX at shoulder height has very > > > little relevance to an insect living in grass, for example. And > > > if TMAX is sustained for one second, that has very different > > > consequences from if TMAX is sustained for five minutes. I can > > > see the usefulness of "proportion of day abov
Re: [R] Help with plotting and date-times for climate data
Hi, Tim, I actually did see this chart when I was doing some research, but rejected it because it was difficult to interpolate the graph for the three week period I was interested it. I didn't discover until just now that I could click on the labels on the x-axis to expand the graph. Unfortunately, downloading the data from this site costs $95/month. Also, I found the raw data (from the NWS, for free) and decided to exercise my R skills to see if I could produce the exact graph I wanted. Thanks for taking the time to research this. -Kevin On Wed, 2023-09-13 at 18:21 +, Ebert,Timothy Aaron wrote: > Hi Kevin, > > https://weatherspark.com/y/11610/Average-Weather-in-Ely-Minnesota-United-States-Year-Round > Just scroll down. I think what you are looking for is the first > graph, but there are about a dozen other graphs on various > meteorological metrics. > > Another option would be to use larger cities (Duluth, > International Falls, Thunder Bay) and take a metal average. There is > a lake effect for two of these more than the other. > > All good? > Tim > > -Original Message- > From: Kevin Zembower > Sent: Wednesday, September 13, 2023 2:05 PM > To: Ebert,Timothy Aaron ; Richard O'Keefe > > Cc: r-help@r-project.org > Subject: Re: [R] Help with plotting and date-times for climate data > > [External Email] > > Well, I looked for this, on both the NWS and WeatherUnderground, but > couldn't find what I was looking for. Didn't check Weather.com, but > if you can find a chart of the average high and low temperatures in > Ely, MN between about the middle of September to the middle of > October, I'll buy you a beer. > > -Kevin > > On Wed, 2023-09-13 at 17:39 +, Ebert,Timothy Aaron wrote: > > I admire the dedication to R and data science, but the Weather > > Channel > > might be a simpler approach. Weather.com. I can search for (city > > name) > > and either weather (current values) or climate. It depends on how > > far > > away the trip will be. > > > > -Original Message----- > > From: Kevin Zembower > > Sent: Wednesday, September 13, 2023 1:22 PM > > To: Richard O'Keefe ; Ebert,Timothy Aaron > > > > Cc: r-help@r-project.org > > Subject: Re: [R] Help with plotting and date-times for climate data > > > > [External Email] > > > > Tim, Richard, y'all are reading too much into this. I believe that > > TMAX is the high temperature of the day, and TMIN is the low. I'm > > trying to compute the average or median high and low temperatures > > for > > the data I have (2011 to present). I'm going on a trip to this > > area, > > and want to know how to pack. > > > > Thanks for your interest. > > > > -Kevin > > > > On Thu, 2023-09-14 at 03:07 +1200, Richard O'Keefe wrote: > > > I am well aware of the physiological implications of temperature, > > > and that is *why* I view recorded TMIN and TMAX at a single point > > > with an extremely jaundiced eye. TMAX at shoulder height has > > > very > > > little relevance to an insect living in grass, for example. And > > > if > > > TMAX is sustained for one second, that has very different > > > consequences from if TMAX is sustained for five minutes. I can > > > see > > > the usefulness of "proportion of day above Thi/below Tlo", but > > > that > > > is quite different. > > > > > > OK, so my interest in weather data was mainly based around water > > > management: precipitation, evaporation, herd and crop water > > > needs, > > > that kind of thing. And the first thing you learn from that > > > experience is that ANY kind of single-point summary is seriously > > > misleading. > > > > > > Let's end this digression. > > > > > > > > > On Thu, 14 Sept 2023 at 02:18, Ebert,Timothy Aaron > > > > > > wrote: > > > > I had the same question. > > > > However, I can partly answer the off-topic question. Min and > > > > max > > > > can be important as lower and upper development thresholds. > > > > Below > > > > the min no growth or development occur because reaction rates > > > > are > > > > too slow to enable such. Above max, temperatures are too hot. > > > > Protein function is impaired, and systems stop functioning. > > > > There > > > > is a considerable range between where systems shut
Re: [R] Help with plotting and date-times for climate data
Hi Kevin, https://weatherspark.com/y/11610/Average-Weather-in-Ely-Minnesota-United-States-Year-Round Just scroll down. I think what you are looking for is the first graph, but there are about a dozen other graphs on various meteorological metrics. Another option would be to use larger cities (Duluth, International Falls, Thunder Bay) and take a metal average. There is a lake effect for two of these more than the other. All good? Tim -Original Message- From: Kevin Zembower Sent: Wednesday, September 13, 2023 2:05 PM To: Ebert,Timothy Aaron ; Richard O'Keefe Cc: r-help@r-project.org Subject: Re: [R] Help with plotting and date-times for climate data [External Email] Well, I looked for this, on both the NWS and WeatherUnderground, but couldn't find what I was looking for. Didn't check Weather.com, but if you can find a chart of the average high and low temperatures in Ely, MN between about the middle of September to the middle of October, I'll buy you a beer. -Kevin On Wed, 2023-09-13 at 17:39 +, Ebert,Timothy Aaron wrote: > I admire the dedication to R and data science, but the Weather Channel > might be a simpler approach. Weather.com. I can search for (city name) > and either weather (current values) or climate. It depends on how far > away the trip will be. > > -Original Message- > From: Kevin Zembower > Sent: Wednesday, September 13, 2023 1:22 PM > To: Richard O'Keefe ; Ebert,Timothy Aaron > > Cc: r-help@r-project.org > Subject: Re: [R] Help with plotting and date-times for climate data > > [External Email] > > Tim, Richard, y'all are reading too much into this. I believe that > TMAX is the high temperature of the day, and TMIN is the low. I'm > trying to compute the average or median high and low temperatures for > the data I have (2011 to present). I'm going on a trip to this area, > and want to know how to pack. > > Thanks for your interest. > > -Kevin > > On Thu, 2023-09-14 at 03:07 +1200, Richard O'Keefe wrote: > > I am well aware of the physiological implications of temperature, > > and that is *why* I view recorded TMIN and TMAX at a single point > > with an extremely jaundiced eye. TMAX at shoulder height has very > > little relevance to an insect living in grass, for example. And if > > TMAX is sustained for one second, that has very different > > consequences from if TMAX is sustained for five minutes. I can see > > the usefulness of "proportion of day above Thi/below Tlo", but that > > is quite different. > > > > OK, so my interest in weather data was mainly based around water > > management: precipitation, evaporation, herd and crop water needs, > > that kind of thing. And the first thing you learn from that > > experience is that ANY kind of single-point summary is seriously > > misleading. > > > > Let's end this digression. > > > > > > On Thu, 14 Sept 2023 at 02:18, Ebert,Timothy Aaron > > wrote: > > > I had the same question. > > > However, I can partly answer the off-topic question. Min and max > > > can be important as lower and upper development thresholds. Below > > > the min no growth or development occur because reaction rates are > > > too slow to enable such. Above max, temperatures are too hot. > > > Protein function is impaired, and systems stop functioning. There > > > is a considerable range between where systems shut down (but > > > recover) and tissue death. > > > In a simple form the growth and physiological stage of plants, > > > insects, and many others, can be modeled as a function of > > > temperature. These are often called growing degree day models (or > > > some version of that). This is number of thermal units needed for > > > the organism to develop to the next stage (e.g. instar for an > > > insect, or fruit/flower formation for a plant). However, better > > > accuracy is obtained if the model includes both min and max > > > thresholds. > > > > > > All I have done is provide an example where min and max could have > > > a real world use. I use max(temp) over some interval and then > > > update an accumulated thermal units variable based on the outcome. > > > That detail is not evident in the original request. > > > > > > Tim > > > > > > -Original Message- > > > From: R-help On Behalf Of Richard > > > O'Keefe > > > Sent: Wednesday, September 13, 2023 9:58 AM > > > To: Kevin Zembower > > > Cc: r-help@r-project.org > > >
Re: [R] Help with plotting and date-times for climate data
Well, I looked for this, on both the NWS and WeatherUnderground, but couldn't find what I was looking for. Didn't check Weather.com, but if you can find a chart of the average high and low temperatures in Ely, MN between about the middle of September to the middle of October, I'll buy you a beer. -Kevin On Wed, 2023-09-13 at 17:39 +, Ebert,Timothy Aaron wrote: > I admire the dedication to R and data science, but the Weather > Channel might be a simpler approach. Weather.com. I can search for > (city name) and either weather (current values) or climate. It > depends on how far away the trip will be. > > -Original Message- > From: Kevin Zembower > Sent: Wednesday, September 13, 2023 1:22 PM > To: Richard O'Keefe ; Ebert,Timothy Aaron > > Cc: r-help@r-project.org > Subject: Re: [R] Help with plotting and date-times for climate data > > [External Email] > > Tim, Richard, y'all are reading too much into this. I believe that > TMAX is the high temperature of the day, and TMIN is the low. I'm > trying to compute the average or median high and low temperatures for > the data I have (2011 to present). I'm going on a trip to this area, > and want to know how to pack. > > Thanks for your interest. > > -Kevin > > On Thu, 2023-09-14 at 03:07 +1200, Richard O'Keefe wrote: > > I am well aware of the physiological implications of temperature, > > and > > that is *why* I view recorded TMIN and TMAX at a single point with > > an > > extremely jaundiced eye. TMAX at shoulder height has very little > > relevance to an insect living in grass, for example. And if TMAX > > is > > sustained for one second, that has very different consequences from > > if > > TMAX is sustained for five minutes. I can see the usefulness of > > "proportion of day above Thi/below Tlo", but that is quite > > different. > > > > OK, so my interest in weather data was mainly based around water > > management: precipitation, evaporation, herd and crop water needs, > > that kind of thing. And the first thing you learn from that > > experience is that ANY kind of single-point summary is seriously > > misleading. > > > > Let's end this digression. > > > > > > On Thu, 14 Sept 2023 at 02:18, Ebert,Timothy Aaron > > wrote: > > > I had the same question. > > > However, I can partly answer the off-topic question. Min and max > > > can > > > be important as lower and upper development thresholds. Below the > > > min no growth or development occur because reaction rates are too > > > slow to enable such. Above max, temperatures are too hot. > > > Protein function is impaired, and systems stop functioning. There > > > is > > > a considerable range between where systems shut down (but > > > recover) and tissue death. > > > In a simple form the growth and physiological stage of plants, > > > insects, and many others, can be modeled as a function of > > > temperature. These are often called growing degree day models (or > > > some version of that). This is number of thermal units needed for > > > the organism to develop to the next stage (e.g. instar for an > > > insect, or fruit/flower formation for a plant). However, better > > > accuracy is obtained if the model includes both min and max > > > thresholds. > > > > > > All I have done is provide an example where min and max could > > > have a > > > real world use. I use max(temp) over some interval and then > > > update > > > an accumulated thermal units variable based on the outcome. > > > That detail is not evident in the original request. > > > > > > Tim > > > > > > -Original Message- > > > From: R-help On Behalf Of Richard > > > O'Keefe > > > Sent: Wednesday, September 13, 2023 9:58 AM > > > To: Kevin Zembower > > > Cc: r-help@r-project.org > > > Subject: Re: [R] Help with plotting and date-times for climate > > > data > > > > > > [External Email] > > > > > > Off-topic, but what is a "mean temperature max" > > > and what good would it do you to know you if you did? > > > I've been looking at a lot of weather station data and for no > > > question I've ever had (except "would the newspapers get excited > > > about this") was "max" (or min) the answer. Considering the way > > > that temperature can change by several degrees in a few
Re: [R] Help with plotting and date-times for climate data
I admire the dedication to R and data science, but the Weather Channel might be a simpler approach. Weather.com. I can search for (city name) and either weather (current values) or climate. It depends on how far away the trip will be. -Original Message- From: Kevin Zembower Sent: Wednesday, September 13, 2023 1:22 PM To: Richard O'Keefe ; Ebert,Timothy Aaron Cc: r-help@r-project.org Subject: Re: [R] Help with plotting and date-times for climate data [External Email] Tim, Richard, y'all are reading too much into this. I believe that TMAX is the high temperature of the day, and TMIN is the low. I'm trying to compute the average or median high and low temperatures for the data I have (2011 to present). I'm going on a trip to this area, and want to know how to pack. Thanks for your interest. -Kevin On Thu, 2023-09-14 at 03:07 +1200, Richard O'Keefe wrote: > I am well aware of the physiological implications of temperature, and > that is *why* I view recorded TMIN and TMAX at a single point with an > extremely jaundiced eye. TMAX at shoulder height has very little > relevance to an insect living in grass, for example. And if TMAX is > sustained for one second, that has very different consequences from if > TMAX is sustained for five minutes. I can see the usefulness of > "proportion of day above Thi/below Tlo", but that is quite different. > > OK, so my interest in weather data was mainly based around water > management: precipitation, evaporation, herd and crop water needs, > that kind of thing. And the first thing you learn from that > experience is that ANY kind of single-point summary is seriously > misleading. > > Let's end this digression. > > > On Thu, 14 Sept 2023 at 02:18, Ebert,Timothy Aaron > wrote: > > I had the same question. > > However, I can partly answer the off-topic question. Min and max can > > be important as lower and upper development thresholds. Below the > > min no growth or development occur because reaction rates are too > > slow to enable such. Above max, temperatures are too hot. > > Protein function is impaired, and systems stop functioning. There is > > a considerable range between where systems shut down (but > > recover) and tissue death. > > In a simple form the growth and physiological stage of plants, > > insects, and many others, can be modeled as a function of > > temperature. These are often called growing degree day models (or > > some version of that). This is number of thermal units needed for > > the organism to develop to the next stage (e.g. instar for an > > insect, or fruit/flower formation for a plant). However, better > > accuracy is obtained if the model includes both min and max > > thresholds. > > > > All I have done is provide an example where min and max could have a > > real world use. I use max(temp) over some interval and then update > > an accumulated thermal units variable based on the outcome. > > That detail is not evident in the original request. > > > > Tim > > > > -Original Message- > > From: R-help On Behalf Of Richard > > O'Keefe > > Sent: Wednesday, September 13, 2023 9:58 AM > > To: Kevin Zembower > > Cc: r-help@r-project.org > > Subject: Re: [R] Help with plotting and date-times for climate data > > > > [External Email] > > > > Off-topic, but what is a "mean temperature max" > > and what good would it do you to know you if you did? > > I've been looking at a lot of weather station data and for no > > question I've ever had (except "would the newspapers get excited > > about this") was "max" (or min) the answer. Considering the way > > that temperature can change by several degrees in a few minutes, or > > a few metres -- I meant horizontally when I wrote that, but as you > > know your head and feet don't experience the same temperature, again > > by more than one degree -- I am at something of a loss to ascribe > > much practical significance to TMAX. Are you sure this is the > > analysis you want to do? Is this the most informative data you can > > get? > > > > On Wed, 13 Sept 2023 at 08:51, Kevin Zembower via R-help < > > r-help@r-project.org> wrote: > > > > > Hello, > > > > > > I'm trying to calculate the mean temperature max from a file of > > > climate date, and plot it over a range of days in the year. I've > > > downloaded the data, and cleaned it up the way I think it should > > > be. > > > However, when I plot it, the geom_smooth line doe
Re: [R] Help with plotting and date-times for climate data
Rui, thanks so much for your clear explanation, solution to my problem, and additional help with making the graph come out exactly as I was hoping. I learned a lot from your solution. Thanks, again, for your help. -Kevin On Tue, 2023-09-12 at 23:06 +0100, Rui Barradas wrote: > Às 21:50 de 12/09/2023, Kevin Zembower via R-help escreveu: > > Hello, > > > > I'm trying to calculate the mean temperature max from a file of > > climate > > date, and plot it over a range of days in the year. I've downloaded > > the > > data, and cleaned it up the way I think it should be. However, when > > I > > plot it, the geom_smooth line doesn't show up. I think that's > > because > > my x axis is characters or factors. Here's what I have so far: > > > > library(tidyverse) > > > > data <- read_csv("Ely_MN_Weather.csv") > > > > start_day = yday(as_date("2023-09-22")) > > end_day = yday(as_date("2023-10-15")) > > > > d <- as_tibble(data) %>% > > select(DATE,TMAX,TMIN) %>% > > mutate(DATE = as_date(DATE), > > yday = yday(DATE), > > md = sprintf("%02d-%02d", month(DATE), mday(DATE)) > > ) %>% > > filter(yday >= start_day & yday <= end_day) %>% > > mutate(md = as.factor(md)) > > > > d_sum <- d %>% > > group_by(md) %>% > > summarize(tmax_mean = mean(TMAX, na.rm=TRUE)) > > > > ## Here's the filtered data: > > dput(d_sum) > > > > > structure(list(md = structure(1:25, levels = c("09-21", "09-22", > > "09-23", "09-24", "09-25", "09-26", "09-27", "09-28", "09-29", > > "09-30", "10-01", "10-02", "10-03", "10-04", "10-05", "10-06", > > "10-07", "10-08", "10-09", "10-10", "10-11", "10-12", "10-13", > > "10-14", "10-15"), class = "factor"), tmax_mean = c(65, > > 62.2, > > 61.3, 63.9, 64.3, 60.1, 62.3, 60.5, 61.9, > > 61.2, 63.7, 59.5, 59.6, 61.6, > > 59.4, 58.8, 55.9, 58.125, > > 58, 55.7, 57, 55.4, 49.8, > > 48.75, 43.7)), class = c("tbl_df", "tbl", "data.frame" > > ), row.names = c(NA, -25L)) > > > > > ggplot(data = d_sum, aes(x = md)) + > > geom_point(aes(y = tmax_mean, color = "blue")) + > > geom_smooth(aes(y = tmax_mean, color = "blue")) > > = > > My questions are: > > 1. Why isn't my geom_smooth plotting? How can I fix it? > > 2. I don't think I'm handling the month and day combination > > correctly. > > Is there a way to encode month and day (but not year) as a date? > > 3. (Minor point) Why does my graph of tmax_mean come out red when I > > specify "blue"? > > > > Thanks for any advice or guidance you can offer. I really > > appreciate > > the expertise of this group. > > > > -Kevin > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > Hello, > > The problem is that the dates are factors, not real dates. And > geom_smooth is not interpolating along a discrete axis (the x axis). > > Paste a fake year with md, coerce to date and plot. > I have simplified the aes() calls and added a date scale in order to > make the x axis more readable. > > Without the formula and method arguments, geom_smooth will print a > message, they are now made explicit. > > > > suppressPackageStartupMessages({ > library(dplyr) > library(ggplot2) > }) > > d_sum %>% > mutate(md = paste("2023", md, sep = "-"), > md = as.Date(md)) %>% > ggplot(aes(x = md, y = tmax_mean)) + > geom_point(color = "blue") + > geom_smooth( > formula = y ~ x, > method = loess, > color = "blue" > ) + > scale_x_date(date_breaks = "7 days", date_labels = "%m-%d") > > > > Hope this helps, > > Rui Barradas > __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with plotting and date-times for climate data
Tim, Richard, y'all are reading too much into this. I believe that TMAX is the high temperature of the day, and TMIN is the low. I'm trying to compute the average or median high and low temperatures for the data I have (2011 to present). I'm going on a trip to this area, and want to know how to pack. Thanks for your interest. -Kevin On Thu, 2023-09-14 at 03:07 +1200, Richard O'Keefe wrote: > I am well aware of the physiological implications > of temperature, and that is *why* I view recorded > TMIN and TMAX at a single point with an extremely > jaundiced eye. TMAX at shoulder height has very > little relevance to an insect living in grass, for > example. And if TMAX is sustained for one second, > that has very different consequences from if TMAX > is sustained for five minutes. I can see the usefulness > of "proportion of day above Thi/below Tlo", but that > is quite different. > > OK, so my interest in weather data was mainly based > around water management: precipitation, evaporation, > herd and crop water needs, that kind of thing. And > the first thing you learn from that experience is > that ANY kind of single-point summary is seriously > misleading. > > Let's end this digression. > > > On Thu, 14 Sept 2023 at 02:18, Ebert,Timothy Aaron > wrote: > > I had the same question. > > However, I can partly answer the off-topic question. Min and max > > can be important as lower and upper development thresholds. Below > > the min no growth or development occur because reaction rates are > > too slow to enable such. Above max, temperatures are too hot. > > Protein function is impaired, and systems stop functioning. There > > is a considerable range between where systems shut down (but > > recover) and tissue death. > > In a simple form the growth and physiological stage of plants, > > insects, and many others, can be modeled as a function of > > temperature. These are often called growing degree day models (or > > some version of that). This is number of thermal units needed for > > the organism to develop to the next stage (e.g. instar for an > > insect, or fruit/flower formation for a plant). However, better > > accuracy is obtained if the model includes both min and max > > thresholds. > > > > All I have done is provide an example where min and max could have > > a real world use. I use max(temp) over some interval and then > > update an accumulated thermal units variable based on the outcome. > > That detail is not evident in the original request. > > > > Tim > > > > -Original Message- > > From: R-help On Behalf Of Richard > > O'Keefe > > Sent: Wednesday, September 13, 2023 9:58 AM > > To: Kevin Zembower > > Cc: r-help@r-project.org > > Subject: Re: [R] Help with plotting and date-times for climate data > > > > [External Email] > > > > Off-topic, but what is a "mean temperature max" > > and what good would it do you to know you if you did? > > I've been looking at a lot of weather station data and for no > > question I've ever had (except "would the newspapers get excited > > about this") was "max" (or min) the answer. Considering the way > > that temperature can change by several degrees in a few minutes, or > > a few metres -- I meant horizontally when I wrote that, but as you > > know your head and feet don't experience the same temperature, > > again by more than one degree -- I am at something of a loss to > > ascribe much practical significance to TMAX. Are you sure this is > > the analysis you want to do? Is this the most informative data you > > can get? > > > > On Wed, 13 Sept 2023 at 08:51, Kevin Zembower via R-help < > > r-help@r-project.org> wrote: > > > > > Hello, > > > > > > I'm trying to calculate the mean temperature max from a file of > > > climate date, and plot it over a range of days in the year. I've > > > downloaded the data, and cleaned it up the way I think it should > > > be. > > > However, when I plot it, the geom_smooth line doesn't show up. I > > > think > > > that's because my x axis is characters or factors. Here's what I > > > have so far: > > > > > > library(tidyverse) > > > > > > data <- read_csv("Ely_MN_Weather.csv") > > > > > > start_day = yday(as_date("2023-09-22")) end_day = > > > yday(as_date("2023-10-15")) > > > > >
Re: [R] Help with plotting and date-times for climate data
I am well aware of the physiological implications of temperature, and that is *why* I view recorded TMIN and TMAX at a single point with an extremely jaundiced eye. TMAX at shoulder height has very little relevance to an insect living in grass, for example. And if TMAX is sustained for one second, that has very different consequences from if TMAX is sustained for five minutes. I can see the usefulness of "proportion of day above Thi/below Tlo", but that is quite different. OK, so my interest in weather data was mainly based around water management: precipitation, evaporation, herd and crop water needs, that kind of thing. And the first thing you learn from that experience is that ANY kind of single-point summary is seriously misleading. Let's end this digression. On Thu, 14 Sept 2023 at 02:18, Ebert,Timothy Aaron wrote: > I had the same question. > However, I can partly answer the off-topic question. Min and max can be > important as lower and upper development thresholds. Below the min no > growth or development occur because reaction rates are too slow to enable > such. Above max, temperatures are too hot. Protein function is impaired, > and systems stop functioning. There is a considerable range between where > systems shut down (but recover) and tissue death. > In a simple form the growth and physiological stage of plants, insects, > and many others, can be modeled as a function of temperature. These are > often called growing degree day models (or some version of that). This is > number of thermal units needed for the organism to develop to the next > stage (e.g. instar for an insect, or fruit/flower formation for a plant). > However, better accuracy is obtained if the model includes both min and max > thresholds. > > All I have done is provide an example where min and max could have a real > world use. I use max(temp) over some interval and then update an > accumulated thermal units variable based on the outcome. That detail is not > evident in the original request. > > Tim > > -Original Message- > From: R-help On Behalf Of Richard O'Keefe > Sent: Wednesday, September 13, 2023 9:58 AM > To: Kevin Zembower > Cc: r-help@r-project.org > Subject: Re: [R] Help with plotting and date-times for climate data > > [External Email] > > Off-topic, but what is a "mean temperature max" > and what good would it do you to know you if you did? > I've been looking at a lot of weather station data and for no question > I've ever had (except "would the newspapers get excited about this") was > "max" (or min) the answer. Considering the way that temperature can change > by several degrees in a few minutes, or a few metres -- I meant > horizontally when I wrote that, but as you know your head and feet don't > experience the same temperature, again by more than one degree -- I am at > something of a loss to ascribe much practical significance to TMAX. Are > you sure this is the analysis you want to do? Is this the most informative > data you can get? > > On Wed, 13 Sept 2023 at 08:51, Kevin Zembower via R-help < > r-help@r-project.org> wrote: > > > Hello, > > > > I'm trying to calculate the mean temperature max from a file of > > climate date, and plot it over a range of days in the year. I've > > downloaded the data, and cleaned it up the way I think it should be. > > However, when I plot it, the geom_smooth line doesn't show up. I think > > that's because my x axis is characters or factors. Here's what I have so > far: > > > > library(tidyverse) > > > > data <- read_csv("Ely_MN_Weather.csv") > > > > start_day = yday(as_date("2023-09-22")) end_day = > > yday(as_date("2023-10-15")) > > > > d <- as_tibble(data) %>% > > select(DATE,TMAX,TMIN) %>% > > mutate(DATE = as_date(DATE), > >yday = yday(DATE), > >md = sprintf("%02d-%02d", month(DATE), mday(DATE)) > >) %>% > > filter(yday >= start_day & yday <= end_day) %>% > > mutate(md = as.factor(md)) > > > > d_sum <- d %>% > > group_by(md) %>% > > summarize(tmax_mean = mean(TMAX, na.rm=TRUE)) > > > > ## Here's the filtered data: > > dput(d_sum) > > > > > structure(list(md = structure(1:25, levels = c("09-21", "09-22", > > "09-23", "09-24", "09-25", "09-26", "09-27", "09-28", "09-29", > > "09-30", "10-01", "10-02", "10-03
Re: [R] Help with plotting and date-times for climate data
I had the same question. However, I can partly answer the off-topic question. Min and max can be important as lower and upper development thresholds. Below the min no growth or development occur because reaction rates are too slow to enable such. Above max, temperatures are too hot. Protein function is impaired, and systems stop functioning. There is a considerable range between where systems shut down (but recover) and tissue death. In a simple form the growth and physiological stage of plants, insects, and many others, can be modeled as a function of temperature. These are often called growing degree day models (or some version of that). This is number of thermal units needed for the organism to develop to the next stage (e.g. instar for an insect, or fruit/flower formation for a plant). However, better accuracy is obtained if the model includes both min and max thresholds. All I have done is provide an example where min and max could have a real world use. I use max(temp) over some interval and then update an accumulated thermal units variable based on the outcome. That detail is not evident in the original request. Tim -Original Message- From: R-help On Behalf Of Richard O'Keefe Sent: Wednesday, September 13, 2023 9:58 AM To: Kevin Zembower Cc: r-help@r-project.org Subject: Re: [R] Help with plotting and date-times for climate data [External Email] Off-topic, but what is a "mean temperature max" and what good would it do you to know you if you did? I've been looking at a lot of weather station data and for no question I've ever had (except "would the newspapers get excited about this") was "max" (or min) the answer. Considering the way that temperature can change by several degrees in a few minutes, or a few metres -- I meant horizontally when I wrote that, but as you know your head and feet don't experience the same temperature, again by more than one degree -- I am at something of a loss to ascribe much practical significance to TMAX. Are you sure this is the analysis you want to do? Is this the most informative data you can get? On Wed, 13 Sept 2023 at 08:51, Kevin Zembower via R-help < r-help@r-project.org> wrote: > Hello, > > I'm trying to calculate the mean temperature max from a file of > climate date, and plot it over a range of days in the year. I've > downloaded the data, and cleaned it up the way I think it should be. > However, when I plot it, the geom_smooth line doesn't show up. I think > that's because my x axis is characters or factors. Here's what I have so far: > > library(tidyverse) > > data <- read_csv("Ely_MN_Weather.csv") > > start_day = yday(as_date("2023-09-22")) end_day = > yday(as_date("2023-10-15")) > > d <- as_tibble(data) %>% > select(DATE,TMAX,TMIN) %>% > mutate(DATE = as_date(DATE), >yday = yday(DATE), >md = sprintf("%02d-%02d", month(DATE), mday(DATE)) >) %>% > filter(yday >= start_day & yday <= end_day) %>% > mutate(md = as.factor(md)) > > d_sum <- d %>% > group_by(md) %>% > summarize(tmax_mean = mean(TMAX, na.rm=TRUE)) > > ## Here's the filtered data: > dput(d_sum) > > > structure(list(md = structure(1:25, levels = c("09-21", "09-22", > "09-23", "09-24", "09-25", "09-26", "09-27", "09-28", "09-29", > "09-30", "10-01", "10-02", "10-03", "10-04", "10-05", "10-06", > "10-07", "10-08", "10-09", "10-10", "10-11", "10-12", "10-13", > "10-14", "10-15"), class = "factor"), tmax_mean = c(65, > 62.2, 61.3, 63.9, 64.3, 60.1, > 62.3, 60.5, 61.9, 61.2, 63.7, 59.5, 59.6, > 61.6, 59.4, 58.8, > 55.9, 58.125, 58, 55.7, 57, 55.4, > 49.8, 48.75, 43.7)), class = c("tbl_df", > "tbl", "data.frame" > ), row.names = c(NA, -25L)) > > > ggplot(data = d_sum, aes(x = md)) + > geom_point(aes(y = tmax_mean, color = "blue")) + > geom_smooth(aes(y = tmax_mean, color = "blue")) > = > My questions are: > 1. Why isn't my geom_smooth plotting? How can I fix it? > 2. I don't think I'm handling the month and day combination correctly. > Is there a way to encode month and day (but not year) as a date? >
Re: [R] Help with plotting and date-times for climate data
Off-topic, but what is a "mean temperature max" and what good would it do you to know you if you did? I've been looking at a lot of weather station data and for no question I've ever had (except "would the newspapers get excited about this") was "max" (or min) the answer. Considering the way that temperature can change by several degrees in a few minutes, or a few metres -- I meant horizontally when I wrote that, but as you know your head and feet don't experience the same temperature, again by more than one degree -- I am at something of a loss to ascribe much practical significance to TMAX. Are you sure this is the analysis you want to do? Is this the most informative data you can get? On Wed, 13 Sept 2023 at 08:51, Kevin Zembower via R-help < r-help@r-project.org> wrote: > Hello, > > I'm trying to calculate the mean temperature max from a file of climate > date, and plot it over a range of days in the year. I've downloaded the > data, and cleaned it up the way I think it should be. However, when I > plot it, the geom_smooth line doesn't show up. I think that's because > my x axis is characters or factors. Here's what I have so far: > > library(tidyverse) > > data <- read_csv("Ely_MN_Weather.csv") > > start_day = yday(as_date("2023-09-22")) > end_day = yday(as_date("2023-10-15")) > > d <- as_tibble(data) %>% > select(DATE,TMAX,TMIN) %>% > mutate(DATE = as_date(DATE), >yday = yday(DATE), >md = sprintf("%02d-%02d", month(DATE), mday(DATE)) >) %>% > filter(yday >= start_day & yday <= end_day) %>% > mutate(md = as.factor(md)) > > d_sum <- d %>% > group_by(md) %>% > summarize(tmax_mean = mean(TMAX, na.rm=TRUE)) > > ## Here's the filtered data: > dput(d_sum) > > > structure(list(md = structure(1:25, levels = c("09-21", "09-22", > "09-23", "09-24", "09-25", "09-26", "09-27", "09-28", "09-29", > "09-30", "10-01", "10-02", "10-03", "10-04", "10-05", "10-06", > "10-07", "10-08", "10-09", "10-10", "10-11", "10-12", "10-13", > "10-14", "10-15"), class = "factor"), tmax_mean = c(65, > 62.2, > 61.3, 63.9, 64.3, 60.1, 62.3, 60.5, 61.9, > 61.2, 63.7, 59.5, 59.6, 61.6, > 59.4, 58.8, 55.9, 58.125, > 58, 55.7, 57, 55.4, 49.8, > 48.75, 43.7)), class = c("tbl_df", "tbl", "data.frame" > ), row.names = c(NA, -25L)) > > > ggplot(data = d_sum, aes(x = md)) + > geom_point(aes(y = tmax_mean, color = "blue")) + > geom_smooth(aes(y = tmax_mean, color = "blue")) > ===== > My questions are: > 1. Why isn't my geom_smooth plotting? How can I fix it? > 2. I don't think I'm handling the month and day combination correctly. > Is there a way to encode month and day (but not year) as a date? > 3. (Minor point) Why does my graph of tmax_mean come out red when I > specify "blue"? > > Thanks for any advice or guidance you can offer. I really appreciate > the expertise of this group. > > -Kevin > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with plotting and date-times for climate data
Às 21:50 de 12/09/2023, Kevin Zembower via R-help escreveu: Hello, I'm trying to calculate the mean temperature max from a file of climate date, and plot it over a range of days in the year. I've downloaded the data, and cleaned it up the way I think it should be. However, when I plot it, the geom_smooth line doesn't show up. I think that's because my x axis is characters or factors. Here's what I have so far: library(tidyverse) data <- read_csv("Ely_MN_Weather.csv") start_day = yday(as_date("2023-09-22")) end_day = yday(as_date("2023-10-15")) d <- as_tibble(data) %>% select(DATE,TMAX,TMIN) %>% mutate(DATE = as_date(DATE), yday = yday(DATE), md = sprintf("%02d-%02d", month(DATE), mday(DATE)) ) %>% filter(yday >= start_day & yday <= end_day) %>% mutate(md = as.factor(md)) d_sum <- d %>% group_by(md) %>% summarize(tmax_mean = mean(TMAX, na.rm=TRUE)) ## Here's the filtered data: dput(d_sum) structure(list(md = structure(1:25, levels = c("09-21", "09-22", "09-23", "09-24", "09-25", "09-26", "09-27", "09-28", "09-29", "09-30", "10-01", "10-02", "10-03", "10-04", "10-05", "10-06", "10-07", "10-08", "10-09", "10-10", "10-11", "10-12", "10-13", "10-14", "10-15"), class = "factor"), tmax_mean = c(65, 62.2, 61.3, 63.9, 64.3, 60.1, 62.3, 60.5, 61.9, 61.2, 63.7, 59.5, 59.6, 61.6, 59.4, 58.8, 55.9, 58.125, 58, 55.7, 57, 55.4, 49.8, 48.75, 43.7)), class = c("tbl_df", "tbl", "data.frame" ), row.names = c(NA, -25L)) ggplot(data = d_sum, aes(x = md)) + geom_point(aes(y = tmax_mean, color = "blue")) + geom_smooth(aes(y = tmax_mean, color = "blue")) = My questions are: 1. Why isn't my geom_smooth plotting? How can I fix it? 2. I don't think I'm handling the month and day combination correctly. Is there a way to encode month and day (but not year) as a date? 3. (Minor point) Why does my graph of tmax_mean come out red when I specify "blue"? Thanks for any advice or guidance you can offer. I really appreciate the expertise of this group. -Kevin __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hello, The problem is that the dates are factors, not real dates. And geom_smooth is not interpolating along a discrete axis (the x axis). Paste a fake year with md, coerce to date and plot. I have simplified the aes() calls and added a date scale in order to make the x axis more readable. Without the formula and method arguments, geom_smooth will print a message, they are now made explicit. suppressPackageStartupMessages({ library(dplyr) library(ggplot2) }) d_sum %>% mutate(md = paste("2023", md, sep = "-"), md = as.Date(md)) %>% ggplot(aes(x = md, y = tmax_mean)) + geom_point(color = "blue") + geom_smooth( formula = y ~ x, method = loess, color = "blue" ) + scale_x_date(date_breaks = "7 days", date_labels = "%m-%d") Hope this helps, Rui Barradas __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with plotting and date-times for climate data
Hello, I'm trying to calculate the mean temperature max from a file of climate date, and plot it over a range of days in the year. I've downloaded the data, and cleaned it up the way I think it should be. However, when I plot it, the geom_smooth line doesn't show up. I think that's because my x axis is characters or factors. Here's what I have so far: library(tidyverse) data <- read_csv("Ely_MN_Weather.csv") start_day = yday(as_date("2023-09-22")) end_day = yday(as_date("2023-10-15")) d <- as_tibble(data) %>% select(DATE,TMAX,TMIN) %>% mutate(DATE = as_date(DATE), yday = yday(DATE), md = sprintf("%02d-%02d", month(DATE), mday(DATE)) ) %>% filter(yday >= start_day & yday <= end_day) %>% mutate(md = as.factor(md)) d_sum <- d %>% group_by(md) %>% summarize(tmax_mean = mean(TMAX, na.rm=TRUE)) ## Here's the filtered data: dput(d_sum) > structure(list(md = structure(1:25, levels = c("09-21", "09-22", "09-23", "09-24", "09-25", "09-26", "09-27", "09-28", "09-29", "09-30", "10-01", "10-02", "10-03", "10-04", "10-05", "10-06", "10-07", "10-08", "10-09", "10-10", "10-11", "10-12", "10-13", "10-14", "10-15"), class = "factor"), tmax_mean = c(65, 62.2, 61.3, 63.9, 64.3, 60.1, 62.3, 60.5, 61.9, 61.2, 63.7, 59.5, 59.6, 61.6, 59.4, 58.8, 55.9, 58.125, 58, 55.7, 57, 55.4, 49.8, 48.75, 43.7)), class = c("tbl_df", "tbl", "data.frame" ), row.names = c(NA, -25L)) > ggplot(data = d_sum, aes(x = md)) + geom_point(aes(y = tmax_mean, color = "blue")) + geom_smooth(aes(y = tmax_mean, color = "blue")) = My questions are: 1. Why isn't my geom_smooth plotting? How can I fix it? 2. I don't think I'm handling the month and day combination correctly. Is there a way to encode month and day (but not year) as a date? 3. (Minor point) Why does my graph of tmax_mean come out red when I specify "blue"? Thanks for any advice or guidance you can offer. I really appreciate the expertise of this group. -Kevin __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help needed with olsrr package
On Thu, 24 Aug 2023 10:56:00 +0530 Ashim Kapoor wrote: > When I open a terminal, type R and run my code, it runs fine. When I > start Emacs, start an inferior R process using ESS, the error comes > back. Thankfully, in both of these cases you get an interactive R session. Compare sessionInfo() outputs. Use traceback(), options(error = recover) and other tricks described in help(browser) and the free book The R Inferno [*] to find out (1) which function is trying to eval(); (2) what is being evaluated (what does predvars contain?), and (3) what do the environments actually contain (what is `data`? what is `env`? Use ls(env) if it's an environment) -- Best regards, Ivan [*] https://www.burns-stat.com/documents/books/the-r-inferno/ ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help needed with olsrr package
I copied your data and ran your code. It worked fine for me. > sessionInfo() R version 4.3.1 (2023-06-16) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 22.04.2 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0 locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C time zone: Asia/Jerusalem tzcode source: system (glibc) attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] olsrr_0.5.3 loaded via a namespace (and not attached): [1] vctrs_0.6.3 cli_3.6.1 rlang_1.1.1 car_3.1-2 generics_0.1.3data.table_1.14.8 glue_1.6.2 colorspace_2.1-0 gridExtra_2.3 [10] scales_1.2.1 fansi_1.0.4 grid_4.3.1 carData_3.0-5 munsell_0.5.0 tibble_3.2.1 abind_1.4-5 lifecycle_1.0.3 compiler_4.3.1 [19] goftest_1.2-3 dplyr_1.1.2 Rcpp_1.0.11 pkgconfig_2.0.3 rstudioapi_0.15.0 nortest_1.0-4 R6_2.5.1 tidyselect_1.2.0 utf8_1.2.3 [28] pillar_1.9.0 magrittr_2.0.3tools_4.3.1 gtable_0.3.3 ggplot2_3.4.2 > HTH, Eric On Tue, Aug 22, 2023 at 7:47 PM Ivan Krylov wrote: > > В Tue, 22 Aug 2023 16:06:22 +0530 > Ashim Kapoor пишет: > > > Error in eval(predvars, data, env) : object 'Var.One' not found > > Use traceback() to find out in which function the error was raised. > This looks like a bug in the olsrr package. Could be due to use of > string manipulation in order to work with formula terms, could be > some other assumption violated by I(10*Var2). > > Try asking at https://github.com/rsquaredacademy/olsrr/issues. > > -- > Best regards, > Ivan > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help needed with olsrr package
В Tue, 22 Aug 2023 16:06:22 +0530 Ashim Kapoor пишет: > Error in eval(predvars, data, env) : object 'Var.One' not found Use traceback() to find out in which function the error was raised. This looks like a bug in the olsrr package. Could be due to use of string manipulation in order to work with formula terms, could be some other assumption violated by I(10*Var2). Try asking at https://github.com/rsquaredacademy/olsrr/issues. -- Best regards, Ivan ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help/documentation on Rgui
Thank you Petr, great! Best, Iago De: PIKAL Petr Enviat: Dilluns, 3-juliol 3e000 2023 9:42 Per a: Iago Gin� V�zquez; r-help@r-project.org Assumpte: RE: Help/documentation on Rgui Hi I am not sure about opening Rgui in terminal but for customising Rgui appearance you can modify Rconsole and Rprofile or Rprofile.site which you should find in etc folder of your R installation. https://stat.ethz.ch/R-manual/R-devel/library/utils/html/Rconsole.html https://rdrr.io/r/utils/Rconsole.html and "Initialization at Start of an R Session" in R help ?Rprofile Cheers Petr > -Original Message----- > From: R-help On Behalf Of Iago Gin� > V�zquez > Sent: Monday, July 3, 2023 8:36 AM > To: r-help@r-project.org > Subject: [R] Help/documentation on Rgui > > Hi all, > > Where can I find a detailed document(ation) on the use of Rgui.exe. The most > detailed I found is https://cran.r-project.org/doc/manuals/r-release/R- > ints.html#GUI-consoles, where there is almost nothing. > > Actually I want to know how to open Rgui.exe (let's say, from a terminal > [mainly in Windows], even better, through the ViM plugin NVim-R) with a set > of specific preferences, like a dark background or specific text colour and size, > which I see I can modify once it is open. > > Thank you for your help. > > Iago > > >[[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help/documentation on Rgui
Hi I am not sure about opening Rgui in terminal but for customising Rgui appearance you can modify Rconsole and Rprofile or Rprofile.site which you should find in etc folder of your R installation. https://stat.ethz.ch/R-manual/R-devel/library/utils/html/Rconsole.html https://rdrr.io/r/utils/Rconsole.html and "Initialization at Start of an R Session" in R help ?Rprofile Cheers Petr > -Original Message----- > From: R-help On Behalf Of Iago Giné > Vázquez > Sent: Monday, July 3, 2023 8:36 AM > To: r-help@r-project.org > Subject: [R] Help/documentation on Rgui > > Hi all, > > Where can I find a detailed document(ation) on the use of Rgui.exe. The most > detailed I found is https://cran.r-project.org/doc/manuals/r-release/R- > ints.html#GUI-consoles, where there is almost nothing. > > Actually I want to know how to open Rgui.exe (let's say, from a terminal > [mainly in Windows], even better, through the ViM plugin NVim-R) with a set > of specific preferences, like a dark background or specific text colour and size, > which I see I can modify once it is open. > > Thank you for your help. > > Iago > > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code. ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help/documentation on Rgui
Hi all, Where can I find a detailed document(ation) on the use of Rgui.exe. The most detailed I found is https://cran.r-project.org/doc/manuals/r-release/R-ints.html#GUI-consoles, where there is almost nothing. Actually I want to know how to open Rgui.exe (let's say, from a terminal [mainly in Windows], even better, through the ViM plugin NVim-R) with a set of specific preferences, like a dark background or specific text colour and size, which I see I can modify once it is open. Thank you for your help. Iago [[alternative HTML version deleted]] ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with regex replacements
Magic! tmp %>% as_tibble() %>% rename(Text = value) %>% mutate(Text = str_replace_all(Text, fixed("."), "")) %>% # filter(row_number() < 4) %>% mutate(Text2 = gsub("((|/)[[:alnum:]]+)|(\\([[:alnum:]-]+\\))", "", Text)) Which (as you have already shown!) gave me this: # A tibble: 7 × 2 Text Text2 1 "Я досяг того, чого хотів" "Я досяг того, чого хотів" 2 "Мені вдалося зробити бажане" "Мені вдалося зробити бажане" 3 "Я досяг (досягла) того, чого хотів (хотіла)" "Я досяг того, чого хотів " 4 "Я досяг(-ла) речей, яких хотілося досягти" "Я досяг речей, яких хотілося досягти" 5 "Я досяг/ла того, чого хотів/ла" "Я досяг того, чого хотів" 6 "Я досяг\\досягла того, чого прагнув\\прагнула" "Я досяг того, чого прагнув" 7 "Я досягнув(ла) того, чого хотів(ла)" "Я досягнув того, чого хотів" perfect and I will spend some time tomorrow unpacking that regex and trying to drive the learning points into my thick skull! Deeply indebted, as so often here though generally only when I'm reading others questions and the answers! Chris On 27/06/2023 20:48, Bert Gunter wrote: OK, so you want parentheses, not "brackets" + I think I misinterpreted your specification, which I think is actually incomplete. Based on what I think you meant, how does this work: gsub("((|/)[[:alnum:]]+)|(\\([[:alnum:]-]+\\))", "",tmp$Text) [1] "Я досяг того, чого хотів" "Мені вдалося\nзробити бажане" [3] "Я досяг того, чого хотів " "Я\nдосяг речей, яких хотілося досягти" [5] "Я досяг того, чого\nхотів" "Я досяг того, чого прагнув" [7] "Я\nдосягнув того, чого хотів" If you want it without the \n's, cat the above to get: cat(gsub("((|/)[[:alnum:]]+)|(\\([[:alnum:]-]+\\))", "",tmp$Text)) Я досяг того, чого хотів Мені вдалося зробити бажане Я досяг того, чого хотів Я досяг речей, яких хотілося досягти Я досяг того, чого хотів Я досяг того, чого прагнув Я досягнув того, чого хотів Cheers, Bert On Tue, Jun 27, 2023 at 11:09 AM Bert Gunter wrote: Does this do it for you (or get you closer): gsub("\\[.*\\]|[] |/ ","",tmp$Text) [1] "Я досяг того, чого хотів" [2] "Мені вдалося\nзробити бажане" [3] "Я досяг (досягла) того, чого хотів (хотіла)" [4] "Я\nдосяг(-ла) речей, яких хотілося досягти" [5] "Я досяг/ла того, чого\nхотів/ла" [6] "Я досяг\\досягла того, чого прагнув\\прагнула" [7] "Я\nдосягнув(ла) того, чого хотів(ла)" On Tue, Jun 27, 2023 at 10:16 AM Chris Evans via R-help wrote: I am sure this is easy for people who are good at regexps but I'm failing with it. The situation is that I have hundreds of lines of Ukrainian translations of some English. They contain things like this: 1"Я досяг того, чого хотів"2"Мені вдалося зробити бажане"3"Я досяг (досягла) того, чого хотів (хотіла)"4"Я досяг(-ла) речей, яких хотілося досягти"5"Я досяг/ла того, чого хотів/ла"6"Я досяг\\досягла того, чого прагнув\\прагнула."7"Я досягнув(ла) того, чого хотів(ла)" Using dput(): tmp <- structure(list(Text = c("Я досяг того, чого хотів", "Мені вдалося зробити бажане", "Я досяг (досягла) того, чого хотів (хотіла)", "Я досяг(-ла) речей, яких хотілося досягти", "Я досяг/ла того, чого хотів/ла", "Я досяг\\досягла того, чого прагнув\\прагнула", "Я досягнув(ла) того, чого хотів(ла)" )), row.names = c(NA, -7L), class = c("tbl_df", "tbl", "data.frame" )) Those show four different ways translators have handled gendered words: 1) Ignore them and (I'm guessing) only give the masculine 2) Give the feminine form of the word (or just the feminine suffix) in brackets 3) Give the feminine form/suffix prefixed by a forward slash 4) Give the feminine form/suffix prefixed by backslash (here a double backslash) I would like just to drop all these feminine gendered options. (Don't worry, they'll get back in later.) So I would like to replace 1) anything between brackets with nothing! 2) anything between a forward slash and the next space with nothing 3) anything between a backslas
Re: [R] Help with regex replacements
OK, so you want parentheses, not "brackets" + I think I misinterpreted your specification, which I think is actually incomplete. Based on what I think you meant, how does this work: gsub("((|/)[[:alnum:]]+)|(\\([[:alnum:]-]+\\))", "",tmp$Text) [1] "Я досяг того, чого хотів" "Мені вдалося\nзробити бажане" [3] "Я досяг того, чого хотів ""Я\nдосяг речей, яких хотілося досягти" [5] "Я досяг того, чого\nхотів" "Я досяг того, чого прагнув" [7] "Я\nдосягнув того, чого хотів" If you want it without the \n's, cat the above to get: cat(gsub("((|/)[[:alnum:]]+)|(\\([[:alnum:]-]+\\))", "",tmp$Text)) Я досяг того, чого хотів Мені вдалося зробити бажане Я досяг того, чого хотів Я досяг речей, яких хотілося досягти Я досяг того, чого хотів Я досяг того, чого прагнув Я досягнув того, чого хотів Cheers, Bert On Tue, Jun 27, 2023 at 11:09 AM Bert Gunter wrote: > Does this do it for you (or get you closer): > > gsub("\\[.*\\]|[] |/ ","",tmp$Text) > [1] "Я досяг того, чого хотів" > [2] "Мені вдалося\nзробити бажане" > [3] "Я досяг (досягла) того, чого хотів (хотіла)" > [4] "Я\nдосяг(-ла) речей, яких хотілося досягти" > [5] "Я досяг/ла того, чого\nхотів/ла" > [6] "Я досяг\\досягла того, чого прагнув\\прагнула" > [7] "Я\nдосягнув(ла) того, чого хотів(ла)" > > On Tue, Jun 27, 2023 at 10:16 AM Chris Evans via R-help < > r-help@r-project.org> wrote: > >> I am sure this is easy for people who are good at regexps but I'm >> failing with it. The situation is that I have hundreds of lines of >> Ukrainian translations of some English. They contain things like this: >> >> 1"Я досяг того, чого хотів"2"Мені вдалося зробити бажане"3"Я досяг >> (досягла) того, чого хотів (хотіла)"4"Я досяг(-ла) речей, яких хотілося >> досягти"5"Я досяг/ла того, чого хотів/ла"6"Я досяг\\досягла того, чого >> прагнув\\прагнула."7"Я досягнув(ла) того, чого хотів(ла)" >> >> Using dput(): >> >> tmp <- structure(list(Text = c("Я досяг того, чого хотів", "Мені вдалося >> зробити бажане", "Я досяг (досягла) того, чого хотів (хотіла)", "Я >> досяг(-ла) речей, яких хотілося досягти", "Я досяг/ла того, чого >> хотів/ла", "Я досяг\\досягла того, чого прагнув\\прагнула", "Я >> досягнув(ла) того, чого хотів(ла)" )), row.names = c(NA, -7L), class = >> c("tbl_df", "tbl", "data.frame" )) Those show four different ways >> translators have handled gendered words: 1) Ignore them and (I'm >> guessing) only give the masculine 2) Give the feminine form of the word >> (or just the feminine suffix) in brackets 3) Give the feminine >> form/suffix prefixed by a forward slash 4) Give the feminine form/suffix >> prefixed by backslash (here a double backslash) I would like just to >> drop all these feminine gendered options. (Don't worry, they'll get back >> in later.) So I would like to replace 1) anything between brackets with >> nothing! 2) anything between a forward slash and the next space with >> nothing 3) anything between a backslash and the next space with nothing >> but preserving the rest of the text. I have been trying to achieve this >> using str_replace_all() but I am failing utterly. Here's a silly little >> example of my failures. This was just trying to get the text I wanted to >> replace (as I was trying to simplify the issues for my tired wetware): > >> tmp %>%+ as_tibble() %>% + rename(Text = value) %>% + mutate(Text = >> str_replace_all(Text, fixed("."), "")) %>% + filter(row_number() < 4) >> %>% + mutate(Text2 = str_replace(Text, "\\(.*\\)", "\\1")) Errorin >> `mutate()`:ℹIn argument: `Text2 = str_replace(Text, "\\(.*\\)", >> "\\1")`.Caused by error in `stri_replace_first_regex()`:!Trying to >> access the index that is out of bounds. (U_INDEX_OUTOFBOUNDS_ERROR) Run >> `rlang::last_trace()` to see where the error occurred. I have tried >> gurgling around the internet but am striking out so throwing myself on >> the list. Apologies if this is trivial but I'd hate to have to clean >> these hundreds of lines by hand though it's starting to look as if I'd >> achieve that faster by hand than I will by banging my ignorance of R >> regexp syntax on the problem. TIA, Chris >> >> -- >> Chris Evans (he
Re: [R] Help with regex replacements
Does this do it for you (or get you closer): gsub("\\[.*\\]|[] |/ ","",tmp$Text) [1] "Я досяг того, чого хотів" [2] "Мені вдалося\nзробити бажане" [3] "Я досяг (досягла) того, чого хотів (хотіла)" [4] "Я\nдосяг(-ла) речей, яких хотілося досягти" [5] "Я досяг/ла того, чого\nхотів/ла" [6] "Я досяг\\досягла того, чого прагнув\\прагнула" [7] "Я\nдосягнув(ла) того, чого хотів(ла)" On Tue, Jun 27, 2023 at 10:16 AM Chris Evans via R-help < r-help@r-project.org> wrote: > I am sure this is easy for people who are good at regexps but I'm > failing with it. The situation is that I have hundreds of lines of > Ukrainian translations of some English. They contain things like this: > > 1"Я досяг того, чого хотів"2"Мені вдалося зробити бажане"3"Я досяг > (досягла) того, чого хотів (хотіла)"4"Я досяг(-ла) речей, яких хотілося > досягти"5"Я досяг/ла того, чого хотів/ла"6"Я досяг\\досягла того, чого > прагнув\\прагнула."7"Я досягнув(ла) того, чого хотів(ла)" > > Using dput(): > > tmp <- structure(list(Text = c("Я досяг того, чого хотів", "Мені вдалося > зробити бажане", "Я досяг (досягла) того, чого хотів (хотіла)", "Я > досяг(-ла) речей, яких хотілося досягти", "Я досяг/ла того, чого > хотів/ла", "Я досяг\\досягла того, чого прагнув\\прагнула", "Я > досягнув(ла) того, чого хотів(ла)" )), row.names = c(NA, -7L), class = > c("tbl_df", "tbl", "data.frame" )) Those show four different ways > translators have handled gendered words: 1) Ignore them and (I'm > guessing) only give the masculine 2) Give the feminine form of the word > (or just the feminine suffix) in brackets 3) Give the feminine > form/suffix prefixed by a forward slash 4) Give the feminine form/suffix > prefixed by backslash (here a double backslash) I would like just to > drop all these feminine gendered options. (Don't worry, they'll get back > in later.) So I would like to replace 1) anything between brackets with > nothing! 2) anything between a forward slash and the next space with > nothing 3) anything between a backslash and the next space with nothing > but preserving the rest of the text. I have been trying to achieve this > using str_replace_all() but I am failing utterly. Here's a silly little > example of my failures. This was just trying to get the text I wanted to > replace (as I was trying to simplify the issues for my tired wetware): > > tmp %>%+ as_tibble() %>% + rename(Text = value) %>% + mutate(Text = > str_replace_all(Text, fixed("."), "")) %>% + filter(row_number() < 4) > %>% + mutate(Text2 = str_replace(Text, "\\(.*\\)", "\\1")) Errorin > `mutate()`:ℹIn argument: `Text2 = str_replace(Text, "\\(.*\\)", > "\\1")`.Caused by error in `stri_replace_first_regex()`:!Trying to > access the index that is out of bounds. (U_INDEX_OUTOFBOUNDS_ERROR) Run > `rlang::last_trace()` to see where the error occurred. I have tried > gurgling around the internet but am striking out so throwing myself on > the list. Apologies if this is trivial but I'd hate to have to clean > these hundreds of lines by hand though it's starting to look as if I'd > achieve that faster by hand than I will by banging my ignorance of R > regexp syntax on the problem. TIA, Chris > > -- > Chris Evans (he/him) > Visiting Professor, UDLA, Quito, Ecuador & Honorary Professor, > University of Roehampton, London, UK. > Work web site: https://www.psyctc.org/psyctc/ > CORE site: http://www.coresystemtrust.org.uk/ > Personal site: https://www.psyctc.org/pelerinage2016/ > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with regex replacements
Thanks Avi (I am a keen follower or your, and other stalwart helpers here). On 27/06/2023 18:27, avi.e.gr...@gmail.com wrote: Chris, Consider breaking up your task into multiple passes. Sorry, I could have explained more of what I had tried. I never know how long to make things here. I had been doing that. My plan was to pick them off, one by one but I think I am banging my head on a fundamental incomprehension on my part. And do them in whatever order preserves what you need. Agree. First, are you talking about brackets as in square brackets, or as in your example, parentheses? Sorry, always get that wrong, parentheses. Mea culpa. If you are sure you have no nested brackets, your requirement seems to be that anything matching [ stuff ] be replaced with nothing. Or if using parentheses, something similar. > 99% sure there are no nested parentheses. However, there are lines with none, one or sometimes (as in the little reprex) more than one set of parentheses. Your issue here is both sets of symbols are special so you must escape them so they are seen as part of the pattern and not the instructions. So, sorry to be stupid but I thought I was doing that using "\(.*\)" Could you reply showing me the correct escaping and the correct replacing? I was using str_replace_all() but happy to use gsub() if that's easier/safer/better. The idea would be to pass through the text once and match all instances on a line and then replace with nothing or whatever is needed. Nothing. But there is no guarantee some of your constructs will be on the same line completely so be wary. Totally agree. I also see that my Emailer (Thunderbird) despite my exhorting it not to, mangled the Email. Have tried to fix that. The mess below should have said: I am sure this is easy for people who are good at regexps but I'm failing with it. The situation is that I have hundreds of lines of Ukrainian translations of some English. They contain things like this: 1"Я досяг того, чого хотів" 2"Мені вдалося зробити бажане" 3"Я досяг (досягла) того, чого хотів (хотіла)" 4"Я досяг(-ла) речей, яких хотілося досягти" 5"Я досяг/ла того, чого хотів/ла" 6"Я досяг\\досягла того, чогопрагнув\\прагнула."7"Я досягнув(ла) того, чого хотів(ла)" Using dput(): tmp <- structure(list(Text = c("Я досяг того, чого хотів", "Мені вдалося зробити бажане", "Я досяг (досягла) того, чого хотів (хотіла)", "Я досяг(-ла) речей, яких хотілося досягти", "Я досяг/ла того, чого хотів/ла", "Я досяг\\досягла того, чого прагнув\\прагнула", "Я досягнув(ла) того, чого хотів(ла)" )), row.names = c(NA, -7L), class = c("tbl_df", "tbl", "data.frame" )) Those show four different ways translators have handled gendered words: 1) Ignore them and (I'm guessing) only give the masculine 2) Give the feminine form of the word (or just the feminine suffix) in brackets 3) Give the feminine form/suffix prefixed by a forward slash 4) Give the feminine form/suffix prefixed by backslash (here a double backslash) I would like just to drop all these feminine gendered options. (Don't worry, they'll get back in later.) So I would like to replace 1) anything between brackets with nothing! 2) anything between a forward slash and the next space with nothing 3) anything between a backslash and the next space with nothing but preserving the rest of the text. I have been trying to achieve this using str_replace_all() but I am failing utterly. Here's a silly little example of my failures. This was just trying to get the text I wanted to replace (as I was trying to simplify the issues for my tired wetware): > tmp %>% + as_tibble() %>% + rename(Text = value) %>% + mutate(Text = str_replace_all(Text, fixed("."), "")) %>% + filter(row_number() < 4) %>% + mutate(Text2 = str_replace(Text, "\\(.*\\)", "\\1")) Error in `mutate()`:ℹIn argument: `Text2 = str_replace(Text, "\\(.*\\)", "\\1")`. Caused by error in `stri_replace_first_regex()`:! Trying to access the index that is out of bounds. (U_INDEX_OUTOFBOUNDS_ERROR) Run `rlang::last_trace()` to see where the error occurred. I have tried gurgling around the internet but am striking out so throwing myself on the list. Apologies if this is trivial but I'd hate to have to clean these hundreds of lines by hand though it's starting to look as if I'd achieve that faster by hand than I will by banging my ignorance of R regexp syntax on the problem. TIA, Chris -Original Message- From: R-help On Behalf Of Chris Evans via R-help Sent: Tuesday, June 27, 2023 1:16 PM To: r-help@r-project.org Subject: [R] Help with regex replacements I am sure this is easy for people who are good at regexps
Re: [R] Help with regex replacements
Chris, Consider breaking up your task into multiple passes. And do them in whatever order preserves what you need. First, are you talking about brackets as in square brackets, or as in your example, parentheses? If you are sure you have no nested brackets, your requirement seems to be that anything matching [ stuff ] be replaced with nothing. Or if using parentheses, something similar. Your issue here is both sets of symbols are special so you must escape them so they are seen as part of the pattern and not the instructions. The idea would be to pass through the text once and match all instances on a line and then replace with nothing or whatever is needed. But there is no guarantee some of your constructs will be on the same line completely so be wary. -Original Message- From: R-help On Behalf Of Chris Evans via R-help Sent: Tuesday, June 27, 2023 1:16 PM To: r-help@r-project.org Subject: [R] Help with regex replacements I am sure this is easy for people who are good at regexps but I'm failing with it. The situation is that I have hundreds of lines of Ukrainian translations of some English. They contain things like this: 1"Я досяг того, чого хотів"2"Мені вдалося зробити бажане"3"Я досяг (досягла) того, чого хотів (хотіла)"4"Я досяг(-ла) речей, яких хотілося досягти"5"Я досяг/ла того, чого хотів/ла"6"Я досяг\\досягла того, чого прагнув\\прагнула."7"Я досягнув(ла) того, чого хотів(ла)" Using dput(): tmp <- structure(list(Text = c("Я досяг того, чого хотів", "Мені вдалося зробити бажане", "Я досяг (досягла) того, чого хотів (хотіла)", "Я досяг(-ла) речей, яких хотілося досягти", "Я досяг/ла того, чого хотів/ла", "Я досяг\\досягла того, чого прагнув\\прагнула", "Я досягнув(ла) того, чого хотів(ла)" )), row.names = c(NA, -7L), class = c("tbl_df", "tbl", "data.frame" )) Those show four different ways translators have handled gendered words: 1) Ignore them and (I'm guessing) only give the masculine 2) Give the feminine form of the word (or just the feminine suffix) in brackets 3) Give the feminine form/suffix prefixed by a forward slash 4) Give the feminine form/suffix prefixed by backslash (here a double backslash) I would like just to drop all these feminine gendered options. (Don't worry, they'll get back in later.) So I would like to replace 1) anything between brackets with nothing! 2) anything between a forward slash and the next space with nothing 3) anything between a backslash and the next space with nothing but preserving the rest of the text. I have been trying to achieve this using str_replace_all() but I am failing utterly. Here's a silly little example of my failures. This was just trying to get the text I wanted to replace (as I was trying to simplify the issues for my tired wetware): > tmp %>%+ as_tibble() %>% + rename(Text = value) %>% + mutate(Text = str_replace_all(Text, fixed("."), "")) %>% + filter(row_number() < 4) %>% + mutate(Text2 = str_replace(Text, "\\(.*\\)", "\\1")) Errorin `mutate()`:ℹIn argument: `Text2 = str_replace(Text, "\\(.*\\)", "\\1")`.Caused by error in `stri_replace_first_regex()`:!Trying to access the index that is out of bounds. (U_INDEX_OUTOFBOUNDS_ERROR) Run `rlang::last_trace()` to see where the error occurred. I have tried gurgling around the internet but am striking out so throwing myself on the list. Apologies if this is trivial but I'd hate to have to clean these hundreds of lines by hand though it's starting to look as if I'd achieve that faster by hand than I will by banging my ignorance of R regexp syntax on the problem. TIA, Chris -- Chris Evans (he/him) Visiting Professor, UDLA, Quito, Ecuador & Honorary Professor, University of Roehampton, London, UK. Work web site: https://www.psyctc.org/psyctc/ CORE site: http://www.coresystemtrust.org.uk/ Personal site: https://www.psyctc.org/pelerinage2016/ __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with regex replacements
I am sure this is easy for people who are good at regexps but I'm failing with it. The situation is that I have hundreds of lines of Ukrainian translations of some English. They contain things like this: 1"Я досяг того, чого хотів"2"Мені вдалося зробити бажане"3"Я досяг (досягла) того, чого хотів (хотіла)"4"Я досяг(-ла) речей, яких хотілося досягти"5"Я досяг/ла того, чого хотів/ла"6"Я досяг\\досягла того, чого прагнув\\прагнула."7"Я досягнув(ла) того, чого хотів(ла)" Using dput(): tmp <- structure(list(Text = c("Я досяг того, чого хотів", "Мені вдалося зробити бажане", "Я досяг (досягла) того, чого хотів (хотіла)", "Я досяг(-ла) речей, яких хотілося досягти", "Я досяг/ла того, чого хотів/ла", "Я досяг\\досягла того, чого прагнув\\прагнула", "Я досягнув(ла) того, чого хотів(ла)" )), row.names = c(NA, -7L), class = c("tbl_df", "tbl", "data.frame" )) Those show four different ways translators have handled gendered words: 1) Ignore them and (I'm guessing) only give the masculine 2) Give the feminine form of the word (or just the feminine suffix) in brackets 3) Give the feminine form/suffix prefixed by a forward slash 4) Give the feminine form/suffix prefixed by backslash (here a double backslash) I would like just to drop all these feminine gendered options. (Don't worry, they'll get back in later.) So I would like to replace 1) anything between brackets with nothing! 2) anything between a forward slash and the next space with nothing 3) anything between a backslash and the next space with nothing but preserving the rest of the text. I have been trying to achieve this using str_replace_all() but I am failing utterly. Here's a silly little example of my failures. This was just trying to get the text I wanted to replace (as I was trying to simplify the issues for my tired wetware): > tmp %>%+ as_tibble() %>% + rename(Text = value) %>% + mutate(Text = str_replace_all(Text, fixed("."), "")) %>% + filter(row_number() < 4) %>% + mutate(Text2 = str_replace(Text, "\\(.*\\)", "\\1")) Errorin `mutate()`:ℹIn argument: `Text2 = str_replace(Text, "\\(.*\\)", "\\1")`.Caused by error in `stri_replace_first_regex()`:!Trying to access the index that is out of bounds. (U_INDEX_OUTOFBOUNDS_ERROR) Run `rlang::last_trace()` to see where the error occurred. I have tried gurgling around the internet but am striking out so throwing myself on the list. Apologies if this is trivial but I'd hate to have to clean these hundreds of lines by hand though it's starting to look as if I'd achieve that faster by hand than I will by banging my ignorance of R regexp syntax on the problem. TIA, Chris -- Chris Evans (he/him) Visiting Professor, UDLA, Quito, Ecuador & Honorary Professor, University of Roehampton, London, UK. Work web site: https://www.psyctc.org/psyctc/ CORE site: http://www.coresystemtrust.org.uk/ Personal site: https://www.psyctc.org/pelerinage2016/ __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help sourcing datasets (.csv)
Another suggestion: The statistics does not care where the numbers come from. The values 1, 2, 3 have a mean of 2 no matter if these are weights of a bird, plant heights, or concrete tensile strength. Your interpretation might change, but the mean is still 2. Try synthetic data. X<-rnorm(1000, mean=4, sd=2) Y<-14+12*X cor(X,Y) That is too simple, but it is the start. Y<- rnorm(1000, mean=14, sd=2) + 12*X cor(X,Y) look at the result in something like ggplot2 Dataf <- data.frame(X,Y) ggplot(Dataf, aes(X, Y)) + geom.point() + stat_smooth(method=lm, se=FALSE) This approach has a few advantages: 1) I know that X and Y are samples from the Gaussian (Normal) distribution. 2) I know that the data are homoscedastic. 3) I can change 1 and 2 in whatever way I want. Possibly useful if you want to understand how violations in model assumptions influence outcomes. 4) I can look closely at the influence of sample size when assumptions are met and when they are not. Note that ANOVA and regression do not assume that the independent or dependent variables are normally distributed. The assumption of Normality is for the error term in the model. However, if both dependent and independent variables are normally distributed then it is likely that the error term will also be normally distributed. What should I get here? Y<- rnorm(1000, mean=14, sd=2) + X*rnorm(1000, mean=12, sd=27) Tim -Original Message----- From: R-help On Behalf Of Uwe Ligges Sent: Friday, June 2, 2023 5:18 AM To: james carrigan ; r-help@r-project.org Subject: Re: [R] Help sourcing datasets (.csv) [External Email] See ?data On 28.05.2023 10:53, james carrigan wrote: > Dear Sir or Madam > I'm trying to compile a collection of datasets that require use of the > following hypothesis tests. > Are there datasets within the R library that I can get access to? > Kind regards > James Carrigan > > Hypothesis Testing > t.test(X,Y) > - performs a two sample t-test between X and Y > t.test(X,Y,paired=TRUE) > - performs a paired t-test between X and Y prop.test(x = c(a, b), n = > c(n1, n2)) - performs a 2-sample test for equality of proportions with > continuity correction > > Sent from my iPad Sent from my iPhone > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat/ > .ethz.ch%2Fmailman%2Flistinfo%2Fr-help&data=05%7C01%7Ctebert%40ufl.edu > %7C5f3292c3315b446b8b9008db634a37cb%7C0d4da0f84a314d76ace60a62331e1b84 > %7C0%7C0%7C638212942641271785%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw > MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sda > ta=s5NqLzxYTlnA1BHldzka%2F2i%2FoefvsLmU%2FDuLJav5mMc%3D&reserved=0 > PLEASE do read the posting guide > http://www.r/ > -project.org%2Fposting-guide.html&data=05%7C01%7Ctebert%40ufl.edu%7C5f > 3292c3315b446b8b9008db634a37cb%7C0d4da0f84a314d76ace60a62331e1b84%7C0% > 7C0%7C638212942641271785%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiL > CJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=xG > MQDNZksGydmnYDLAFjZ%2BEZp4ne%2Bf5JK%2BO9qrH7zeU%3D&reserved=0 > and provide commented, minimal, self-contained, reproducible code. ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help sourcing datasets (.csv)
See ?data On 28.05.2023 10:53, james carrigan wrote: Dear Sir or Madam I’m trying to compile a collection of datasets that require use of the following hypothesis tests. Are there datasets within the R library that I can get access to? Kind regards James Carrigan Hypothesis Testing t.test(X,Y) — performs a two sample t-test between X and Y t.test(X,Y,paired=TRUE) — performs a paired t-test between X and Y prop.test(x = c(a, b), n = c(n1, n2)) — performs a 2-sample test for equality of proportions with continuity correction Sent from my iPad Sent from my iPhone __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help sourcing datasets (.csv)
Dear Sir or Madam I’m trying to compile a collection of datasets that require use of the following hypothesis tests. Are there datasets within the R library that I can get access to? Kind regards James Carrigan Hypothesis Testing t.test(X,Y) — performs a two sample t-test between X and Y t.test(X,Y,paired=TRUE) — performs a paired t-test between X and Y prop.test(x = c(a, b), n = c(n1, n2)) — performs a 2-sample test for equality of proportions with continuity correction Sent from my iPad Sent from my iPhone __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with bootstrap sampling with rms package in R
Hi all, I appreciate any help that can be offered and don’t mind sending a fee to anyone that can help. I am a physician and am writing a paper to be submitted to a medical journal and am performing bootstrap internal validation by the Harrell method using the R package called rms. It’s a multi variable logistic regression model. I have done the 1000 sample bootstrap and generated Dxy which I have converted to AUC. But I also want to illustrate with a histogram of all the 1000 AUC values generated from the training AUC from each bootstrap model. Reaching out for help with this, thanks in advance. Best, Munveer __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug in R-Help Archives?
My apologies, I did not mean to be part of the discussion. If there is such a thing as a pocket email (similar to a pocket dial) the email would be classified as a pocket email. John From: R-help on behalf of Rui Barradas Sent: Friday, January 27, 2023 10:15 AM To: Ivan Krylov Cc: R-help Mailing List Subject: Re: [R] Bug in R-Help Archives? Às 07:36 de 27/01/2023, Ivan Krylov escreveu: > On Fri, 27 Jan 2023 13:01:39 +0530 > Deepayan Sarkar wrote: > >> From looking at the headers in John Sorkin's mail, my guess is that he >> just replied to the other thread rather than starting a fresh email, >> and in his attempts to hide that, was outsmarted by Outlook. > > That's 100% correct. The starting "Pipe operator" e-mail has > In-Reply-To: <047e01d91ed5$577e42a0$067ac7e0$@yahoo.com>, and the > message with this Message-ID is the one from Mukesh Ghanshyamdas > Lekhrajani with the subject "Re: [R] R Certification" that's > immediately above the message by John Sorkin. > Thanks, I was searching the archives for something else, stumbled on that and forgot to look at the heders. Good news there's nothing wrong with R-Help. Rui Barradas __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help&data=05%7C01%7CJSorkin%40som.umaryland.edu%7Ca90bca3f346f470c472808db007a65cd%7C717009a620de461a88940312a395cac9%7C0%7C0%7C638104297929279937%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=8CGlDg%2Fdkx28raPOalXjZ7NqN%2BP%2BoWo9UFL%2Boc6NBRU%3D&reserved=0 PLEASE do read the posting guide https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.html&data=05%7C01%7CJSorkin%40som.umaryland.edu%7Ca90bca3f346f470c472808db007a65cd%7C717009a620de461a88940312a395cac9%7C0%7C0%7C638104297929279937%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=mira%2F3jlC1V3jAJvBiqw53EpaCJknQ1W77NY7jTzfyA%3D&reserved=0 and provide commented, minimal, self-contained, reproducible code. ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug in R-Help Archives?
Às 07:36 de 27/01/2023, Ivan Krylov escreveu: On Fri, 27 Jan 2023 13:01:39 +0530 Deepayan Sarkar wrote: From looking at the headers in John Sorkin's mail, my guess is that he just replied to the other thread rather than starting a fresh email, and in his attempts to hide that, was outsmarted by Outlook. That's 100% correct. The starting "Pipe operator" e-mail has In-Reply-To: <047e01d91ed5$577e42a0$067ac7e0$@yahoo.com>, and the message with this Message-ID is the one from Mukesh Ghanshyamdas Lekhrajani with the subject "Re: [R] R Certification" that's immediately above the message by John Sorkin. Thanks, I was searching the archives for something else, stumbled on that and forgot to look at the heders. Good news there's nothing wrong with R-Help. Rui Barradas ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug in R-Help Archives?
Às 07:31 de 27/01/2023, Deepayan Sarkar escreveu: From looking at the headers in John Sorkin's mail, my guess is that he just replied to the other thread rather than starting a fresh email, and in his attempts to hide that, was outsmarted by Outlook. This is based on references to domains such as yahoo.com, dcn.davis.ca.us, and precheza.cz in the header, which were all involved in the certification thread. -Deepayan On Fri, Jan 27, 2023 at 12:26 PM Rui Barradas wrote: Às 06:39 de 27/01/2023, Rui Barradas escreveu: Hello, When consulting the R-Help Archives today I've noticed that the thread Pipe operator started by John Sorkin, Tue Jan 3 17:48:30 CET 2023 is under another thread, R Certification started by Mukesh Ghanshyamdas Lekhrajani. Isn't this a bug in the filing system? Thanks to the list maintainer Martin Maechler and ETH Zurich for organizing and hosting the list for all of us. It's an invaluable tool that has served so many R users along the years and that surely gives a lot of work organizing and eventual headaches. I hope this is not one of them. Rui Barradas ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Maybe the attached screen capture makes it more clear. Rui Barradas ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Thanks, I had missed that. Rui Barradas ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug in R-Help Archives?
Every email thread (mailing list or not) gets a hidden identifier that is used to identify that thread. It is not that Outlook outsmarted John... any email program would have done the same. John... please don't reply to existing posts with a new subject... many mailing list users may be using the threaded view in their email program and never see your question at all if they were not interested in the original thread. On January 26, 2023 11:31:39 PM PST, Deepayan Sarkar wrote: >From looking at the headers in John Sorkin's mail, my guess is that he >just replied to the other thread rather than starting a fresh email, >and in his attempts to hide that, was outsmarted by Outlook. > >This is based on references to domains such as yahoo.com, >dcn.davis.ca.us, and precheza.cz in the header, which were all >involved in the certification thread. > >-Deepayan > >On Fri, Jan 27, 2023 at 12:26 PM Rui Barradas wrote: >> >> Às 06:39 de 27/01/2023, Rui Barradas escreveu: >> > Hello, >> > >> > When consulting the R-Help Archives today I've noticed that the thread >> > >> > Pipe operator >> > >> > started by John Sorkin, Tue Jan 3 17:48:30 CET 2023 is under another >> > thread, >> > >> > R Certification >> > >> > started by Mukesh Ghanshyamdas Lekhrajani. >> > >> > Isn't this a bug in the filing system? >> > >> > Thanks to the list maintainer Martin Maechler and ETH Zurich for >> > organizing and hosting the list for all of us. It's an invaluable tool >> > that has served so many R users along the years and that surely gives a >> > lot of work organizing and eventual headaches. I hope this is not one of >> > them. >> > >> > Rui Barradas >> > >> > __ >> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> > https://stat.ethz.ch/mailman/listinfo/r-help >> > PLEASE do read the posting guide >> > http://www.R-project.org/posting-guide.html >> > and provide commented, minimal, self-contained, reproducible code. >> >> Maybe the attached screen capture makes it more clear. >> >> Rui Barradas >> >> >> __ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > >______ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. -- Sent from my phone. Please excuse my brevity. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug in R-Help Archives?
On Fri, 27 Jan 2023 13:01:39 +0530 Deepayan Sarkar wrote: > From looking at the headers in John Sorkin's mail, my guess is that he > just replied to the other thread rather than starting a fresh email, > and in his attempts to hide that, was outsmarted by Outlook. That's 100% correct. The starting "Pipe operator" e-mail has In-Reply-To: <047e01d91ed5$577e42a0$067ac7e0$@yahoo.com>, and the message with this Message-ID is the one from Mukesh Ghanshyamdas Lekhrajani with the subject "Re: [R] R Certification" that's immediately above the message by John Sorkin. -- Best regards, Ivan ______ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug in R-Help Archives?
>From looking at the headers in John Sorkin's mail, my guess is that he just replied to the other thread rather than starting a fresh email, and in his attempts to hide that, was outsmarted by Outlook. This is based on references to domains such as yahoo.com, dcn.davis.ca.us, and precheza.cz in the header, which were all involved in the certification thread. -Deepayan On Fri, Jan 27, 2023 at 12:26 PM Rui Barradas wrote: > > Às 06:39 de 27/01/2023, Rui Barradas escreveu: > > Hello, > > > > When consulting the R-Help Archives today I've noticed that the thread > > > > Pipe operator > > > > started by John Sorkin, Tue Jan 3 17:48:30 CET 2023 is under another > > thread, > > > > R Certification > > > > started by Mukesh Ghanshyamdas Lekhrajani. > > > > Isn't this a bug in the filing system? > > > > Thanks to the list maintainer Martin Maechler and ETH Zurich for > > organizing and hosting the list for all of us. It's an invaluable tool > > that has served so many R users along the years and that surely gives a > > lot of work organizing and eventual headaches. I hope this is not one of > > them. > > > > Rui Barradas > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > Maybe the attached screen capture makes it more clear. > > Rui Barradas > > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bug in R-Help Archives?
Às 06:39 de 27/01/2023, Rui Barradas escreveu: Hello, When consulting the R-Help Archives today I've noticed that the thread Pipe operator started by John Sorkin, Tue Jan 3 17:48:30 CET 2023 is under another thread, R Certification started by Mukesh Ghanshyamdas Lekhrajani. Isn't this a bug in the filing system? Thanks to the list maintainer Martin Maechler and ETH Zurich for organizing and hosting the list for all of us. It's an invaluable tool that has served so many R users along the years and that surely gives a lot of work organizing and eventual headaches. I hope this is not one of them. Rui Barradas __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Maybe the attached screen capture makes it more clear. Rui Barradas __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Bug in R-Help Archives?
Hello, When consulting the R-Help Archives today I've noticed that the thread Pipe operator started by John Sorkin, Tue Jan 3 17:48:30 CET 2023 is under another thread, R Certification started by Mukesh Ghanshyamdas Lekhrajani. Isn't this a bug in the filing system? Thanks to the list maintainer Martin Maechler and ETH Zurich for organizing and hosting the list for all of us. It's an invaluable tool that has served so many R users along the years and that surely gives a lot of work organizing and eventual headaches. I hope this is not one of them. Rui Barradas __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with function and survey data
Dear Bert Thank you for your suggestion. I have tried it but it did not work. For record, I am reposting the post with the plain text. library(tidyverse) library(plyr) library(survey) dat <- structure(list( r3a_1 = structure(c(3L, 2L, 3L, 3L, 3L, 3L, 3L,3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("Don't Know", "No", "Yes"), class = "factor"), r3a_2 = structure(c(3L, 3L,3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("Don't Know", "No", "Yes"), class = "factor"), r3a_3 = structure(c(3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L), .Label = c("Don't Know","No", "Yes"), class = "factor"), r3a_4 = structure(c(3L,2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L, 2L, 3L, 2L, 3L, 2L, 2L,3L, 3L, 3L, 1L), .Label = c("Don't Know", "No", "Yes"), class = "factor"), r3a_5 = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 3L, 2L,2L, 3L, 2L, 3L, 3L, 2L, 3L, 2L, 3L, 1L), .Label = c("Don't Know","No", "Yes"), class = "factor"), r3a_6 = structure(c(3L,3L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 3L, 3L, 2L, 2L, 2L, 3L,2L, 3L, 3L, 3L), .Label = c("Don't Know", "No", "Yes"), class = "factor"), r3a_7 = structure(c(1L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L,3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L), .Label = c("Don't Know", "No", "Yes"), class = "factor"), r3a_8 = structure(c(3L,2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 3L, 3L, 2L, 3L, 3L, 2L, 2L, 2L, 3L, 3L), .Label = c("Don't Know", "No", "Yes"), class = "factor"), r3a_9 = structure(c(1L, 3L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 3L,3L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L), .Label = c("Don't Know","No", "Yes"), class = "factor"), weight = c(0.34, 0.34, 0.34,0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.43, 0.43, 0.43, 0.34, 0.34, 0.34, 0.34, 0.34), seg_2 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L,1L, 1L, 1L, 1L), .Label = c("1", "2"), class = "factor"), seg_3 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 1L,1L, 2L, 2L, 2L), .Label = c("1", "2"), class = "factor"), seg_4 = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L,1L, 1L, 1L, 1L), .Label = c("1", "2"), class = "factor")), .Names = c("r3a_1", "r3a_2", "r3a_3", "r3a_4", "r3a_5", "r3a_6", "r3a_7", "r3a_8", "r3a_9", "weight", "seg_2","seg_3","seg_4"), row.names = c(NA, 20L), class = "data.frame") dat_weight <- svydesign(ids = ~1, weights = ~weight, data = dat) my_funca <- function(mk,y){ my_re <- ldply( mk, function(x) svytable(bquote(~ y + .(as.name(x))), dat_weight) %>% as_tibble() %>% dplyr::group_by({{y}}) %>% transmute(!!(as.name(x)), Procent = round(n/sum(n,na.rm = T)*100,2)) %>% pivot_wider(names_from = (as.name(x)), values_from = Procent) ) return(my_re) } my_funca(mk =names(dat)[1:9], y = dat$seg_2) Regards, Vincent Edjabou Mobile: +45 31 95 99 33 linkedin.com/vincent Orcid: -0003-2849-6151 Regards, Vincent Edjabou Mobile: +45 31 95 99 33 linkedin.com/vincent Orcid: -0003-2849-6151 On Mon, Oct 31, 2022 at 5:21 PM Bert Gunter wrote: > > 1. This is a plain text list. Set your email to post in plain text, not html, > which often gets mangled (see below). > > 2. I did not run your example, but try: > my_funca(mk =names(dat)[1:9], y = dat$seg_2) > > ## seg_2 is a component of dat and is not in the environment of the call. I > did not see any data argument that would tell it to look elsewhere, but I am > not familiar with tidy_whatever's nonstandard evaluation conventions. > > -- Bert > > On Mon, Oct 31, 2022 at 8:39 AM Edjabou Vincent wrote: >> >> Dear R-Help >> I am working with complex survey data using the survey package. >> I would like to create a function for the generate multi crosstable. The >> problem is that I am getting error with the following message: >> "Error in eval(predvars, data, env) : object 'y' not found" >> >> Here is the example: >> library(tidyv
Re: [R] Help with function and survey data
1. This is a plain text list. Set your email to post in plain text, not html, which often gets mangled (see below). 2. I did not run your example, but try: my_funca(mk =names(dat)[1:9], y = dat$seg_2) ## seg_2 is a component of dat and is not in the environment of the call. I did not see any data argument that would tell it to look elsewhere, but I am not familiar with tidy_whatever's nonstandard evaluation conventions. -- Bert On Mon, Oct 31, 2022 at 8:39 AM Edjabou Vincent wrote: > Dear R-Help > I am working with complex survey data using the survey package. > I would like to create a function for the generate multi crosstable. The > problem is that I am getting error with the following message: > "Error in eval(predvars, data, env) : object 'y' not found" > > Here is the example: > library(tidyverse) > library(plyr) > library(survey) > > dat <- structure(list( >r3a_1 = structure(c(3L, 2L, 3L, 3L, 3L, 3L, 3L,3L, 3L, 3L, 3L, 2L, 2L, > 3L, 3L, 3L, 3L, 3L, 3L, 3L), > .Label = c("Don't Know", "No", "Yes"), class = "factor"), > r3a_2 = structure(c(3L, 3L,3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, > 3L, 3L, 3L, 3L, 3L, 3L, 3L), > .Label = c("Don't Know", "No", "Yes"), class = > "factor"), > r3a_3 = structure(c(3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, > 2L, 2L, 2L, 2L, 2L, 3L, 3L), > .Label = c("Don't Know","No", "Yes"), class = > "factor"), > r3a_4 = structure(c(3L,2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L, 2L, 3L, 2L, > 3L, 2L, 2L,3L, 3L, 3L, 1L), > .Label = c("Don't Know", "No", "Yes"), class = > "factor"), > r3a_5 = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 3L, 2L,2L, 3L, 2L, > 3L, 3L, 2L, 3L, 2L, 3L, 1L), > .Label = c("Don't Know","No", "Yes"), class = > "factor"), > r3a_6 = structure(c(3L,3L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 3L, 3L, 2L, > 2L, 2L, 3L,2L, 3L, 3L, 3L), > .Label = c("Don't Know", "No", "Yes"), class = > "factor"), > r3a_7 = structure(c(1L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L,3L, 3L, 2L, > 2L, 2L, 2L, 2L, 3L, 3L, 3L), > .Label = c("Don't Know", "No", "Yes"), class = > "factor"), > r3a_8 = structure(c(3L,2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 3L, 3L, 2L, > 3L, 3L, 2L, 2L, 2L, 3L, 3L), > .Label = c("Don't Know", "No", "Yes"), class = > "factor"), > r3a_9 = structure(c(1L, 3L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 3L,3L, 3L, 2L, > 2L, 2L, 3L, 2L, 2L, 3L, 3L), > .Label = c("Don't Know","No", "Yes"), class = > "factor"), > weight = c(0.34, 0.34, 0.34,0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, > 0.34, 0.34, 0.43, 0.43, 0.43, 0.34, 0.34, 0.34, 0.34, 0.34), > seg_2 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, > 1L, 1L, 1L,1L, 1L, 1L, 1L), > .Label = c("1", "2"), class = "factor"), > seg_3 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, > 1L, 1L, 1L,1L, 2L, 2L, 2L), > .Label = c("1", "2"), class = "factor"), > seg_4 = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, > 1L, 1L, 1L,1L, 1L, 1L, 1L), > .Label = c("1", "2"), class = "factor")), > .Names = c("r3a_1", "r3a_2", "r3a_3", "r3a_4", "r3a_5", "r3a_6", "r3a_7", > "r3a_8", "r3a_9", "weight", "seg_2","seg_3","seg_4"), row.names = c(NA, > 20L), class = "data.frame") > > dat_weight <- svydesign(ids = ~1, weights = ~weight, data = dat) > > my_funca <- function(mk,y){ >my_re <- ldply( mk, function(x) > svytable(bquote(~ y + .(as.name(x))), dat_weight) %>% > as_tibble() %>% > dplyr::group_by({{y}}) %>% > transmute(!!(as.name(x)), Procent = round(n/sum(n,na.rm = > T)*100,2)) %>% > pivot_wider(names_from = (as.name(x)), > values_from = Procent) >) >return(my_re) > } > > my_funca(mk =names(dat)[1:9], y = seg_2) > > > I will appreciate any help you will provide. > > > > > Regards, > > Vincent Edjabou > Mobile: +45 31 95 99 33 > linkedin.com/vincent > <http://linkedin.com/in/vincent-maklawe-edjabou-9742a41b> > > Orcid: -0003-2849-6151 > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with function and survey data
Dear R-Help I am working with complex survey data using the survey package. I would like to create a function for the generate multi crosstable. The problem is that I am getting error with the following message: "Error in eval(predvars, data, env) : object 'y' not found" Here is the example: library(tidyverse) library(plyr) library(survey) dat <- structure(list( r3a_1 = structure(c(3L, 2L, 3L, 3L, 3L, 3L, 3L,3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("Don't Know", "No", "Yes"), class = "factor"), r3a_2 = structure(c(3L, 3L,3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("Don't Know", "No", "Yes"), class = "factor"), r3a_3 = structure(c(3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L), .Label = c("Don't Know","No", "Yes"), class = "factor"), r3a_4 = structure(c(3L,2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L, 2L, 3L, 2L, 3L, 2L, 2L,3L, 3L, 3L, 1L), .Label = c("Don't Know", "No", "Yes"), class = "factor"), r3a_5 = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 3L, 2L, 3L, 2L,2L, 3L, 2L, 3L, 3L, 2L, 3L, 2L, 3L, 1L), .Label = c("Don't Know","No", "Yes"), class = "factor"), r3a_6 = structure(c(3L,3L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 3L, 3L, 2L, 2L, 2L, 3L,2L, 3L, 3L, 3L), .Label = c("Don't Know", "No", "Yes"), class = "factor"), r3a_7 = structure(c(1L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 2L,3L, 3L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L), .Label = c("Don't Know", "No", "Yes"), class = "factor"), r3a_8 = structure(c(3L,2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 2L, 3L, 3L, 2L, 3L, 3L, 2L, 2L, 2L, 3L, 3L), .Label = c("Don't Know", "No", "Yes"), class = "factor"), r3a_9 = structure(c(1L, 3L, 2L, 2L, 3L, 2L, 2L, 3L, 3L, 3L,3L, 3L, 2L, 2L, 2L, 3L, 2L, 2L, 3L, 3L), .Label = c("Don't Know","No", "Yes"), class = "factor"), weight = c(0.34, 0.34, 0.34,0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.43, 0.43, 0.43, 0.34, 0.34, 0.34, 0.34, 0.34), seg_2 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L,1L, 1L, 1L, 1L), .Label = c("1", "2"), class = "factor"), seg_3 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 1L,1L, 2L, 2L, 2L), .Label = c("1", "2"), class = "factor"), seg_4 = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L,1L, 1L, 1L, 1L), .Label = c("1", "2"), class = "factor")), .Names = c("r3a_1", "r3a_2", "r3a_3", "r3a_4", "r3a_5", "r3a_6", "r3a_7", "r3a_8", "r3a_9", "weight", "seg_2","seg_3","seg_4"), row.names = c(NA, 20L), class = "data.frame") dat_weight <- svydesign(ids = ~1, weights = ~weight, data = dat) my_funca <- function(mk,y){ my_re <- ldply( mk, function(x) svytable(bquote(~ y + .(as.name(x))), dat_weight) %>% as_tibble() %>% dplyr::group_by({{y}}) %>% transmute(!!(as.name(x)), Procent = round(n/sum(n,na.rm = T)*100,2)) %>% pivot_wider(names_from = (as.name(x)), values_from = Procent) ) return(my_re) } my_funca(mk =names(dat)[1:9], y = seg_2) I will appreciate any help you will provide. Regards, Vincent Edjabou Mobile: +45 31 95 99 33 linkedin.com/vincent <http://linkedin.com/in/vincent-maklawe-edjabou-9742a41b> Orcid: -0003-2849-6151 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R-help Digest, Vol 236, Issue 25
Paul wrote: " Is there any package besides fitdistrplus that does allow automatic distribution fitting?" Automatic distribution fitting can be done using Minitab. Minitab will try and fit your dataset against 14 distributions. It has the option of using a Box-Cox or a Johnson methods to transform the dataset into a normal distribution. I suspect that this is as close as you can get to an automatic distribution fitting. Hope this helps! Thomas Subia -Original Message----- From: R-help On Behalf Of r-help-requ...@r-project.org Sent: Thursday, October 27, 2022 3:00 AM To: r-help@r-project.org Subject: R-help Digest, Vol 236, Issue 25 Send R-help mailing list submissions to r-help@r-project.org To subscribe or unsubscribe via the World Wide Web, visit https://urldefense.com/v3/__https://stat.ethz.ch/mailman/listinfo/r-help__;!!NX4bS6ECB6Pv!58HVkevfq5zfBsZ-2SRH07K3Plt5jMiaOZESF0m5ISL6OEQ6tVLVvrxTtICUro1_0hb0FfINk_O3DRlbb69V3tZbX1blniVg28s$ or, via email, send a message with subject or body 'help' to r-help-requ...@r-project.org You can reach the person managing the list at r-help-ow...@r-project.org When replying, please edit your Subject line so it is more specific than "Re: Contents of R-help digest..." Today's Topics: 1. Re: unexpected 'else' in " else" (Richard O'Keefe) 2. Function for Distribution Fitting (Paul Bernal) 3. Re: Function for Distribution Fitting (JRG) 4. Re: Function for Distribution Fitting (Bert Gunter) 5. Re: Function for Distribution Fitting (Gabor Grothendieck) 6. compile report error (=?UTF-8?Q?G=C3=A1bor_Malomsoki?=) 7. Re: compile report error (Rui Barradas) 8. Re: Function for Distribution Fitting (Ebert,Timothy Aaron) 9. Re: compile report error (=?UTF-8?Q?G=C3=A1bor_Malomsoki?=) 10. Best place to ask questions about non-R Base topics, ex. dplyr, dbplyr, etc. ? (Kelly Thompson) 11. Re: Best place to ask questions about non-R Base topics, ex. dplyr, dbplyr, etc. ? (Jeff Newmiller) 12. Re: compile report error (=?UTF-8?Q?G=C3=A1bor_Malomsoki?=) 13. Re: Best place to ask questions about non-R Base topics, ex. dplyr, dbplyr, etc. ? (Eric Berger) 14. Re: compile report error (Rui Barradas) 15. Color Nodes (Jeff Reichman) 16. Re: Color Nodes (Rui Barradas) 17. Re: Color Nodes (Jeff Reichman) 18. R-package imputeTS / warning messages (Paulo Barata) 19. Re: Color Nodes (Eric Berger) -- Message: 1 Date: Wed, 26 Oct 2022 23:03:30 +1300 From: "Richard O'Keefe" To: Jinsong Zhao Cc: "r-help@r-project.org" Subject: Re: [R] unexpected 'else' in " else" Message-ID: Content-Type: text/plain; charset="utf-8" This is explained in books about S and R. The first place to look is of course > ?"if" which says Note that it is a common mistake to forget to put braces ('{ .. }') around your statements, e.g., after 'if(..)' or 'for()'. In particular, you should not have a newline between '}' and 'else' to avoid a syntax error in entering a 'if ... else' construct at the keyboard or via 'source'. For that reason, one (somewhat extreme) attitude of defensive programming is to always use braces, e.g., for 'if' clauses. The basic issue is that the top level wants to get started on your command AS SOON AS IT HAS A COMPLETE COMMAND, and if (...) stmt is complete. It's not going to hang around "Waiting for Godot" for an 'else' that might never ever ever turn up. So if (x < y) z <- x else z <- y is absolutely fine, no braces needed, while if (x < y) z <- x else z <- y will see the eager top level rush off to do your bidding at the end of the first line and then be completely baffled by an 'else' where it does not expect one. It's the same reason that you break AFTER infix operators instead of BEFORE. x <- y + z works fine, while x <- y + z doesn't. On Fri, 21 Oct 2022 at 22:29, Jinsong Zhao wrote: > Hi there, > > The following code would cause R error: > > > w <- 1:5 > > r <- 1:5 > > if (is.matrix(r)) > + r[w != 0, , drop = FALSE] > > else r[w != 0] > Error: unexpected 'else' in "else" > > However, the code: > if (is.matrix(r)) > r[w != 0, , drop = FALSE] > else r[w != 0] > is extracted from stats::weighted.residuals. > > My question is why the code in the function does not cause error? > > Best, > Jinsong > > __ > R-help@r-project.
Re: [R] Help installing devtools plus other packages in R terminal
On Wed, 5 Oct 2022 20:02:02 + "Rhon Calderon, Eric" wrote: > automake found. Running autoupdate and autogen.sh. <...> > + libtoolize --copy > autogen.sh: line 43: libtoolize: command not found Since you have automake installed, you also need libtool <https://www.gnu.org/software/libtool/> installed in order to compile this particular package from source. Depending on the HPC, there may be a particular command to "activate" the installation already made by the HPC administrator. I guess you could also report this as a bug in devtools: they check for automake but not libtool. If you can temporarily chmod -x automake, the installation should succeed too, because then the package will not try to regenerate its build system. I don't see why they even try to do that, but maybe that's a workaround for some kind of compatibility problem. > CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh > '/tmp/RtmpMjF6Ns/R.INSTALL4a3cb2204b0da/httpuv/src/libuv/missing' > aclocal-1.16 -I m4 > /tmp/RtmpMjF6Ns/R.INSTALL4a3cb2204b0da/httpuv/src/libuv/missing: line > 81: aclocal-1.16: command not found Make sure your automake installation is working. I think the error is caused by the previous error and may go away once you install libtool, but I may be mistaken regarding that. Do Bioconductor packages really depend on devtools? What do their errors look like? -- Best regards, Ivan __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.