Re: [R] Using options(max.print = 1000000) to read in data

2019-07-08 Thread Rui Barradas
, to have an idea of the data I would rather further limit the number of matrix lines printed with head(object) tail(object) Hope this helps, Rui Barradas On Mon, Jul 8, 2019 at 10:16 AM Kevin Thorpe wrote: On Jul 8, 2019, at 10:06 AM, Spencer Brackett < spbracket...@saintjosephhs.

Re: [R] Using options(max.print = 1000000) to read in data

2019-07-08 Thread Rui Barradas
of 173 variables: There are 173 variables eac h with the same number of observations, 20530. When you read in data files with any form of read.table (read.csv is the same function with different arguments default values set), you will always get a data.frame. Hope this helps, Rui Barra

Re: [R] Capturing positive and negative changes using R

2019-07-20 Thread Rui Barradas
untry'. See in base R ?aggregate ?tapply ?ave ?by And there's also contributed packages, such as dplyr and data.table. If you can repost your data, setting your e-mail client to plain text, we will be able to say more. Hope this helps, Rui Barradas Às 20:33 de 20/07/19, Faradj Kolie

Re: [R] Printing vector

2019-07-21 Thread Rui Barradas
} A[nrow(A), 1:remainder] <- x[(len*passes + 1):n] A } print0(rnorm(23), 10) print0(rnorm(23), 10, fill = 0) Hope this helps, Rui Barradas Às 21:34 de 20/07/19, Steven escreveu: Dear All: Below is what I meant. Procedure print0 allows me to print a vector of length 53 in four rows of 10 plu

Re: [R] Printing vector

2019-07-22 Thread Rui Barradas
en*m + 1):n], rep(fill, len*(m + 1) - n))) } A } Hope this helps, Rui Barradas Às 07:47 de 22/07/19, Rui Barradas escreveu: Hello, Maybe something like the following is what you want. I have added an extra argument 'fill' to allow to choose what to print in the end. It's defa

Re: [R] Printing vector

2019-07-22 Thread Rui Barradas
m <- n %/% len remainder <- n %% len A <- matrix(x[seq_len(len*m)], ncol = len) if(remainder > 0){ A <- rbind(A, c(x[(len*m + 1):n], rep(fill, len*(m + 1) - n))) } print(A, na.print = "") } print0c(rnorm(23), 10) print0c(2^(1:23), 10) Hope this helps, Rui Barr

Re: [R] Reading recurring data in a text file

2019-07-24 Thread Rui Barradas
ps, reserve memory beforehand. wc <- vector("list", length = length(mc_list)) tmp <- vector("list", length = length(tmp_list)) are much better than your wc <- list() tmp <- list() Maybe I will find ways to save time with the really slow instructions. Hope this

Re: [R] Reading recurring data in a text file

2019-07-24 Thread Rui Barradas
Hello, Instead of read.table use data.table::fread It's an order of magnitude faster and all you have to do is to change the function, all arguments are the same (in this case). Hope this helps, Rui Barradas Às 20:18 de 24/07/19, Rui Barradas escreveu: Hello, This is far f

Re: [R] Modelos neural netwok

2019-07-27 Thread Rui Barradas
Hope this helps, Rui Barradas Às 18:41 de 27/07/19, Agustín Alonso Rodriguez escreveu: Estimados miembros de la Lista: Me dirijo a vosotros para que, si pod�is, ilumin�is mi confusi�n. Estoy trabajando con los modelos neural netwok del libro Forecasting, Principles and Practic

Re: [R] Monte carlo Simulation

2019-07-29 Thread Rui Barradas
learn Monte Carlo simulation and go through the many examples that can be found on-line. Then come back with *code* that doesn't work, or that doesn't do what you expect it to do, or a similar problem. Hope this helps, Rui Barradas Thank you [[alternative HTML versi

Re: [R] ggplot - position=position_dodge()) and scale_y_continuous

2019-07-30 Thread Rui Barradas
ion_dodge()) + theme_minimal() + scale_fill_manual(values = c("blue", "red")) + scale_x_continuous(breaks = 1:12) + scale_y_discrete(limits = c(0, 100)) Hope this helps, Rui Barradas Às 10:50 de 30/07/19, Knut Krueger via R-help escreveu: Hello to all, how can I can set both  y a

Re: [R] Plotting hclust() results

2019-08-06 Thread Rui Barradas
4 4 -1.3 -1.13 -1.78 -0.05 -0.23 -0.23 5 5 -1.6 -1.3 -1.34 -0.23 -0.45 -0.45 ", header = TRUE) Hope this helps, Rui Barradas Às 03:25 de 06/08/19, reichm...@sbcglobal.net escreveu: R Help Forum I have output from hierarchal clustering and want to plo

