Re: [R] Good Evening,

2020-10-29 Thread Rui Barradas
. Start with R-intro.pdf that comes with R. There are also many texts online that cover this and lots of other graphics stuff. Hope this helps, Rui Barradas Às 14:49 de 29/10/20, Joy Kissoon escreveu: runif (100, 1000, 1) __ R-help@r-projec

Re: [R] fast way to find most common value across columns dataframe

2020-10-31 Thread Rui Barradas
s::Mode(x), so = apply(x, 1, Mode), times = 10 ) print(mb, unit = "relative", order = "median") [1] https://stackoverflow.com/a/8189441/8245406 Hope this helps, Rui Barradas Às 17:12 de 31/10/20, Luigi Marongiu escreveu: Thank you. The problem was not finding the mode

Re: [R] strptime() keeps emitting warnings after establishing a handler with tryCatch()

2020-11-01 Thread Rui Barradas
t_PT.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=pt_PT.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.0.3 Hope this helps, Ru

Re: [R] colMeans function

2020-11-04 Thread Rui Barradas
class(), str() or dim() return when applied to both. See also this StackOverflow post: https://stackoverflow.com/questions/1169456/the-difference-between-bracket-and-double-bracket-for-accessing-the-el Hope this helps, Rui Barradas Às 13:26 de 04/11/20, Engin Yılmaz escreveu: Dear I use

Re: [R] Data Table not rendering properly using R shiny

2020-11-07 Thread Rui Barradas
Hello, Or maybe logical_idx <- max_usage_hours_per_region$Region %in% input$Region Another option is ?match Hope this helps, Rui Barradas Às 15:41 de 07/11/20, Jeff Newmiller escreveu: This looks odd... max_usage_hours_per_region[input$Region,] This would only work if you

Re: [R] ggplot2 stat_smooth formula different units

2020-11-11 Thread Rui Barradas
Hello, Try removing I() from I(log(y)). But it's hard to say without a reproducible example, please post the output of dput(dat) or, if dat is big, the output of dput(head(dat, 20)) Hope this helps, Rui Barradas Às 22:11 de 11/11/20, Marcelo Laia escreveu: Hi, I am running

Re: [R] ggtree: color-code multiple paraphyletic clades

2020-11-11 Thread Rui Barradas
/treeManipulation.html Hope this helps, Rui Barradas Às 21:59 de 11/11/20, April Ettington escreveu: I've been using groupOTU to color paraphyletic clades in my tree based on lists of tips, but I have multiple clades I want to highlight. Is there some way to use ggplot to indicate mul

Re: [R] find local max in moving window

2020-11-13 Thread Rui Barradas
sition[w, ] Hope this helps, Rui Barradas Às 09:59 de 13/11/20, ani jaya escreveu: Dear r list, I try to locate any local max value and location of data that follow 7 moving window condition, meaning that this data is largest and centered in 7 values to the left and 7 values to the right.

Re: [R] long integer handling

2020-11-13 Thread Rui Barradas
Hello, You can compute the exact result with package Rmpfr. See ?mpfr and [1]. library(Rmpfr) two <- mpfr(2, precBits = 64) two^64 - 1 #1 'mpfr' number of precision 64 bits #[1] 18446744073709551615 [1] https://www.mpfr.org/ Hope this helps, Rui Barradas Às 01:44 de 14/

Re: [R] long integer handling

2020-11-13 Thread Rui Barradas
Hello, I forgot to suggest package gmp. See the second example in ?gmp::bigz Hope this helps, Rui Barradas Às 05:50 de 14/11/20, Rui Barradas escreveu: Hello, You can compute the exact result with package Rmpfr. See ?mpfr and [1]. library(Rmpfr) two <- mpfr(2, precBits = 64) two^64

Re: [R] assistance programming R

2020-11-16 Thread Rui Barradas
len(q), na.rm = na.rm) } # Tests set.seed(2020) x1 <- rpois(10, lambda = 4) x2 <- rpois(100, lambda = 10) n_l(x1, q = 4) n_l(x2, q = 21) Hope this helps, Rui Barradas Às 12:45 de 16/11/20, Ablaye Ngalaba escreveu: Hello, please, I need help in programming R. Here i

Re: [R] ON the installation of: abnormally-distributed/cvreg

