Re: [R] R code for overlapping variables -- count

2024-06-02 Thread Rui Barradas
Às 18:40 de 02/06/2024, Rui Barradas escreveu: Às 18:34 de 02/06/2024, Leo Mada via R-help escreveu: Dear Shadee, If you have a data.frame with the following columns: n = 100; # population size x = data.frame(   Sex = sample(c("M","F"), n, T),   Country = sample(c(

Re: [R] R code for overlapping variables -- count

2024-06-02 Thread Rui Barradas
mented, minimal, self-contained, reproducible code. Hello, The following is simpler. r2 <- xtabs(~ ., x) |> as.data.frame() r2[-4L] # or r2[names(r2) != "Freq"] Hope this helps, Rui Barradas -- Este e-mail foi analisado pelo software antivírus AVG para verificar a presença de ví

Re: [R] add only the 1st of May with POSIXct

2024-05-29 Thread Rui Barradas
- Italy Meteo Section Snow Section Via del Colle Ameno 5 60126 Torrette di Ancona, Ancona (AN) Uff: +39 071 806 7743 E-mail: stefano.so...@regione.marche.it ---Oo-oO ____ Da: Rui Barradas Inviato: martedì 28 magg

Re: [R] add only the 1st of May with POSIXct

2024-05-28 Thread Rui Barradas
rs years <- Reduce(`:`, years) # coerce to "Date" from <- ISOdate(years, 5L, 2L, tz = "Etc/GMT-1") to <- ISOdate(years, 10L, 30L, tz = "Etc/GMT-1") # this logical index keeps only the dates between May, 2nd and Nov 1st. keep <- data.frame(from, to) |

Re: [R] Print date on y axis with month, day, and year

2024-05-10 Thread Rui Barradas
of the format = "%m-%d-%Y" argument. Let scale_x_date take care of formating the date as you want it displayed. Any of the two below is a valid date format. ggplot(data = yyy[1:30,], aes(jdate, Sum)) + geom_point() + # scale_x_date(date_labels = "%b %d, %Y") scale_x_d

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-21 Thread Rui Barradas
Às 09:08 de 21/04/2024, Rui Barradas escreveu: Às 08:55 de 21/04/2024, Hans W escreveu: As we all know, in R indices for vectors start with 1, i.e, x[0] is not a correct expression. Some algorithms, e.g. in graph theory or combinatorics, are much easier to formulate and code if 0 is an allowed

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-21 Thread Rui Barradas
i + 1L NextMethod() } as_zerobased <- function(x) { class(x) <- c("zerobased", class(x)) x } x <- 1:10 y <- as_zerobased(x) y[0] #> [1] 1 y[1] #> [1] 2 y[9] #> [1] 10 y[10] #> [1] NA Hope this helps, Rui Barradas -- Este e-mail foi analisado pelo software

Re: [R] Exceptional slowness with read.csv

2024-04-10 Thread Rui Barradas
) |> which() data.frame(Col = i, Unbalanced = Unbalanced) }) |> do.call(rbind, args = _) } # read the data disregardin g quoted strings df1 <- read.csv(fl, quote = "") # determine which strings have unbalanced quotes and # where unbalanced_dquotes(df1)

Re: [R] Exceptional slowness with read.csv

2024-04-08 Thread Rui Barradas
the most serious problem here. Hoep 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

Re: [R] Question regarding reservoir volume and water level

2024-04-07 Thread Rui Barradas
lt;- 14e6 water_level(l = lev) #> [1] 7056452 water_level(v = vol) #> [1] 2480 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 --

Re: [R] Output of tapply function as data frame: Problem Fixed

2024-03-28 Thread Rui Barradas
# note that the row names are still tapply's names vector # and that the columns order is not Date/count. Both are fixed # after the calculations. res You can see that the error message is on the pipe. Please, let me know where I am missing it. Thanks. On Wed, Mar 27, 2024 at 10:45 PM Rui Barradas wrote: Às 0

Re: [R] Output of tapply function as data frame: Problem Fixed