Re: [R] how to reverse colors on boxplot

2019-08-08 Thread Rui Barradas
pch = 20, col = rgb(0, 0, 0, 0.5), jitter = 0.001) Hope this helps, Rui Barradas Às 18:49 de 08/08/19, Ana Marija escreveu: Hello, I made plot in attach using: boxplot(flcn_M~subject,data=dx,col = c("royalblue1","palevioletred1"),xlab="subjec

Re: [R] vectorizing the integrate function

2019-08-10 Thread Rui Barradas
_j[[k]]$abs.error } } } Hope this helps, Rui Barradas Às 21:14 de 10/08/19, ravi via R-help escreveu: Bert,Thanks a lot for your help. I have a few follow-up questions (shown in the comment lines).  Numerical values and error for a (i) vector and (ii) array. a <- seq(from=0,to=1,

Re: [R] ggplot2 fill problem in colour shading

2019-08-11 Thread Rui Barradas
= factor(fill) and the graph is exactly the same. Which leads me to propose an easier way of creating the vector 'fill', in the first place. fill <- as.integer((5 < x) & (x < 7.5)) Will give the same result, coerce to factor if you like. Hope this helps, Rui Barradas Às

Re: [R] Help

2019-08-11 Thread Rui Barradas
Hello, This seems to be the site you want, not CRAN. http://gecon.r-forge.r-project.org/ And please no HTML, post in plain text. Hope this helps, Rui Barradas Às 02:01 de 11/08/19, tanyi_cm2000--- via R-help escreveu: Hi,my name is; William, a graduate student in the Department of

Re: [R] Trying to understand how to sort a DF on two columns

2019-08-13 Thread Rui Barradas
esides, if this goes into a function all temporary variables will be gone and the memory released, in which case there will be no problem. (The with equivalent is i <- with(temp, order(patid, time)), btw.) Hope this helps, Rui Barradas Às 03:20 de 13/08/19, Sorkin, John escreveu: I want to

Re: [R] Partition a vector into select groups with fixed length

2019-08-18 Thread Rui Barradas
t;- c(1, rep(0, n - 1)) f <- rep(f, length.out = length(x)) f <- cumsum(f) } split(x, f) } breakVec(LETTERS) breakVec(LETTERS, 4) breakVec(LETTERS, 1) breakVec(LETTERS, -1) Hope this helps, Rui Barradas Às 19:01 de 18/08/19, Christofer Bogaso escreveu: Hi, Let say I have a ve

Re: [R] Partition a vector into select groups with fixed length

2019-08-18 Thread Rui Barradas
Hello, Bert's modular arithmetic way simplifies my code a lot. breakVec <- function(x, n = 5){ if(n < 1) stop(paste("Illegal value n:", n)) f <- if(n == 1) "" else (seq_along(x) - 1) %/% n split(x, f) } Hope this helps, Rui Barradas Às 20:08 de 18/08/

Re: [R] Code that works when run as straight code, but that fails when run as a function

2019-08-23 Thread Rui Barradas
) s2E <- s2a$Estimate Is s1as1E a typo? The way you define and use s2E suggests that it should be s1E <- s1a$Estimate Hope this helps, Rui Barradas Time <- c(1,2) SBP <- c(s1E,s2E) plot(Time,SBP) title("Predicted Sys SBP, age 5.99 yr (SS 524 obs with BP 190mmHg removed)"

Re: [R] Colouring selected columns in a facetted column chart

2019-08-25 Thread Rui Barradas
fill = col), show.legend = FALSE) + scale_fill_manual(values = levels(col)) + facet_wrap(~ Country, ncol = 3) + theme(axis.text.x = element_text(angle = 50, hjust = 1)) Hope this helps, Rui Barradas Às 04:21 de 25/08/19, Eric Berger escreveu: This seems to work ggplot(t1) + geom_col(ae

Re: [R] creating a line plot for time series data for several years

2019-09-04 Thread Rui Barradas
(x = as.factor(DATE), y = abundance, colour = site)) + geom_line(aes(group = year)) + theme_bw() Ab + facet_grid(year ~ .) + theme(axis.text.x = element_text(angle = 90, hjust = 1, size = 4)) Hope this helps

Re: [R] P-values Kolmogorov–Smirnov test

2019-09-05 Thread Rui Barradas
he sense of function identical(), meaning they are *exactly* the same. Why shouldn't they? Hope this helps, Rui Barradas Às 17:06 de 05/09/19, Boo G. escreveu: Hello, I am trying to perform a Kolmogorov–Smirnov test to assess the difference between a distribution and samples drawn prop