2020-12-09 Thread Rui Barradas
devtools::install_github('abnormally-distributed/cvreg') Hope this helps, Rui Barradas Às 09:00 de 08/12/20, Ishaqbaba via R-help escreveu: Hello Sir, Hope this email finds you hale, healthy and safe. I have been having problem in installing this: install.packages("remotes&

Re: [R] ggplot2::coord_fixed() margin problem

2020-12-20 Thread Rui Barradas
Does this answer the question? Hope this helps, Rui Barradas Às 12:22 de 20/12/20, Martin Møller Skarbiniks Pedersen escreveu: Hi, I posted this on the Google Group for ggplot2 but got no response. https://groups.google.com/g/ggplot2/c/441srnt6RZU So I hope someone can help me here in

Re: [R] ggplot2::coord_fixed() margin problem

2020-12-20 Thread Rui Barradas
Hello, Is it this? plot.background = element_rect(colour = "yellow2", fill = "yellow2") The small white space goes away. Hope this helps, Rui Barradas Às 17:00 de 20/12/20, Martin Møller Skarbiniks Pedersen escreveu: On Sun, 20 Dec 2020 at 17:43, Rui Barradas wrote:

Re: [R] Passing variable name

2020-12-27 Thread Rui Barradas
erflow.com/questions/1886/dynamically-select-data-frame-columns-using-and-a-vector-of-column-names [2]: https://stackoverflow.com/questions/1169456/the-difference-between-bracket-and-double-bracket-for-accessing-the-el Hope this helps, Rui Barradas Às 21:48 de 27/12/20, Jim Lemon escreveu:

Re: [R] Passing variable name

2020-12-28 Thread Rui Barradas
and" MyT2 <- table(MyData[[V1]], MyData[[V2]]) MyT2 MyChi <- chisq.test(MyT2) MyChi name2 <- c(V1, V2, "Frequency") dMyT <- as.data.frame(MyT2) names(dMyT) <- name2 library(ggplot2) ggplot(data = na.omit(dMyT), aes(get(V1), Frequency, fill = get(V2))) + geom_bar(position

Re: [R] non-standard reshape from long to wide

2021-01-07 Thread Rui Barradas
) Note: your df.wide is not a data.frame, the transpose coerces it to matrix. In this case it doesn't matter because it was just an example of expected output but in other, real use cases you must be careful. df.wide <- as.data.frame(df.wide) would solve it. Hope this helps, Rui

Re: [R] Secondary y axis in ggplot2: did not respond when change its y-axis value

2021-01-08 Thread Rui Barradas
= subset(daT1, variable == "y1"), aes(y = value)) + geom_line(data = subset(daT1, variable == "y2"), aes(y = value*diff(rng) + rng[1])) + facet_wrap(~group) + scale_y_continuous(sec.axis = sec_axis(~ .*0.0001)) Hope this helps, Rui Barradas Às 01:0

Re: [R] replace zero in a matrix using random numbers

2021-01-08 Thread Rui Barradas
l be separating the instruction you wrote from the NULL instruction. A simpler example could be mean(1:5); This is *two* instructions: mean(1:5); NULL Hope this helps, Rui Barradas Às 22:33 de 08/01/21, Yuan Chun Ding escreveu: Hi R users, I am analyzing miRNA sequence data for a special network

Re: [R] How to avoid ggplot clipping the x axis [damn, replaces previous Email]

2021-01-10 Thread Rui Barradas
element on its own: xlim(1, 6) Or lims(x = c(1, 6)) But with these two, the labels are not like you want them, they are 2 by 2. Hope this helps, Rui Barradas Às 10:34 de 10/01/21, Chris Evans escreveu: [I must try to remember that swapping between Rstudio and my Emailer is a recipe for hi

Re: [R] Converting "day of year" to "year", "month" and "day"

2021-01-15 Thread Rui Barradas
web and have only their URLs posted. This way a reader has the option to download them or not. Can you post sample data? Please post the output of `dput(df)`. Or, if it is too big the output of `dput(head(df, 20))`. (`df` is the name of your dataset.) Hope this helps, Rui Barradas Às 11:30

Re: [R] Converting "day of year" to "year", "month" and "day"

2021-01-15 Thread Rui Barradas
1998-01-03 #4 1998 4 0 332 1998-01-04 #5 1998 5 0 302 1998-01-05 #6 1998 6 0 329 1998-01-06 Hope this helps, Rui Barradas Às 06:48 de 16/01/21, Jibrin Alhassan escreveu: Hi Barradas  Sorry for the delay. Below is a section of my data. I have up to 1826 covering 1998 to 2002 year  

Re: [R] Converting "day of year" to "year", "month" and "day"

2021-01-17 Thread Rui Barradas
, assign to df1, without creating df2. Hope this helps, Rui Barradas Às 15:12 de 17/01/21, Jibrin Alhassan escreveu: Hi Barradas, Thanks for your assistance. It has brought me closer to what I am looking for. I tried your code as shown below: > df1 <- read.table("SWSdata_1998_2002&q

Re: [R] Errors and OS Differences with as.POSIXct and as.POSIXlt

2021-01-19 Thread Rui Barradas
7] LC_PAPER=pt_PT.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=pt_PT.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.0.3 Hope this help

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

2021-01-21 Thread Rui Barradas
ormal") f$estimate p <- pretty(range(data)) x <- seq(from = min(p), to = max(p), by = 0.1) hist(data, freq = FALSE) lines(x, y = dlnorm(x, meanlog = f$estimate["meanlog"], sdlog = f$estimate["sdlog"]) ) Hope this helps, Rui Barra

Re: [R] How to generate SE for the proportion value using a randomization process in R?

2021-01-22 Thread Rui Barradas
original sd(b$t) # bootstrapped estimate of the SE of the sample prop. hist(b$t, freq = FALSE) Hope this helps, Rui Barradas Às 21:57 de 22/01/21, Marna Wagley escreveu: Hi All, I was trying to estimate standard error (SE) for the proportion value using some kind of randomization process (bo

Re: [R] How to generate SE for the proportion value using a randomization process in R?

2021-01-23 Thread Rui Barradas
ction(x, xbar, s){ dnorm(x, mean = xbar, sd = s) } hist(b$t, freq = FALSE) curve(f(x, xbar = b$t0, s = sd(b$t)), from = 0, to = 1, col = "blue", add = TRUE) curve(f(x, xbar = b$t0, s = sd(b$t)/sqrt(R)), from = 0, to = 1, col = "red", add = TRUE) Hope this helps,

Re: [R] Plot dataframe with color based on a column value

2021-01-24 Thread Rui Barradas
Hello, Base R: colrs <- rainbow(length(unique(ROI$Z))) roi_wide <- reshape(ROI, v.names = "Y", timevar = "Z", idvar = "X", direction = "wide") matplot(roi_wide, type = "l", lwd = 3, lty = "solid", col = colrs) Hope this h

Re: [R] Calling procedures

2021-01-25 Thread Rui Barradas
DF: normal or logistic # * if(logistic) pbivlogis(x,y,rho) else pbivnorm(x,y,rho,recycle=TRUE) } Hope this helps, Rui Barradas Às 06:14 de 25/01/21, Steven Yen escreveu: Dear All Below are calls to functions to calculate bivariate and univariate logistic probabilities.It works for the fo

Re: [R] make new collumns with conditions

2021-01-25 Thread Rui Barradas
1L, 1L, 1L, 2L, 2L, 2L, 2L), species = c("red deer", "red deer", "red deer", "red deer", "red deer", "red deer", "red deer", "red deer")), class = "data.frame", row.names = c(NA, -8L)) Hope this