2024-03-27 Thread Rui Barradas
regards from Ogbos On Wed, Mar 27, 2024 at 8:44 AM Rui Barradas wrote: Às 04:30 de 27/03/2024, Ogbos Okike escreveu: Warm greetings to you all. Using the tapply function below: data<-read.table("FD1month",col.names = c("Dates","count")) x=data$count f<-factor(d

Re: [R] Output of tapply function as data frame

2024-03-27 Thread Rui Barradas
00 #> 4 2024-03-25 4.476190 #> 5 2024-03-26 6.538462 #> 6 2024-03-27 5.20 Also, I'm glad to help as always but Ogbos, you have been an R-Help contributor for quite a while, please post data in dput format. Given the problem the output of the following is more than enough. dput(h

Re: [R] Problem with R coding

2024-03-12 Thread Rui Barradas
at Windows can find R.exe and Rgui.exe without the full path name. 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 UNSUB

Re: [R] help - Package: stats - function ar.ols

2024-02-23 Thread Rui Barradas
sting-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 anti

Re: [R] Looping

2024-02-18 Thread Rui Barradas
ec <- sprintf("data%d.csv", 1:24) data_list <- sapply(file_names_vec, read.csv, simplify = FALSE) # access the 1st data.frame data_list[[1L]] # same as above data_list[["data1.csv"]] # same as above data_list$data1.csv Hope this helps, Rui Barradas -- Este e-mail f

Re: [R] Packages sometimes don't update, but no error or warning is thrown

2024-02-14 Thread Rui Barradas
st -- 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, From within RStudio you can always run the qualified names

Re: [R] Packages sometimes don't update, but no error or warning is thrown

2024-02-13 Thread Rui Barradas
from whithin RStudio I close RStudio, write a script with the install.packages() call and run it from a command window. R -q -f "instscript.R" This many times works better and it also works with Bioconductor's BiocManager::install or with remotes'/devtools's install_github. Hope

Re: [R] gathering denominator under frac

2024-02-02 Thread Rui Barradas
Sepal.Length, Sepal.Width, color = Species)) + geom_point() g + ylab(expression(paste(frac( additive~HCO[3]^"-", true~HCO[3]^"-" 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

Re: [R] Need help testing a problem

2024-02-01 Thread Rui Barradas
d this stranger, a call like the following is expected. tryCatch(stop("error"), error = function(e) e) |> str() List of 2 $ message: chr "error" $ call : language doTryCatch(return(expr), name, parentenv, handler) - attr(*, "class")= chr [1:3] "simpl

Re: [R] ggplot 3-dimensions

2023-12-17 Thread Rui Barradas
theme( panel.spacing = unit(0, "lines"), strip.background = element_blank(), strip.placement = "outside", # this line was added by me, remove if not wanted strip.text.x.bottom = element_text(face = "bold", size = 10), axis.title.x = e

Re: [R] ggplot2: Get the regression line with 95% confidence bands

2023-12-12 Thread Rui Barradas
d 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 w

Re: [R] ggplot2: Get the regression line with 95% confidence bands

2023-12-10 Thread Rui Barradas
ot;lm", formula = y ~ x) + labs( title = "Standard linear regression for France", x = "Year", y = "PISA score in mathematics" ) + ylim(470, 500) #> Warning message: #> In max(ids, na.rm = TRUE) : no non-missing arguments to max; returning -In

Re: [R] Convert character date time to R date-time variable.

2023-12-07 Thread Rui Barradas
Às 16:30 de 07/12/2023, Rui Barradas escreveu: Às 16:21 de 07/12/2023, Sorkin, John escreveu: Colleagues, I have a matrix of character data that represents date and time. The format of each element of the matrix is "2020-09-17_00:00:00" How can I convert the elements into a valid R

Re: [R] Convert character date time to R date-time variable.

2023-12-07 Thread Rui Barradas
as.POSIXct Don't forget the underscore in the format. as.POSIXct("2020-09-17_00:00:00", format = "%Y-%m-%d_%H:%M:%S") 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 __

Re: [R] Mann Kendall mutation package?

2023-12-01 Thread Rui Barradas
ct.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hello, Your link points to a GitHub repository, the package can be installed with devtools::install_github(repo = "Sibada/sibadaR") Hope this helps Rui Barradas -- Este e-mail foi analisa

Re: [R] back tick names with predict function

2023-11-30 Thread Rui Barradas
Às 17:57 de 30/11/2023, Rui Barradas escreveu: Às 17:38 de 30/11/2023, Robert Baer escreveu: I am having trouble using back ticks with the R extractor function 'predict' and an lm() model.  I'm trying too construct some nice vectors that can be used for plotting the two types of regression

Re: [R] back tick names with predict function

2023-11-30 Thread Rui Barradas
ddle dataframe arguement CI.p = predict(mod2, newdata = newd, interval = 'prediction')# fail 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-proje

Re: [R] ggplot with two x-axis and two dimensions

2023-11-25 Thread Rui Barradas
u", "Neu", "Neu", "Neu", "Neu", "Neu", "Neu", "Neu", "Neu", "Neu", "Neu", "Pos", "Pos", "Pos", "Pos", "Pos", "Pos&q

Re: [R] Fast way to draw mean values and 95% confidence intervals of groups with ggplot2

2023-11-16 Thread Rui Barradas
se_D, ymax = mean_D + se_D), fill = "grey", alpha = 0.5) + geom_line(aes(y = mean_D, color = C)) + geom_point(aes(y = D, color = C)) + scale_color_manual(name = "Concentration", values = clrs) Hope this helps, Rui Barradas -- Este e-mail foi analisado

Re: [R] anyone having trouble accesing CRAN?

2023-11-15 Thread Rui Barradas
code. Hello, Yes, CRAN is down. I know last week there was an anouncement about a maintenance scheduled but I cannot place that e-mail right now and don't remember the date exactly so I cannot say for sure this is what is happening. But it is probably a scheduled maintenance. Rui Barradas

Re: [R] Cryptic error for mscmt function

2023-11-06 Thread Rui Barradas
R file, rename it .txt? See [1], section General Instructions for more on this [1] https://www.r-project.org/mail.html#instructions Hope this helps, Rui Barradas -- Este e-mail foi analisado pelo software antivírus AVG para verificar a presença de víru

Re: [R] Sum data according to date in sequence

2023-11-04 Thread Rui Barradas
e". Then the grouped sums are computed. suppressPackageStartupMessages( library(dplyr) ) dt1 %>% mutate(date = as.Date(date, "%m/%d/%Y")) %>% summarise(EnergykWh = sum(EnergykWh), .by = date) #> date EnergykWh #> 1 2016-01-14 11.98569 #> 2 2016-01-

Re: [R] Missing shapes in legend with scale_shape_manual

2023-10-31 Thread Rui Barradas
ntercept = 130) + scale_y_continuous( name = "Blood glucose (mg/dL)", breaks = seq(100, 230, by = 20) ) + scale_shape_manual( #name = "Conditions", labels = c("Missed meds", "Missed exercise"), values = c(20, 4), na.translate = FALSE

Re: [R] How to Reformat a dataframe

2023-10-28 Thread Rui Barradas
5091 # keep the rows with values not NA df_long <- df_long[complete.cases(df_long), , drop = FALSE] # check the dimensions again dim(df_long) # [1] 15091 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

Re: [R] Plot for 10 years extrapolation

2023-10-27 Thread Rui Barradas
, dfuture # , lty = "dashed" , lwd=2 , col = "black") # if lines() is used for both the interpolated and extrapolated # values you will have a gap between both fitted and predicted lines # but it is closer to what you want # get the fitted values first (interpo

Re: [R] Bug in print for data frames?

2023-10-26 Thread Rui Barradas
th only one row. But that is a very special case, the general case would be to extract the column. Hope this helps, Rui Barradas If you have another row in your x, say: x <- data.frame(A=c(1,4), B=c(2,5), C=c(3,6)) then your code x$C <- y[1] returns an error. If y has the same number of rows as x

Re: [R] Bug in print for data frames?

2023-10-26 Thread Rui Barradas
nce, avoids repeated calls to ncol nc <- ncol(agg) cbind(agg[-nc], agg[[nc]]) #> A MeanS #> 1 a 14.5 9.082951 #> 2 b 15.5 9.082951 #> 3 c 16.5 9.082951 # all is well cbind(agg[-nc], agg[[nc]]) |> str() #> 'data.frame':3 obs. of 3 variables: #> $ A : c

Re: [R] by function does not separate output from function with mulliple parts

2023-10-25 Thread Rui Barradas
g) #> mydata$StepType: First #> lm model parameter contrast #> #> Contrast S.E.LowerUppert df Pr(>|t|) #> 1 2.99114 1.956013 -1.05518 7.037461 1.53 23 0.1399 #> #> mydata$StepType: Second #> lm model parameter contrast #> #&g

Re: [R] running crossvalidation many times MSE for Lasso regression

2023-10-24 Thread Rui Barradas
ct.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.o

Re: [R] Best way to test for numeric digits?

2023-10-18 Thread Rui Barradas
Às 19:35 de 18/10/2023, Leonard Mada escreveu: Dear Rui, On 10/18/2023 8:45 PM, Rui Barradas wrote: split_chem_elements <- function(x, rm.digits = TRUE) {   regex <- "(?<=[A-Z])(?![a-z]|$)|(?<=.)(?=[A-Z])|(?<=[a-z])(?=[^a-z])"   if(rm.digits) {     stringr::s

Re: [R] Best way to test for numeric digits?

2023-10-18 Thread Rui Barradas
about the workaround). Q: My question focused if there is anything like is.numeric, but to parse each element of a vector. Sincerely, Leonard On 10/18/2023 6:53 PM, Rui Barradas wrote: Às 15:59 de 18/10/2023, Leonard Mada via R-help escreveu: Dear List members, What is the best way to test

Re: [R] Best way to test for numeric digits?

2023-10-18 Thread Rui Barradas
"CCl2CO2AlPO4SiO4Cl") split_chem_elements(mol) #> [[1]] #> [1] "C" "Cl" "F" #> #> [[2]] #> [1] "Li" "Al" "H" #> #> [[3]] #> [1] "C" "Cl" "C" "O" "Al&q

Re: [R] creating a time series

2023-10-16 Thread Rui Barradas
Hello, Given your date format, try format = "%d.%m.%Y %H:%M" Test with your date time: x <- "2.11.2017 13:30" as.POSIXct(x, format = "%d.%m.%Y %H:%M") #> [1] "2017-11-02 13:30:00 WET" as.POSIXct(su_seviyeleri_data$kayit_zaman, format = "%d.%m.%Y %

Re: [R] if-else that returns vector

2023-10-12 Thread Rui Barradas
like it but ifelse(rep(T, length(c(1,2,3))), c(1,2,3), c(5,6)) maybe you should use max(length(c(1, 2, 3)), length(5, 6))) instead, but it's still ugly. 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

Re: [R] Text showing when R is launched

2023-10-11 Thread Rui Barradas
e were a couple of R files in there which I have since deleted but I am still getting the same issue Thankyou, George From: Rui Barradas Sent: 10 October 2023 12:06 To: George Loftus ; r-help@r-project.org Subject: Re: [R] Text showing when R is launched Às 23:56

Re: [R] Text showing when R is launched

2023-10-10 Thread Rui Barradas
, reproducible code. Hello, Try deleting file /Users/admin/.RData It is restoring the previous session and this is many times a source for problems. 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

Re: [R] Is it possible to get a downward pointing solid triangle plotting symbol in R?

2023-10-06 Thread Rui Barradas
Às 10:09 de 06/10/2023, Chris Evans via R-help escreveu: The reason I am asking is that I would like to mark areas on a plot using geom_polygon() and aes(fill = variable) to fill various polygons forming the background of a plot with different colours. Then I would like to overlay that with

Re: [R] R issue / No buffer space available

2023-10-05 Thread Rui Barradas
.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hello, RStudio is an IDE for R, not R itself. That is a RStudio error and RStudio technical support [1] is better suited to solve your problem. [1] https://community.rstudio.com/ Hope this helps, Rui Barr

Re: [R] annotate

2023-10-05 Thread Rui Barradas
aes(x = eruptions, y = waiting, label = waiting), vjust = -1 ) + theme_cowplot() 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 mai