Re: [R] P-values Kolmogorov–Smirnov test

2019-09-05 Thread Rui Barradas
th(d_2)) #kolmogorov-smirnov distance x <- f_d_1(d_2) y <- f_d_2(d_2) ht <- ks.test(x, y) d_stat[i, 2] <- ht$statistic d_stat[i, 3] <- ht$p.value } Hope this helps, Rui Barradas Às 19:29 de 05/09/19, Rui Barradas escreveu: Hello, I don't have the algorithms

Re: [R] P-values Kolmogorov–Smirnov test

2019-09-05 Thread Rui Barradas
ser to a uniform with increasing sizes. Try hist(d_stat[801:1000, 3]) [1]https://www.jstatsoft.org/article/view/v008i18 Hope this helps, Rui Barradas 2) Also in this case the p-values don’t make much sense, according to my previous interpretation. Again, I could be wrong in my inter

Re: [R] P-values Kolmogorov–Smirnov test

2019-09-05 Thread Rui Barradas
ered a chi-squared GOF test? Hope this helps, Rui Barradas Às 20:51 de 05/09/19, Boo G. escreveu: Hello and thanks for your patience. As far as I understand, the paper of Marsiglia and colleagues refers to CDF samples (i.e. from a hypothetical distribution — e.g. a Poisson), while I have an ECDF s

Re: [R] R bar chart

2019-09-07 Thread Rui Barradas
Hello, There is no attached file, R-help is doesn't allow many file types. Try reposting with the extension .txt or post the output of dput(head(dataset, 20)) directly in your e-mail. Hope this helps, Rui Barradas Às 10:58 de 07/09/19, farshad goudarzian escreveu: Hello. Here I att

Re: [R] new_index

2019-09-07 Thread Rui Barradas
14, 20, 8 ", stringsAsFactors = FALSE) dat2 <- read.csv(text=" ID, weight A, 0.25 B, 0.42 C, 0.65 ", stringsAsFactors = FALSE) Simpler, no? Hope this helps, Rui Barradas Às 20:23 de 07/09/19, Val escreveu: Hi all Correction for my previous posting. dat2 should be read

Re: [R] new_index

2019-09-08 Thread Rui Barradas
Hello, Bert: Quoting Jeff, "Val has been posting to this list for almost a decade". I didn't know about the "decade" part (didn't look it up) but that's why I answered the question. Val: It's not that hard to run the code you post *before* posting i

Re: [R] how to split a column by tab ?

2019-09-09 Thread Rui Barradas
emed more appropriate (?). s <- strsplit(as.character(daT1), "[[:blank:]]+") x <- lapply(s, function(.s) .s[!grepl("[[:alpha:]]+", .s)]) daT3 <- as.data.frame(do.call(cbind, x)) daT3 Hope this helps, Rui Barradas Às 12:54 de 09/09/19, Marna Wagley escreveu: Hi R User,

Re: [R] how to split a column by tab ?

2019-09-09 Thread Rui Barradas
- nms daT3 Hope this helps, Rui Barradas Às 16:28 de 09/09/19, Marna Wagley escreveu: Thank you Rui. it helped a lot. Sincerely, MW On Mon, Sep 9, 2019 at 6:47 AM Rui Barradas <mailto:ruipbarra...@sapo.pt>> wrote: Hello, You could try a character class instead of one

Re: [R] Choosing specific Date Range from non-sequential Date

2019-09-09 Thread Rui Barradas
17 -2.25359807972754 1998-05-21 -2.55799006865995 1999-08-22 -2.25114162617707 1999-08-25 -1.47905397376409 1999-09-05 -0.641589808755325 1999-09-09 -0.648954682695949 1999-09-13 -0.726364489272492 1999-09-16 -1.28445236942011 ") Hope this helps, Rui Barradas Às 20:14 de 09/09/19, Ogbos Okike

Re: [R] Query about calculating the monthly average of daily data columns

2019-09-12 Thread Rui Barradas
Hello, Please include data, say dput(head(data, 20)) # post the output of this But, is the problem as simple as rowMeans(data[2:3], na.rm = TRUE) ? Hope this helps, Rui Barradas Às 15:53 de 12/09/19, Subhamitra Patra escreveu: Dear R-users, I have daily data from 03-01-1994 to 29-12

Re: [R] Query about calculating the monthly average of daily data columns