Re: [R] make new collumns with conditions

2021-01-25 Thread Rui Barradas
it a try would have their job made easier. To the OP: the code before "Data in dput format:" is a proposed solution, not the structure(list(etc)), like Michael says. If you run that statement, you will see the data as you've posted it, even with the original column names. Hope t

Re: [R] How to predict/interpolate new Y given knwon Xs and Ys?

2021-01-26 Thread Rui Barradas
tion in [1] [1] https://CRAN.R-project.org/package=investr Hope this helps, Rui Barradas Às 09:11 de 26/01/21, Luigi Marongiu escreveu: Hello, I have a series of x/y and a model. I can interpolate a new value of x using this model, but I get funny results if I give the y and look for the correspo

Re: [R] Regarding fitted value

2021-01-28 Thread Rui Barradas
Hello, From help('forecast::fitted.Arima'): h The number of steps to forecast ahead. So you have the default h = 1 step ahead forecast for your model. Hope this helps, Rui Barradas Às 12:13 de 28/01/21, Md. Moyazzem Hossain escreveu: Dear R-experts, I hope that all

Re: [R] How to generate SE for the proportion value using a randomization process in R?

2021-01-28 Thread Rui Barradas
ay. It will now return a matrix of indices with R = 1000 rows and 19 columns. Hope this helps, Rui Barradas Às 19:29 de 28/01/21, Marna Wagley escreveu: Hi Rui, I am sorry for asking you several questions. In the given example, randomizations (reshuffle) were done 1000 times, and its 1000

Re: [R] How to generate SE for the proportion value using a randomization process in R?

2021-01-28 Thread Rui Barradas
Hello, Yes, sorry for my previous post, I had forgotten about boot.array. That's a much better solution for your problem. Rui Barradas Às 20:29 de 28/01/21, Marna Wagley escreveu: Thank you Rui, This is great. How about the following? SimilatedData<-boot.array(b, indices=T) see

Re: [R] need help calculating the indicator function

2021-01-29 Thread Rui Barradas
Hello, Maybe this? n_l <- function(Y, l, na.rm = FALSE) sum(Y == l, na.rm = na.rm) set.seed(2020) q <- 6 y <- sample(q, 10, TRUE) l <- 4 n_l(y, l) #[1] 3 Hope this helps, Rui Barradas Às 14:27 de 29/01/21, Ablaye Ngalaba escreveu: Hello, please, I need to calculate t

Re: [R] need help calculating the indicator function

2021-01-30 Thread Rui Barradas
Hello, Please cc the list, R-Help is threaded and your doubt and answers might be of interest to others. With a vector Y, you want 0 in all Y != l and 1 in all Y == l? n_l <- function(Y, l) as.integer(Y == l) Hope this helps, Rui Barradas Às 11:26 de 30/01/21, Ablaye Ngalaba escre

Re: [R] Regarding fitted value

2021-02-01 Thread Rui Barradas
forecast(model1) plot(fc) Hope this helps, Rui Barradas Às 23:31 de 01/02/21, Md. Moyazzem Hossain escreveu: Dear Rui Barradas Thank you very much for your reply. However, still now, I have a confusion whether I get the fitted value for the year 2000, 2001, ..., 2020 or 2001, 2002, ..., 202