Re: [R] Jim Lemon RIP

2023-10-04 Thread Rui Barradas
My sympathies for your loss. Jim Lemon was a dedicated contributor to the R community and his answers were always welcome. Jim will be missed. Rui Barradas Às 23:36 de 04/10/2023, Jim Lemon escreveu: Hello, I am very sad to let you know that my husband Jim died on 18th September. I

Re: [R] Grouping by Date and showing count of failures by date

2023-09-30 Thread Rui Barradas
s with calls to library() when using non-base functionality. 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 mor

Re: [R] predict function type class vs. prob

2023-09-23 Thread Rui Barradas
t) 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, min

Re: [R] Hadamard transformation

2023-09-18 Thread Rui Barradas
matrix(1, 4, 4) z <- lower.tri(diag(4), TRUE) z[] <- apply(z, 2, as.integer) H(x) H(y) H(z) 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 rea

Re: [R] Help with plotting and date-times for climate data

2023-09-12 Thread Rui Barradas
le. 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)) %>

Re: [R] graph in R with grouping letters from the turkey test with agricolae package

2023-09-12 Thread Rui Barradas
graphs, only data. Can you post the code have you tried? 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

Re: [R] prop.trend.test

2023-09-08 Thread Rui Barradas
lue of prop.trend.test, makes it easier for the users to determine the existence of trending and its direction. If there are any other ways to do this, please let me know. Thomas Subia On Thursday, September 7, 2023 at 10:31:27 AM PDT, Rui Barradas wrote: Às 14:23 de 07/09