2019-09-12 Thread Rui Barradas
lt;- merge(aggA, aggB) head(MonthReturns) Final clean up. rm(date, month, aggA, aggB) Hope this helps, Rui Barradas -- Bert On Thu, Sep 12, 2019 at 8:41 AM Rui Barradas <mailto:ruipbarra...@sapo.pt>> wrote: Hello, Please include data, say dput(head(data, 20))  # post

Re: [R] If Loop With Lagged Variable

2019-09-19 Thread Rui Barradas
Not tested, since there is no data.) Hope this helps, Rui Barradas Às 17:27 de 19/09/19, Phillip Heinrich escreveu: Attached is every at bat for the Arizona Diamondback’s first three games of 2018 – BBdata1.rda. I added the Date and DHCode variables by parsing the first variable labeled Gam

Re: [R] If Loop With Lagged Variable

2019-09-19 Thread Rui Barradas
#7 2018-03-30 2 #8 2018-03-30 2 #9 2018-04-01 3 #10 2018-04-01 3 #11 2018-04-01 3 #12 2018-04-01 3 Hope this helps, Rui Barradas Às 22:09 de 19/09/19, Rui Barradas escreveu: Hello, There was no attachment, R-Help allows only a limited number of file t

Re: [R] Loop With Dates

2019-09-20 Thread Rui Barradas
Hello, Maybe I am not understanding but isn't this what you have asked in your previous question and my 2nd post (adapted) does? If not, where does it fail? Hope this helps, Rui Barradas Às 18:46 de 20/09/19, Phillip Heinrich escreveu: With the data snippet below I’m trying to incr

Re: [R] Creating a simple function

2019-09-20 Thread Rui Barradas
Hello, Something like this? ctab <- function(data) { gmodels::CrossTable(as.matrix(data), prop.chisq = FALSE, prop.c = FALSE, prop.t = FALSE, format = "SPSS") } mtcars %>% select(cyl, gear) %>% ctab() Hope this helps, Rui Barradas Às 16:30 de 20/09/19, Zachary Lim

Re: [R] 95% bootstrap CIs

2019-09-23 Thread Rui Barradas
Hello, Is this what you are looking for? ci95 <- apply(my.data, 2, quantile, probs = c(0.025, 0.975)) Hope this helps, Rui Barradas Às 20:42 de 23/09/19, varin sacha via R-help escreveu: Dear R-Experts, Here is my reproducible R code to get the Mean squared error of GAM and MARS afte

Re: [R] 95% bootstrap CIs

2019-09-25 Thread Rui Barradas
bootResults <- boot(data=data, statistic=mse, R=1000) boot.ci(bootResults, type = boot.ci.type) Hope this helps, Rui Barradas Às 13:43 de 25/09/19, varin sacha via R-help escreveu: Dear R-experts, Below the reproducible example. I have tried to write a function that returns the statistic of

Re: [R] Real Basic Question

2019-09-27 Thread Rui Barradas
ew environment and load the data there might be sound advice. Check if your data set exists in the .GlobalEnv first, then load() it. ls(pattern = "^ari", envir = .GlobalEnv) Hope this helps, Rui Barradas Às 18:06 de 26/09/19, Duncan Murdoch escreveu: On 26/09/2019 12:55 p.m., Phill

Re: [R] stats::lm has inconsistent output when adding constant to dependent variable

2019-09-27 Thread Rui Barradas
23 1 Hope this helps, Rui Barradas Às 18:05 de 27/09/19, David J. Birke escreveu: Dear R community, I just stumbled upon the following behavior in R version 3.6.0: set.seed(42) y <- rep(0, 30) x <- rbinom(30, 1, prob = 0.91) # The following will not show any

Re: [R] mapple