Re: [R] Regarding fitted value

2021-02-02 Thread Rui Barradas
Hello, Thanks for the links, they are very helpful. Rui Barradas Às 11:36 de 02/02/21, Partho Sarkar escreveu: In case further clarification is needed, this from Rob Hyndman, author of the Forecast package, may be helpful: "fitted produces one-step in-sample (i.e., training data) "

Re: [R] Axis whitout all the row, that contains time

2021-02-12 Thread Rui Barradas
20 secs", date_labels = "%M:%S") + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1, size = 5)) Hope this helps, Rui Barradas Às 15:05 de 12/02/21, Informatique escreveu: Hello, i'm using Rstudio from a few day, and i have some information in a CVS file, take

Re: [R] Axis whitout all the row, that contains time

2021-02-14 Thread Rui Barradas
s", date_labels = "H:%M:%S") Can you post as data sample the output of dput? dput(head(listeMesuresPropres, 20)) # or 30 Hope this helps, Rui Barradas Às 07:35 de 14/02/21, Informatique escreveu: Hello, the time are in the first table like that : 10:24:00 and i use this f

Re: [R] Axis whitout all the row, that contains time

2021-02-14 Thread Rui Barradas
the entire ggplot code, not just the scale_x_datetime instruction but the rest of the plotting code? Hope this helps, Rui Barradas Às 13:25 de 14/02/21, Informatique escreveu: Hello, Thank's for your help. i when i try this one geom_line() + scale_x_datetime(date_breaks =

Re: [R] Axis whitout all the row, that contains time

2021-02-14 Thread Rui Barradas
alue) liste_data_long$value <- as.numeric(liste_data_long$value) library(ggplot2) ggplot(liste_data_long, aes(x = DateHeure, y = value, color = variable)) + geom_line() + geom_point() + scale_x_datetime(date_breaks = "60 secs", date_labels = "%H:%M:%S") Hope this

Re: [R] Axis whitout all the row, that contains time

2021-02-14 Thread Rui Barradas
Hello, Sorry, my typo now, see inline. Às 16:56 de 14/02/21, Rui Barradas escreveu: Hello, Please always cc the r-help mailing list, this might be helpful to others in the future. 1. You have a data file using the continental Europe convention of marking the decimals with a comma

Re: [R] overlaying frequency histograms or density plots in R

2021-02-25 Thread Rui Barradas
p + geom_histogram( mapping = aes(y = ..density..), position = position_dodge(), bins = 10) + scale_y_continuous(labels = scales::label_percent()) Hope this helps, Rui Barradas Às 07:43 de 25/02/21, Bogdan Tanasa escreveu: Thanks a lot Petr ! shall i uses "dodge" also for

Re: [R] Making model predictions

2021-02-28 Thread Rui Barradas
t is predict(m, newdata = newd) #[1] Yes #Levels: No Yes Hope this helps, Rui Barradas Às 14:42 de 27/02/21, Jeff Reichman escreveu: R User Forum Is there a better way than grabbing individual cell values from a model output to make predictions. For example the output from the following Naï

Re: [R] Column-by-column division

2021-03-03 Thread Rui Barradas
Hello, Maybe define an infix operator? `%!%` <- function(x, y) { stopifnot(ncol(x) == length(y)) t(t(x)/y) } x <- matrix(1:20, ncol = 2) s <- 1:2 x %!% s x %!% 1:4 Hope this helps, Rui Barradas Às 11:00 de 03/03/21, Steven Yen escreveu: I have a 10 x 2 matrix x. Like to d

Re: [R] Column-by-column division

2021-03-03 Thread Rui Barradas
Hello, I forgot about sweep: sweep(x, 2, s, '/') sweep(x, 2, 1:4, '/') Hope this helps, Rui Barradas Às 11:12 de 03/03/21, Rui Barradas escreveu: Hello, Maybe define an infix operator? `%!%` <- function(x, y) {   stopifnot(ncol(x) == length(y))   t(t(x)/y) }

Re: [R] A tibble with date column appears different in shiny

2021-03-03 Thread Rui Barradas
= col_character(), state = col_character(), fips = col_character(), cases = col_double(), deaths = col_double() ) us_counties <- read_csv(url(urlfile), col_types = cols_spec) Hope this helps, Rui Barradas Às 15:24 de 03/03/21, Gayathri Nagarajan escreveu: Hi Team I have a tibble like the b

Re: [R] A tibble with date column appears different in shiny

2021-03-04 Thread Rui Barradas
Hello, This is a known issue with renderTable. Show the results with renderDataTable instead. Hope this helps, Rui Barradas Às 15:24 de 03/03/21, Gayathri Nagarajan escreveu: Hi Team I have a tibble like the below : class(us_counties) [1] "tbl_df" "tbl"

Re: [R] Help please