Re: [R] prop.trend.test

2023-09-07 Thread Rui Barradas
rs, patients)$estimate #>prop 1prop 2prop 3prop 4 #> 0.9651163 0.9677419 0.9485294 0.8536585 smokers/patients #> [1] 0.9651163 0.9677419 0.9485294 0.8536585 plot(smokers/patients, type = "b") Hope this helps, Rui Barradas

Re: [R] Regarding error in RStudio

2023-09-05 Thread Rui Barradas
RStudio questions to the RStudio support service, they answer quickly and the answers are generally good. It's written at the bottom of the attached image that the workspace was loaded from file C:/WSI/.RData Close RStudio, remove this file and restart. See if it solved it. Hope this he

Re: [R] Merge and replace data

2023-09-05 Thread Rui Barradas
replaced by the value in the column which is non zero.. I tried append and merge but fail to get what I want. Hello, That's a case for ?pmax: x1 <- c(116,0,115,137,127,0,0) x2 <- c(0,159,0,0,0,159,127) pmax(x1, x2) #> [1] 116 159 115 137 127 159 127 Hope this he

Re: [R] aggregate formula - differing results

2023-09-04 Thread Rui Barradas
differently, even though they all use mean(na.rm = TRUE) to calculate the group stats. Best wishes, Ivan On 04/09/2023 13:46, Rui Barradas wrote: Às 10:44 de 04/09/2023, Ivan Calandra escreveu: Dear useRs, I have just stumbled across a behavior in aggregate() that I cannot explain. Any help