2019-10-02 Thread Rui Barradas
pply(phdf[-6], 1, function(x){ 1*all(x == 0) + # rule 1 2*(x[1] == 1 & x[2] == 1) + # rule 2 3*(x[1] == 0 & x[2] == 1 & x[3] == 2) # rule 3 }) phdf$code <- ifelse(i == 0, phdf$code, new_values[i]) Hope this helps, Rui Barradas Às 04:24 de 02

Re: [R] can not extract rows which match a string

2019-10-03 Thread Rui Barradas
Hello, You have to use is.na to get the NA values. t1 <- data.frame(sex_chromosome_aneuploidy_f22019_0_0 = c(NA, "Yes"), other = 1:2) i <- t1$sex_chromosome_aneuploidy_f22019_0_0 == "Yes" & !is.na(t1$sex_chromosome_aneuploidy_f22019_0_0) i t

Re: [R] can not extract rows which match a string

2019-10-03 Thread Rui Barradas
Hello, Then it's easier, is.na alone will do it. j <- is.na(t1$sex_chromosome_aneuploidy_f22019_0_0) t1[j, ] Hope this helps, Rui Barradas Às 20:29 de 03/10/19, Ana Marija escreveu: Hi Rui, sorry for confusion, I would only need to extract from my t1 dataframe rows which ha

Re: [R] can not extract rows which match a string

2019-10-03 Thread Rui Barradas
a(.) !i means (.) != "Yes" Hope this helps, Rui Barradas Às 21:21 de 03/10/19, Rui Barradas escreveu: Hello, Then it's easier, is.na alone will do it. j <- is.na(t1$sex_chromosome_aneuploidy_f22019_0_0) t1[j, ] Hope this helps, Rui Barradas Às 20:29 de 03/10/19, Ana Marija

Re: [R] my question is how to read pvcm file

2019-10-04 Thread Rui Barradas
estions on R code, not to search (R related?) stuff for you. 3. At an R prompt run install.packages('sos') sos::findFn('pvcm file') It yields nothing of relevance. Hope this helps, Rui Barradas Às 12:00 de 04/10/19, Jui-Kun Chiang via R-help escreveu: Dear Sir,

Re: [R] how to select all columns that contain in any of their rows a partial match for a string?

2019-10-05 Thread Rui Barradas
Hello, Try the following cols <- sapply(tot, function(x) any(grepl("^E94", x))) To have the column numbers, which(cols) Hope this helps, Rui Barradas Às 19:50 de 05/10/19, Ana Marija escreveu: Hello, I have a data frame tot which has many columns and many rows. I am tryin

Re: [R] how to select all columns that contain in any of their rows a partial match for a string?

2019-10-05 Thread Rui Barradas
, x)) e10 <- rowSums(e10) > 0 e11 <- sapply(tot, function(x) grepl("^E11", x)) e11 <- rowSums(e11) > 0 tot$newcol <- -9 tot$newcol[e10] <- 1 tot$newcol[e11] <- 2 On both cases the 2 lines sapply/rowSums can be made one with rowSums(sapply(...)) > 0 Hope this he

Re: [R] how to read this kind of csv in R?

2019-10-06 Thread Rui Barradas
tmp), text = unlist(strsplit(tmp, ","))) }) n <- max(sapply(tmp, '[[', 'n')) tmp <- lapply(tmp, function(x) as.numeric(x$text)) tmp[[1]] <- rep(tmp[[1]], each = n) res <- do.call(cbind.data.frame, tmp) names(res) <- lns[i_title] res If you have hundreds of fil

Re: [R] how to read this kind of csv in R?

2019-10-07 Thread Rui Barradas
t;- cbind.data.frame(first, res) names(res) <- sub("\\[.*\\]$", "", lns[i_title]) res } df1 <- readCSVFile("strange.csv") If this function doesn't do it, please try to make an effort on your own, R-Help is not a code writing service, it's a mail li

Re: [R] Creating a histogram from a frequency vector

2019-10-09 Thread Rui Barradas
Hello, Here are 3 ways. The first are almost the same, they use base graphics. x <- 1:6 y <- c(73,53,42,67,41,50) barplot(setNames(y, x)) Or names(y) <- x barplot(y) And 3: library(ggplot2) ggplot(data.frame(x, y), aes(x, y)) + geom_col() Hope this helps, Rui Barradas Às

Re: [R] Bar Charts

2019-10-16 Thread Rui Barradas
UE)[nvec] x[i[order(i)]] }else{ sort(x, decreasing = TRUE)[nvec] } } barplot(TopN(CONTBR_RESULT, 15)) barplot(TopN(CONTBR_RESULT, 15, TRUE)) Hope this helps, Rui Barradas Jim On Wed, Oct 16, 2019 at 11:21 AM wrote: r-help forum I have a database that I have performed a "

Re: [R] List of data frame