2021-03-10 Thread Rui Barradas
Hello, Please read the posting guide at the end of this and every R-Help mail. You should post the output of dput(data) or, if the data set 'data' is too big, the output of dput(head(data, 20)) for us to be able to help you. Rui Barradas Às 18:29 de 10/03/21, Areti Panopoulo

Re: [R] How to plot dates

2021-03-16 Thread Rui Barradas
uot;) + geom_point() + scale_x_datetime(breaks = myDat$datetime) + scale_y_continuous(labels = NULL) + ylab("event") + theme(axis.text.x = element_text(angle = 60, vjust = 1, hjust=1), axis.ticks.y = element_blank()) Hope this helps, Rui Barradas Às 13:36 de 16/03/21, S

Re: [R] R

2021-03-16 Thread Rui Barradas
Hello, Yes, you can ask R-Help questions on R code, that's what it is intended for. But please read the posting guide, it's link is at the bottom of this and of any R-Help mail. Good luck, enjoy R! Rui Barradas Às 18:19 de 16/03/21, Jonathan Lim escreveu: Hi I found your

Re: [R] Failure in predicting parameters

2021-03-18 Thread Rui Barradas
1) plot(1:45, high, type = "l", col = "red") points(1:45, R, col = "blue") points(1:45, highpred$Prediction, col = "cyan", pch = 3) [1] https://CRAN.R-project.org/package=qpcR Hope this helps, Rui Barradas Às 06:51 de 18/03/21, Luigi Marongiu escreveu:

Re: [R] Can't save files from the Source pane of R Studio

2021-03-22 Thread Rui Barradas
Hello, R-Help is for questions on R code. RStudio has its own help forum that you can access from the Help menu, Help > RStudio Community Forum Hope this helps, Rui Barradas Às 18:07 de 22/03/21, Parkhurst, David escreveu: I�m just starting to learn and use R Studio in my Mac. Now I f

Re: [R] Converting POSIXct format date to Character format

2021-03-24 Thread Rui Barradas
Hello, R is case sensitive, the column name is YEAR_END_Date, neither of Year_END_Date YEAR_END_DATE matches that name. Try select(PLC, format(YEAR_END_Date,format = "%B %d, %Y"), EPS) Hope this helps, Rui Barradas Às 19:11 de 24/03/21, e-mail ma015k3113 via R-help escreveu:

Re: [R] Including a ggplot call with a conditional geom in a function

2021-03-24 Thread Rui Barradas
Hello, In the following code, the fixed parts of the plot are drawn first, assigning the plot to p. Then geom_hline is conditionally added to p and the result returned to caller. This may be a problem if the conditional geom needs to be in a specified order in the plot. Function plotLineFunc2

Re: [R] dplyr: summarise across using variable names and a condition

2021-03-26 Thread Rui Barradas
-matches("^gender_.*_std$"), -matches("^race_.*_std$") ) %>% rename_with( .cols = matches("^gender|^race"), ~sub("mean$", "prop", .x) ) %>% all.equal(need) #[1] TRUE Hope this helps, Rui Barradas Às 13:47 de 26/03/21, Paul Mil

Re: [R] Controling the presentation of violin plot

2021-03-31 Thread Rui Barradas
s, will be used. p + geom_dotplot(binaxis='y', stackdir='center', dotsize=1) + scale_y_continuous( trans = scales::pseudo_log_trans(base = exp(1)) ) Hope this helps, Rui Barradas Às 23:49 de 31/03/21, Mahmood Naderan-Tahan escreveu: Hi, With the following command

Re: [R] R Language on Windows 2019

2021-04-07 Thread Rui Barradas
great software with no real Windows Server 2019 compatibility problems. Hope this helps, Rui Barradas Às 19:49 de 07/04/21, Tammy Regalado escreveu: What versions of Windows can R Language be installed on? Specifically, is Windows Server 2019 a supported pla

Re: [R] Assigning several lists to variables whose names are contained in other variables

2021-04-09 Thread Rui Barradas
} To keep extending a vector or list object in a loop is inefficient, this creates the list with the right length beforehand. Hope this helps, Rui Barradas Às 13:21 de 09/04/21, Wolfgang Grond escreveu: Greg, here I get the error message: Error my_function(val) : cannot find function

Re: [R] Identifying column type

2021-04-09 Thread Rui Barradas
Hello, Maybe something like ok <- sapply(mydata, is.numeric) mydata <- mydata[ok] to keep the numeric columns only. Hope this helps, Rui Barradas Às 04:25 de 10/04/21, Steven Yen escreveu: I have data of mixed types in a data frame - date and numeric, as shown in summary below. Ho

Re: [R] Assigning several lists to variables whose names are contained in other variables

2021-04-10 Thread Rui Barradas
vector("list", length = nrow(datatable)) for(i in seq_along(datatable$column)){ net_name <- datatable$column[i] NET <- get(net_name, envir = .GlobalEnv) result3[[i]] <- my_function(NET) } names(result3) <- paste("subnet", datatable$column, sep = "_") 4.

Re: [R] Comparing dates in two large data frames