Re: [R] aggregate formula - differing results

2023-09-04 Thread Rui Barradas
s of the other numeric columns, just of those two. # define a vector of columns of interest cols <- c("Length", "Width", "RAWMAT") # 1) Simple aggregation with 2 variables, select cols: aggregate(cbind(Length, Width) ~ RAWMAT, data = my_data[cols], FUN = me

Re: [R] Error in analysis of Rasch using eRm package.

2023-08-22 Thread Rui Barradas
, It seems that you have data that in tabular form is one column per answer, so you would end up with 30 columns, maybe an extra id column. Can you post sample data? If not, make up the answers and post the answers of the first 6 individuals or so. Hope this helps, Rui Barradas

Re: [R] Questions about R

2023-08-17 Thread Rui Barradas
and anyone willing to check them can. [1] https://cran.r-project.org/web/packages/ 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

Re: [R] geom_smooth

2023-08-11 Thread Rui Barradas
geom_line(data = fit, aes(x, ymax), linetype = "dashed", linewidth = 1) 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 posti

Re: [R] Use generic functions, e.g. print, without UseMethod?

2023-08-11 Thread Rui Barradas
generic to have methods processing inputs of different classes in ways specific to those classes. 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 PL

Re: [R] unused argument(s) (Header = 1) help!