2019-10-19 Thread Rui Barradas
na.strings = "8888") }) Hope this helps, Rui Barradas Às 02:38 de 18/10/19, ani jaya escreveu: Dear R-Help, I have a list of data frame that I import from excel file using read.xlsx command. sheets <- openxlsx::getSheetNames("rainfall.xlsx") test <- lapply(sheets,functio

Re: [R] Retaining attributes of columns of a data frame when subsetting.

2019-10-20 Thread Rui Barradas
a2") <- "second_a" str(X) ok <- c(1, 3, 4) X <- X[ok, ] str(X) Hope this helps, Rui Barradas Às 03:13 de 20/10/19, Rolf Turner escreveu: On 20/10/19 3:00 PM, Richard M. Heiberger wrote: Look at methods(as.data.frame) Define your specialized columns to have a newly defi

Re: [R] Query about calculating the monthly average of daily data columns

2019-10-20 Thread Rui Barradas
df1$DATE %/% 100 aggregate(Spread ~ PERMNO + MONTH, df1, mean) Hope this helps, Rui Barradas Às 17:17 de 20/10/19, jim holtman escreveu: Does this do what you want: library(tidyverse) input <- read_delim("PERMNO DATE Spread + 111 19940103 0.025464308 + 111 19940104 0.064424296 +

Re: [R] Retaining attributes of columns of a data frame when subsetting.

2019-10-20 Thread Rui Barradas
{ attributes(x[[nm]]) <- Sat[[nm]] x[[nm]]}, x = x, Sat = SaveAt) names(lX) <- names(x) x <- as.data.frame(lX) x } The (frequent) error comes from tests where a X was created in the globalenv and found by the method. Rui Barradas Às 22:55 de 20/10/19, Rolf Turner escre

Re: [R] About vargha effect size

2019-10-21 Thread Rui Barradas
t the right place to ask, R-Help is about R *code* not statistics. For questions about statistics see Cross Validated [1] [1] https://stats.stackexchange.com Hope this helps, Rui Barradas Às 10:21 de 21/10/19, javed khan escreveu: I have two samples A and B in excel and I want to use the vargh

Re: [R] Heatmap

2019-10-21 Thread Rui Barradas
Hello, Just do col = rev(heat.colors(256)) ? Hope this helps, Rui Barradas Às 12:55 de 21/10/19, Eleftheria Dalmaris escreveu: Hello all, I have made the attached heat map without a problem. On this heat map, the yellows are my high values and the oranges are my low values. Is there a way

Re: [R] negative vector length when merging data frames

2019-10-24 Thread Rui Barradas
asign <- data.table::fread(asign_file) # extract the relevant rows and merge res <- l4[i1, ] res2 <- asign[i2, setdiff(names(asign), names(l4))] merge(res, res2, by.x = c("X1", "X2"), by.y = c("chr", "pos")) Hope this helps, Rui Barradas

Re: [R] Matching Values issue

2019-10-25 Thread Rui Barradas
Hello, That's a floating-point issue. See FAQ 7.31. See also [1], [2] and the links therein. [1] https://stackoverflow.com/questions/9508518/why-are-these-numbers-not-equal [2] https://stackoverflow.com/questions/588004/is-floating-point-math-broken Hope this helps, Rui Barradas Às

Re: [R] " Error in firstnonmiss:lastnonmiss : argument of length 0 "

2019-10-30 Thread Rui Barradas
Hello, Is this as simple as if ( (!is.na(dts[1,j-1])) & (!is.na(dts[3,j-1])) ) { (change the logical operator from '|' to '&')? The result vseries1 still has some NA's at the end of some of its series. Hope this helps, Rui Barradas Às 02:05 de 30/10/19, p

Re: [R] " Error in firstnonmiss:lastnonmiss : argument of length 0 "

2019-10-30 Thread Rui Barradas
Hello, Another option that prevents length(x) == 1 is to use NROW(x) instead of length(x). Hope this helps, Rui Barradas Às 16:58 de 30/10/19, William Dunlap escreveu: Your EXTEND() function appears to expect that its 'x' argument will be a numeric vector, but you pass it a

Re: [R] transforming dates

2019-11-03 Thread Rui Barradas
the same for all vector elements, if not y <- c('11/7/2016', '14-07-16', '2016/7/11') lubridate::dmy(y) #[1] "2016-07-11" "2016-07-14" NA #Warning message: # 1 failed to parse. Hope this helps, Rui Barradas Às 02:25 de 03/11/19, reichm...@sbcglo

Re: [R] how to find number of unique rows for combination of r columns

2019-11-08 Thread Rui Barradas
Hello, If performance is important, and with 73M rows it probably is, take a look at this StackOverflow post. [1] https://stackoverflow.com/a/36058634/8245406 Hope this helps, Rui Barradas Às 21:33 de 08/11/19, Martin Morgan escreveu: With this example df = data.frame(a = c(1, 1, 2, 2

Re: [R] Identifying presence of Java

2019-11-09 Thread Rui Barradas
(dirname(tmpfile)) system2('java', '-version', '>', tmpfile) readLines(tmpfile) unlink(tmpfile) # final cleanup Hope this helps, Rui Barradas Às 16:51 de 09/11/19, Dennis Fisher escreveu: R 3.6.3 OSX and Windows Colleagues I want to identify if Java is in

Re: [R] Identifying presence of Java

2019-11-09 Thread Rui Barradas
Hello, This error can be a 32 bits vs 64 bits thing. R and java must have the same architecture. If you have 64b Java installed, don't run 32b R. And vice-versa. Hope this helps, Rui Barradas Às 18:53 de 09/11/19, Dennis Fisher escreveu: Dirk I am now more confused (and I appreciate

Re: [R] data load from excel files

2019-11-13 Thread Rui Barradas
n1, function(DF){ format(DF[["Tanggal"]][1], "%Y-%m") }) pon1 <- pon1[order(inx_ym)] # get the minimum and maximum of every "RR" min.RR <- sapply(pon1, function(DF) min(DF[["RR"]], na.rm = TRUE)) max.RR <- sapply(pon1, function(DF) max(DF[["RR&qu