2021-04-10 Thread Rui Barradas
were right. result <- logical(nrow(df1)) inx <- findInterval(df1$Time, df2$start) not_zero <- inx != 0 result[not_zero] <- df1$Time[not_zero] <= df2$end[ inx[not_zero] ] Hope this helps, Rui Barradas Às 12:06 de 10/04/21, Kulupp escreveu: Dear all, I have two data frames (df1 a

Re: [R] Looping through data error

2021-04-13 Thread Rui Barradas
] = 100/is.na(CLOSE_SHARE_PRICE[i]) } } Hope this helps, Rui Barradas Às 13:51 de 13/04/21, e-mail ma015k3113 via R-help escreveu: Dear All,I have a dataframe with 4 variables and I am trying to calculate how many shares can be purchased with £100 in the first year when the company was listed

Re: [R] Looping through data error

2021-04-13 Thread Rui Barradas
Hello, Typo, inline. Às 17:06 de 13/04/21, Rui Barradas escreveu: Hello, A close parenthesis is missing in the nd if. Should be "the 2nd if". Rui Barradas for (i in 1:(nrow(PLC_Return)-1)){   if (i == 1){     NUMBER_OF_SHARES[i] = 100/is.na(CLOSE_SHARE_PRICE[i])   } els

Re: [R] Error loading "XLConnect" library

2021-04-14 Thread Rui Barradas
/error-package-or-namespace-load-failed-for-xlconnect Hope this helps, Rui Barradas Às 18:42 de 14/04/21, Bernard McGarvey escreveu: I installed the "XLConnect" package which appears to be successful and then tried to load the "XLConnect" library and got an error as shown

Re: [R] geom_node_point color in ggraph

2021-04-15 Thread Rui Barradas
quot;) + geom_edge_link() + geom_node_point(aes(colour = Acronym), size = 8) + scale_color_manual(name = "Project / Projekt", values = c("blue", "red")) Hope this helps, Rui Barradas Às 15:57 de 15/04/21, Wolfgang Grond escreveu: Dear all, I'm

Re: [R] Installed Packages not working

2021-04-17 Thread Rui Barradas
Hello, That error message means you need to run install.packages("rlang") before running library(farff) Hope this helps, Rui Barradas Às 20:02 de 17/04/21, Neha gupta escreveu: Hi, suddenly the packages I installed not working. It gives me the error: Error: package or name

Re: [R] What is an alternative to expand.grid if create a long vector?

2021-04-19 Thread Rui Barradas
very, very long time to process. Revise the problem? Hope this helps, Rui Barradas Às 13:35 de 19/04/21, Shah Alam escreveu: Dear All, I would like to know that is there any problem in *expand.grid* function or it is a limitation of this function. I am trying to create a combination of

Re: [R] The program can't stop when searches over all files under folders and subfolders

2021-04-19 Thread Rui Barradas
Hello, The following will probably not solve the problem but I would 1. use pattern = "\\.wma$" in list.files; 2. use sub, not gsub, in sub("\\.wma$", ".mp3", i) Hope this helps, Rui Barradas Às 05:29 de 20/04/21, Jim Lemon escreveu: Hi John, If the progra

Re: [R] Query

2021-04-26 Thread Rui Barradas
tact the maintainer("vars") ? Hope this helps, Rui Barradas Às 18:31 de 25/04/21, Sun Yong Kim escreveu: vars package From: John Kane Sent: Sunday, April 25, 2021 12:30 PM To: Sun Yong Kim Cc: r-help@r-project.org Subject: Re: [R] Query What package

Re: [R] Help understanding loop behaviour

2021-04-30 Thread Rui Barradas
Hello, For column J, ave/seq_along seems to be the simplest. For column I, ave is also a good option, it avoids split/lapply. xx$I <- ave(xx$NUMBER_OF_YEARS, xx$COMPANY_NUMBER, FUN = function(x){ c(rep(1, length(x) - 1), max(length(x))) }) xx$J <- ave(xx$NUMBER_OF_YEARS, xx$COMPANY_NUMBER,

Re: [R] Help understanding loop behaviour

2021-04-30 Thread Rui Barradas
Hello, Right, thanks. I should be xx$I <- ave(xx$NUMBER_OF_YEARS, xx$COMPANY_NUMBER, FUN = function(x){ c(rep(1, length(x) - 1), length(x)) ### ??? }) Hope this helps, Rui Barradas Às 19:46 de 30/04/21, Bert Gunter escreveu: There is something wrong here I believe --

Re: [R] Plotting two time series in one graph

2021-05-02 Thread Rui Barradas
Hello, Can you post sample data? For instance, the output of dput(head(dovrez, 20)) dput(head(rqa_df_USD, 20)) Or maybe you could rbind the data.frames with one column telling which of Res or LAM the values come from. Hope this helps, Rui Barradas Às 19:38 de 02/05/21, Baki UNAL via R

Re: [R] grep

2021-05-08 Thread Rui Barradas
"x1.conserv" "x2.black" "x2.conserv" Hope this helps, Rui Barradas Às 18:20 de 08/05/21, Jeff Newmiller escreveu: Regular expression patterns are not vectorized... only the data to be searched are. Use one of the many websites dedicated to tutoring regular expres

Re: [R] grep

2021-05-08 Thread Rui Barradas
e = FALSE) } jj <- jindex[!i1] x.label <- x.label[jj] } Or even simpler if(any(!i1 & !i2)){ words <- jindex[!i1 & !i2] pattern <- paste(words, collapse = "|") jindex <- grep(pattern = pattern, x.label, value = FALSE) jj <- jindex[!i1] x.label

Re: [R] No error message but don't get the 8 graphs

2021-05-09 Thread Rui Barradas
) [...] par(op) dev.off() # The comments only line is your last code line. The result is attached. Hope this helps, Rui Barradas Às 19:39 de 09/05/21, varin sacha via R-help escreveu: Dear R-experts, I am trying to get the 8 graphs like the ones in this