2023-08-09 Thread 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. Hello, That erro

Re: [R] Stacking matrix columns

2023-08-06 Thread Rui Barradas
ked it but it's the slowest of the three, OP's, Iris' (the fastest). 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-pro

Re: [R] Multiply

2023-08-04 Thread Rui Barradas
atrix(dat2[match(dat1[,1], dat2[,1]),-1]) Res <- data.frame(ID = dat1[,1], Index = multiplication) # this is what I find simpler # the method being called is cbind.data.frame Res2 <- cbind(dat1[1], Index = multiplication) identical(Res, Res2) #> [1] TRUE Hope this helps, Rui Barradas __

Re: [R] Problems with facets in ggplot2

2023-08-04 Thread Rui Barradas
e( Year = rep((1990:1995),8), Flow = round(rnorm(48,50,10),3), Stat = rep(c(rep("Tweed",6), rep("Tay",6)),4), Metric = rep(c("AMAX","Mean","AMIN","Median"),each=12) ) ggplot(mock, aes(Year,Flow, group = factor(Stat), colour

Re: [R] Choosing colours for lines in ggplot2

2023-08-02 Thread Rui Barradas
coord_cartesian(ylim = c(0, 10)) + geom_line()+ geom_point()+ scale_color_manual(name = "Stat", values = cb8[4:5])+ theme_bw() Hope this helps, Rui Barradas __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see http

Re: [R] Plotting Fitted vs Observed Values in Logistic Regression Model

2023-08-02 Thread Rui Barradas
geom_point() + stat_smooth( formula = y ~ x, method = glm, method.args = list(family = binomial), se = FALSE ) Hope this helps, Rui Barradas __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailm

Re: [R] Downloading a directory of text files into R

2023-07-25 Thread Rui Barradas
84 # http://home.brisnet.org.au/~bgreen/Data/Hanson2/ # 749 # matches the question's number sum(lengths(success)) # [1] 833 Hope this helps, Rui Barradas __

Re: [R] Off-topic: ChatGPT Code Interpreter

2023-07-17 Thread Rui Barradas
. The fundamental machine is intelligence. Fernando Pessoa, 1926 Revista de Comércio e Contabilidade, nº 4. Lisboa, 25-4-1926. (Magazine of Commerce and Accounting, nº 4. Lisbon, 25-4-1926) Rui Barradas __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more

Re: [R] nlmixr2 installation problems

2023-07-16 Thread Rui Barradas
lo, Maybe this [1] is relevant. [1] https://community.rstudio.com/t/meaning-of-common-message-when-install-a-package-there-are-binary-versions-available-but-the-source-versions-are-later/2431 Hope this helps, Rui Barradas __ R-help@r-project.org ma

Re: [R] How to add error bars to a line plot with ggplot2?

2023-07-14 Thread Rui Barradas
(df, aes(x = Time, y = ddC, colour = mM, group = mM)) + geom_line() + geom_errorbar(aes(ymin = ddC - SD, ymax = ddC + SD), width = 0.1) + geom_point(size = 6) + geom_hline(aes(yintercept = 0)) + scale_colour_manual(values = COLS) + ggtitle("Exposure") +

Re: [R] textual analysis - transforming several pdf to txt - naming the files

2023-07-05 Thread Rui Barradas
cible code. Hello, I had tested the code with a couple of PDF's and it ran with no errors or warnings. That error is telling that a "}" is not balanced but in my code they all are, RStudio checks it automatically. Can you try to check in an editor with syntax highlighting? Hope th

Re: [R] textual analysis - transforming several pdf to txt - naming the files

2023-07-05 Thread Rui Barradas
:file_path_sans_ext(files) new_names <- paste(new_names, "txt", sep = ".") setNames(x, new_names) } # apply function # note that my test files are in "~/Temp" txts <- convertpdf2txt(here::here("~", "Temp")) names(txts) Hope this helps, Rui B

Re: [R] Create matrix with column names wiht the same prefix xxxx and that end in 1, 2

2023-07-03 Thread Rui Barradas
Às 20:55 de 03/07/2023, Rui Barradas escreveu: Às 20:26 de 03/07/2023, Sorkin, John escreveu: Jeff, Again my thanks for your guidance. I replaced dimnames(myvalues)<-list(NULL,c(zzz)) with colnames(myvalues)<-zzz and get the same error, Error in dimnames(x) <- dn :    length of 'dim

Re: [R] Create matrix with column names wiht the same prefix xxxx and that end in 1, 2

2023-07-03 Thread Rui Barradas
g, name) print(string) } #> [1] "xxx1" #> [1] "xxx1" "xxx2" # Now creation of xxx1 and xxx2 does work string #> [1] "xxx1" "xxx2" # 2. create a vector of the appropriate length beforehand, my preferred string <- character(2) for (j i