Re: [R] data load from excel files

2019-11-13 Thread Rui Barradas
Hello, Try which.max? Hope this helps, Rui Barradas Às 14:10 de 13/11/19, ani jaya escreveu: Thank you very much Mr. Rui, but for delete the duplicated row I use: ... library(tidyverse) alldata<-data.frame(Reduce(rbind, pon1)) c<-(which(duplicated(alldata$Tanggal))) #duplicate a

Re: [R] Labeling Stacked Bar Plots Representing Percentages with Count Data

2019-11-16 Thread Rui Barradas
bels = scales::percent_format()) Hope this helps, Rui Barradas Às 23:56 de 15/11/19, Josh B escreveu: Hello, I am trying to include the count labels on stacked bar plots which represent percentages. I want to show x-amount of individuals make up the graphed percentages. However, when I include

Re: [R] Can't get facet_grid_paginate() from ggforce to work.

2019-11-17 Thread Rui Barradas
ncol = ncols)+ ylab("Success fraction") + theme_bw() print(ggplot(X) + geom_point(aes(y = Sfrac , x = x)) + facet_grid_paginate(facets = Species ~ LifeStage:degC, page = page, nrow = nrows, ncol = ncols)+ ylab("Succ

Re: [R] Can't get facet_grid_paginate() from ggforce to work.

2019-11-17 Thread Rui Barradas
w() ) } dev.off() print(plotObj[[1]]) print(plotObj[[2]]) Hope this helps, Rui Barradas Às 13:07 de 17/11/19, Rui Barradas escreveu: Hello, I don't know why but use an explicit nrow = nrows with 'nrows' defined as nrows <- length(levels(X$Species)) It seems to work (rem

Re: [R] How to save google map in r ?

2019-11-17 Thread Rui Barradas
Hello, See the docs: get_amp returns a ggmap object and ggmap returns a ggplot object. So ggsave() should do what you want. Hope this helps, Rui Barradas Às 09:48 de 17/11/19, Kristi Glover escreveu: Hi R users, I am struggling to save the map with georeferenced (TIFF) that was imported

Re: [R] Labeling Stacked Bar Plots Representing Percentages with Count Data

2019-11-17 Thread Rui Barradas
Hello, It's dificult to tell without data. Can you post the output of dput(head(tagSummary, 20)) # or 30 ? (If it's private data, something mimicking its structure.) Rui Barradas Às 02:06 de 18/11/19, Josh B escreveu: Hello Rui, I worked through your suggestion and appear to be

Re: [R] Obtaining the time to execute a R command

2019-11-20 Thread Rui Barradas
Hello, There is system.time {base} CPU Time Used Description Return CPU (and other) times that expr used. There are also packages microbenchmark or bench. Hope this helps, Rui Barradas Às 15:44 de 20/11/19, Jeff Reichman escreveu: R- Help Is there a command or way to obtain the

Re: [R] Stacking two graphs with different x and y scale on the same graph

2019-11-26 Thread Rui Barradas
;n", xlab="", ylab="") axis(side=4, at=c(-5,-1,0), labels=c("98%","100%","102%")) mtext("blue line", side=4, line=2.5, at=0) par(op) Hope this helps, Rui Barradas Às 02:53 de 27/11/19, Ogbos Okike escreveu: Dear Contribut

Re: [R] Adding a legend to a (multi-facet) plot produced by ggplot().

2019-12-01 Thread Rui Barradas
n't work",values=c(16,3), labels=c("clyde","irving")) + facet_grid(cols=vars(grp)) [1] https://stackoverflow.com/questions/2185252/reshaping-data-frame-from-wide-to-long-format Hope this helps, Rui Barradas Às 00:04 de 01/12/19, Rolf Turner