Re: [R] Group by and duplicate a value/dplyr

2021-05-11 Thread Rui Barradas
alue[flag]) ) %>% select(-flag) identical(df2$MinValue, df3$MinValue) #[1] TRUE Or, simpler: df4 <- df %>% group_by(Department,Class) %>% mutate(MinValue = min(Value[Value != 0]) ) identical(df2$MinValue, df4$MinValue) #[1] TRUE Hope this helps, Rui Barradas Às 12:11 de 11

Re: [R] empty plots !

2021-05-12 Thread Rui Barradas
(old_par) # at the end, put the graphics device pars back. Hope this helps, Rui Barradas Às 09:33 de 12/05/21, varin sacha via R-help escreveu: Dear Experts, My R code was perfectly working since I decide to add a 5th correlation coefficient : hoeffdings' D. fter a google search, I guess I n

Re: [R] Finding strings in a dataset

2021-05-15 Thread Rui Barradas
; found2 <- sapply(df1, function(x) grepl(pattern, x)) which(found2, arr.ind = TRUE) Hope this helps, Rui Barradas Às 18:07 de 15/05/21, Tuhin Chakraborty escreveu: Hi, How can I find the location of string data in my 2D dataset? spec(Dataset) will reveal the columns that contain the strings. Bu

Re: [R] Finding strings in a dataset

2021-05-16 Thread Rui Barradas
ngs(is.na(as.numeric(x))) } found <- sapply(df1, f) which(found, arr.ind = TRUE) Hope this helps, Rui Barradas Às 06:31 de 16/05/21, Tuhin Chakraborty escreveu: Thank you everyone, for the very helpful suggestions. I understand that my question is not altogether clear. So let me share an example.

Re: [R] Finding strings in a dataset

2021-05-16 Thread Rui Barradas
RUE) res <- as.data.frame(res) res$col_name <- names(df1)[ res$col ] With a big data set the first res is a numeric matrix and it's access and extraction is faster, matrix operations are generally faster than data.frame operations. Hope this helps, Rui Barradas Às 08:30 de 16/05/21, Rui Barrad

Re: [R] [External Email] Group by and add a constant value based on a condition dply

2021-05-26 Thread Rui Barradas
Hello, I too don't see why grouping is needed but here it goes. df1 %>% group_by(Department, Class) %>% mutate(Value = Value + 5*(Date == "4.01.2020")) Hope this helps, Rui Barradas Às 17:01 de 26/05/21, Christopher W Ryan via R-help escreveu: Is the grouping

Re: [R] R grep question

2021-05-27 Thread Rui Barradas
Hello, ifelse needs a logical condition, not the value. Try grepl. CRC$MMR.gene <- ifelse(grepl("MLH1"|"MSH2",CRC$gene.all), "Yes", "No") Hope this helps, Rui Barradas Às 05:29 de 27/05/21, Kai Yang via R-help escreveu: Hi List, I wrote the

Re: [R] if statement and for loop question

2021-05-30 Thread Rui Barradas
;- '' c[i] <- '' d[i] <- '' }) Hope this helps, Rui Barradas Às 17:28 de 30/05/21, Kai Yang via R-help escreveu: Hello List,I have a data frame which having the character columns: | a1 | b1 | c1 | d1 | | a2 | b2 | c2 | d2 | | a3 | b3 | c3 | d3 | | a4 | b4

Re: [R] Plot GEE confindence interval band ggplot2

2021-06-01 Thread Rui Barradas
uot;exchangeable" ) plot_model(m5, type = "pred", terms = c("Pa", "Pt")) Hope this helps, Rui Barradas Às 23:10 de 31/05/21, Luis Fernando García escreveu: Dear all, I want to plot a Generalized Estimating Equation (GEE) model, with interactions and the confidence

Re: [R] trim NA from concatenate result

2021-06-02 Thread Rui Barradas
to post in HTML format. Hope this helps, Rui Barradas Às 22:07 de 02/06/21, Kai Yang via R-help escreveu: Hi List, I use paste function to concatenate  3 character columns together. when I run table to see that, I found 3 categories. How can I write script to trim NA in 2nd and 3rd group and