Re: [R] Create matrix with column names wiht the same prefix xxxx and that end in 1, 2

2023-07-03 Thread Rui Barradas
d, minimal, self-contained, reproducible code. Hello, You don't need so many calls to paste, one is enough. And you don't need the for loop at all, paste and paste0 are vectorized. myvalues <- matrix(nrow=2,ncol=4) cnames <- paste0("xxx&q

Re: [R] How to plot both lines and points by group on ggplot2

2023-07-01 Thread Rui Barradas
=Conc)) + geom_point(size=6) + geom_line(aes(group = Conc)) + scale_colour_manual(values = c("darkslategray3", "darkslategray4", "deepskyblue4")) + ggtitle("Working example") + xlab(expression(bold("Time (h)"))) + ylab(expression(

Re: [R] Issue with crammed Y axis

2023-06-18 Thread Rui Barradas
tor(Annee)))+ geom_bar(position="dodge",stat="identity")+ ylab("Simulation Progress (%)") + facet_wrap(~Type,nrow=3) myplot + theme(panel.grid.major = element_blank(), legend.title=element_blank(), panel.grid.minor = element_blank()

Re: [R] Problem with filling dataframe's column

2023-06-13 Thread Rui Barradas
o? I expected the function to remove 3 rows of the dataframe. I do not know the reason. On Mon, Jun 12, 2023 at 5:16 PM Rui Barradas wrote: Às 23:13 de 12/06/2023, javad bayat escreveu: Dear Rui; Many thanks for the email. I tried your codes and found that the length of the "Values" a

Re: [R] Problem with filling dataframe's column

2023-06-12 Thread Rui Barradas
data3 = data2[!grepl(c("_esmdes","_Des Section","0"), data2$Layer),] Warning message: In grepl(c("_esmdes", "_Des Section", "0"), data2$Layer) : argument 'pattern' has length > 1 and only the first element will be used How

Re: [R] Problem with filling dataframe's column

2023-06-11 Thread Rui Barradas
Às 13:18 de 11/06/2023, Rui Barradas escreveu: Às 22:54 de 11/06/2023, javad bayat escreveu: Dear Rui; Many thanks for your email. I used one of your codes, "data2$LU[which(data2$Layer == "Level 12")] <- "Park"", and it works correctly for me. Actua

Re: [R] Problem with filling dataframe's column

2023-06-11 Thread Rui Barradas
2")] <- "Agri"; ... ... ... . Is there any other way to expand the code in order to consider all of the levels simultaneously? Like the below code: data2$LU[which(data2$Layer == c("Level 1","Level 2", "Level 3", ...))] <- c("Park", "Agri&qu

Re: [R] Problem with filling dataframe's column

2023-06-11 Thread Rui Barradas
Layer == "Level 12") data2$LU[i] <- "Park" # equivalent one-liner data2$LU[which(data2$Layer == "Level 12")] <- "Park" Hope this helps, Rui Barradas __ R-help@r-project.org mailing list -- To UNSUB