Re: [R] Still struggling with facet_grid_paginate() from package ggforce.

2019-12-01 Thread Rui Barradas
:n){ print(g + facet_wrap_paginate(~Trt, ncol = 4, nrow = 3, page = i)) } print(g) Hope this helps, Rui Barradas [1] https://stackoverflow.com/a/58373858/8245406 Às 11:46 de 01/12/19, Rolf Turner escreveu: I am trying to produce a ggplot2 graphic in which there is a single conditio

Re: [R] Adding a legend to a (multi-facet) plot produced by ggplot().

2019-12-01 Thread Rui Barradas
e","irving")) + scale_shape_manual("Doesn't work",values=c(16,3), labels=c("clyde","irving")) + facet_grid(cols=vars(grp)) Hope this helps, Rui Barradas Às 01:07 de 02/12/19, Rolf Turner escreveu: On 2/12/19 3:03 am, Rui Barradas w

Re: [R] Two geom_bar with counts to put in the same plot

2019-12-03 Thread Rui Barradas
more only with data. Hope this helps, Rui Barradas Às 09:18 de 03/12/19, Francesca escreveu: Dear Contributors, I would like to ask help on how to create a plot that is the overlapping of two other plots. It is a geom_bar structure, where I want to count the occurrences of two vari

Re: [R] Two geom_bar with counts to put in the same plot

2019-12-04 Thread Rui Barradas
0, 0, 0, 0, 0, 10, 10, 10, 30, 10, 0, 0, -10, 40, 0, 0, 10, 10, 40, 30, -10, 0, 0, 10, 20, 0, 0, 10, 40, 0, 0, -10, -20)), row.names = c(NA, -236L), class = "data.frame") Hope this helps, Rui Barradas Às 14:10 de 03/12/19, Francesca escreveu: Hi here it is;. THANKS! dput(

Re: [R] how to deal with deprecated functions

2019-12-05 Thread Rui Barradas
a package, and in this case you would even have more examples, if needed. Hope this helps, Rui Barradas Às 19:07 de 04/12/19, Nestor Toledo escreveu: Hello everyone, even I'm not fluent in coding, R has become a fundamental part of my daily work as a researcher and I'm very much

Re: [R] Two geom_bar with counts to put in the same plot

2019-12-05 Thread Rui Barradas
m_density(aes(alpha = 0.2)) + scale_alpha_continuous(guide = "none") + facet_wrap( ~ participation) Hope this helps, Rui Barradas Às 10:19 de 05/12/19, Francesca escreveu: This is a consolation, because I cannot get it in ggplot either! Thanks for the code! F.

Re: [R] Tables from Rmarkdown to Word Document - using huxtables

2019-12-11 Thread Rui Barradas
%>% set_width(0.99) %>% set_col_width(1:5, 0.99) %>% set_number_format(2) hx quick_docx(hx, file = "test.docx") There are ways of doing the same without pipes, those functions don't have the prefix 'set_'. But I believe that what's important is function ?qui

Re: [R] Tables from Rmarkdown to Word Document - using huxtables

2019-12-12 Thread Rui Barradas
") hx ``` Thank you, Ashim On Thu, Dec 12, 2019 at 12:57 PM Ashim Kapoor <mailto:ashimkap...@gmail.com>> wrote: On Wed, Dec 11, 2019 at 9:11 PM Rui Barradas mailto:ruipbarra...@sapo.pt>> wrote: Hello, This works for me: library(dplyr)

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] Newbie: Controlling legends in graphs

2023-05-12 Thread Rui Barradas
w up on top in the legend # mutate(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 =

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

2023-05-13 Thread Rui Barradas
emove 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.

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

2023-05-14 Thread Rui Barradas
p 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 pr

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

2023-05-16 Thread Rui Barradas
FALSE ) Other ways to subset the data are # dplyr 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

Re: [R] Recombining Mon and Year values

2023-05-16 Thread Rui Barradas
[1] "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:/

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

2023-06-11 Thread Rui Barradas
ich(data2$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 -

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

2023-06-11 Thread Rui Barradas
quot;)] <- "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
À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. Actually I

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

2023-06-12 Thread Rui Barradas
ll be used 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 eleme

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

2023-06-13 Thread Rui Barradas
do? 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&qu

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] 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] Create matrix with column names wiht the same prefix xxxx and that end in 1, 2

2023-07-03 Thread Rui Barradas
e commented, 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 <

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

2023-07-03 Thread Rui Barradas
ng <- c(string, 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 <- chara

<    4   5   6   7   8   9   10   11   12   13   >