Re: [R] Beginner problem - using mod function to print odd numbers

2021-06-05 Thread Rui Barradas
Hello, Why not write a function? odd <- function(x, numeric = TRUE){ i <- x %% 2 == 1 if(numeric) x[i] else i } odd(1:100) Hope this helps, Rui Barradas Às 19:17 de 02/06/21, nelpar escreveu: I don't understand. -- 7%%2=1 9%%2=1 11%%2=1 What aren't these numbers

Re: [R] Can I use group_map to iteratively process a dataframe?

2021-06-05 Thread Rui Barradas
Hello, This is cross-posted from StackOverflow [1]. Cross posting is not well seen on R-help and the SO post is better explained (at least the data seem to be more complete). You should have waited for an answer there. Hope this helps, Rui Barradas Às 15:03 de 04/06/21, Madison Bell

Re: [R] Can I use group_map to iteratively process a dataframe?

2021-06-05 Thread Rui Barradas
- read_csv( all_epi_files, col_types = cols( TestAssay = col_character(), Var1 = col_character(), Var2 = col_character(), Freq = col_double() )) %>% mutate(AssayNum = str_extract(TestAssay, "\\d+")) %>% group_by(AssayNum) %>% group_map(~ epi_analysis(.x

Re: [R] Need help to fix the max date filter problem in the date input

2021-06-07 Thread Rui Barradas
Hello, This is not reproducible, we don't have access to ttclasses.csv. Can you post sample data? Please post the output of dput(ttclasses) Or, if it is too big, the output of dput(head(ttclasses, 20)) Hope this helps, Rui Barradas Às 18:03 de 07/06/21, Biplab Nayak escreveu: Hi A

Re: [R] Need help to fix the max date filter problem in the date input

2021-06-07 Thread Rui Barradas
) ) # Define server logic to plot server <- function(input, output) { output$gradePlot <- renderPlot({ grade_ad = input$assessment boxplot(ttclasses$score[ttclasses$assessment==grade_ad], frame.plot=FALSE, horizontal=TRUE, col="magenta", main=grade_ad) ttcla

Re: [R] Need help to fix the max date filter problem in the date input

2021-06-08 Thread Rui Barradas
Hello, Please cc the list. R-Help is not a code writing service, it's a mailing list for doubts on R code. I'm sorry but without answers to the below questions I am not going to answer. What have you tried? What went wrong? Hope this helps, Rui Barradas Às 04:01 de 08/06/

Re: [R] aggregation of irregular interval time-series

2021-06-09 Thread Rui Barradas
Hope this helps, Rui Barradas Às 18:57 de 09/06/21, Enrico Gabrielli escreveu: Hello I just registered on the list. I am an agricultural technician and I am collaborating on a research project on agroforestry and Brown Marmorated Stink Bug (Halyomorpha halys, abbreviated BMSB). Through kob

Re: [R] Identifying words from a list and code as 0 or 1 and words NOT on the list code as 1

2021-06-11 Thread Rui Barradas
e = +str_detect(Utterance, coreWordsPat)) %>% select(ID, Utterance, Core), df %>% mutate(Fringe = str_remove_all(Utterance, coreWordsPat), Fringe = +(nchar(trimws(Fringe)) > 0)) %>% select(ID, Fringe), by = "ID" ) Hope this helps, Rui Barradas Às 18:02

Re: [R] empty data frame and POSIXct data types

2021-06-24 Thread Rui Barradas
with another with the new values. mydf2 <- data.frame() mydf2 #data frame with 0 columns and 0 rows rbind(mydf2, data.frame(data_POSIX = c(day1, day2), value = NA)) # data_POSIX value #1 2018-02-01NA #2 2018-02-02NA But once again assignment will fail, and for the same reason. Ho

Re: [R] Constructing stacked bar plot

2021-06-27 Thread Rui Barradas
ts_ctry %>% slice_max(order_by = Count, n = top_count) Hope this helps, Rui Barradas Às 17:10 de 27/06/21, Jeff Reichman escreveu: R-help Forum I am attempting to create a stacked bar chart but I have to many categories. The following code works and I end up plotting all 134 countries but

Re: [R] add a variable a data frame to sequentially count unique rows

2021-07-03 Thread Rui Barradas
Hello, Either I'm not understanding or isn't this just any of aggregate(count ~ ., data = test, FUN = length) test %>% count(group1, group2, name = "Count") ? Hope this helps, Rui Barradas Às 23:27 de 02/07/21, Yuan Chun Ding escreveu: Hi R users, In this test fi

Re: [R] conditional output of string to file n times...

2021-07-07 Thread Rui Barradas
"ABC" "ABC" "DDG" "DDG" "DDG" "DDG" "DDG" "ABB" "ABB" Hope this helps, Rui Barradas Às 14:27 de 06/07/21, Evan Cooch escreveu: Suppose I have a file with the the following structure - call the two space

<    1   2   3   4   5   6   7   8   9   10   >