Re: [R] Recombining Mon and Year values

2023-05-16 Thread Rui Barradas
quot;Jan 2021" "Mar 2021" "Apr 2021" 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.

Re: [R] Newbie: Drawing fitted lines on subset of data

2023-05-16 Thread Rui Barradas
r data = w %>% filter(year(date) %in% 2010:2015) # base R data = subset(w, year(date) %in% 2010:2015) 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

Re: [R] Error message when using 'optim' for numerical maximum likelihood

2023-05-14 Thread Rui Barradas
but like this it is not possible to do so. 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

Re: [R] aggregate wind direction data with wind speed required

2023-05-13 Thread Rui Barradas
ve or not NA's by adding a na.rm argument: my_fun <- function(wd1, ws1, na.rm = FALSE) { [...] mean_u <- mean(u_component, na.rm = na.rm) mean_v <- mean(v_component, na.rm = na.rm) [...] } aggregate(wd ~ day + month, data=df, FUN = my_fun, ws1 = ws, na.rm = TRUE)

Re: [R] Newbie: Controlling legends in graphs

2023-05-12 Thread Rui Barradas
ate(name = factor(name, levels = c("K", "J"))) %>% ggplot(aes(Year, value, color = name)) + geom_smooth( formula = y ~ x, method = lm, se = FALSE ) + geom_point() + scale_color_manual(values = c(J = "red", K = "b

Re: [R] data.frame with a column containing an array

2023-05-09 Thread Rui Barradas
//www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hello, Are you looking for something like this? DFA <- data.frame(id = 1:2) DFA[["ar"]] <- array(1:8, c(2,2,2)) DFA$ar[1, , ] #> [,1] [,2] #> [1,]1 5 #> [2,

Re: [R] grubbs test to detect all outliers

2023-04-29 Thread Rui Barradas
uEl-Makarim Aboueissa, PhD* *Professor, Mathematics and Statistics* *Graduate Coordinator* *Department of Mathematics and Statistics* *University of Southern Maine* On Sat, Apr 29, 2023 at 8:05 AM Rui Barradas wrote: Às 14:09 de 28/04/2023, AbouEl-Makarim Aboueissa escreveu: *R: *Grubbs Test to de

Re: [R] grubbs test to detect all outliers

2023-04-29 Thread Rui Barradas
2.667 NA 1 486 217 275 # tried to use grubbs.test() on a single column of the dataframe, but # still not working grubbs.test(datafortest$X, type = 11) #> #> Grubbs test for two opposite outliers #> #> data: datafortest$X #> G = 4.6640014, U = 0.0091756, p-value = 0.0286

Re: [R] grubbs test to detect all outliers

2023-04-28 Thread Rui Barradas
-- 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, Please post the output of dput(datafortest) your data is difficult to read int

Re: [R] grDevices::hcl.colors using two colours: Bug or Feature?

2023-04-28 Thread Rui Barradas
ave a closer look... Thanks for reporting this! Achim On Fri, 28 Apr 2023, Rui Barradas wrote: Às 06:01 de 28/04/2023, Stevie Pederson escreveu: Hi, I'm not sure if this is a bug or a feature, but after updating to Rv4.3, if requesting two colours from hcl.colors() you now get the same colour tw

Re: [R] grDevices::hcl.colors using two colours: Bug or Feature?

2023-04-28 Thread Rui Barradas
datasets methods base # # loaded via a namespace (and not attached): # [1] compiler_4.2.3 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 PLE

Re: [R] detect and replace outliers by the averaged

2023-04-21 Thread Rui Barradas
Hello, Às 09:42 de 21/04/2023, Jeff Newmiller escreveu: 0 Somewhat cryptic... Rui Barradas On April 21, 2023 4:08:08 AM GMT+09:00, Dr Eberhard W Lisse wrote: There is at least one outliers package on CRAN. el On 20/04/2023 20:43, AbouEl-Makarim Aboueissa wrote: Dear All: *please

  1   2   3   4   5   6   7   8   9   10   >