Re: [R] Not seeing the results of a function

2020-03-30 Thread Eric Berger
There is also the possibility that the OP believes that the function calls are passing by reference. On Mon, Mar 30, 2020 at 5:55 PM Richard M. Heiberger wrote: > You need one more line In your function. > > addday <- function(stp,mcp,stpos,mcpos){ > stpos<-c(stpos,stp) > mcpos<-c(mcpos,mcp) >

Re: [R] ncol() vs. length() on data.frames

2020-03-31 Thread Eric Berger
A data frame is a special case of a list. It is a list of its columns. > is.list( your_data_frame ) # TRUE On Tue, Mar 31, 2020 at 4:04 PM Ivan Calandra wrote: > Dear useRs, > > I have a very simple question: > On a simple data.frame (i.e. each element is a vector), ncol() and > length() will

Re: [R] ncol() vs. length() on data.frames

2020-03-31 Thread Eric Berger
9772-243 > https://www.researchgate.net/profile/Ivan_Calandra > > On 31/03/2020 15:26, Eric Berger wrote: > > A data frame is a special case of a list. It is a list of its columns. > > > > > is.list( your_data_frame ) > > > > # TRUE > > > > > >

Re: [R] disk.frame change default directory that disk.frames are saved in?

2020-04-02 Thread Eric Berger
Rui wrote: " This is SO dependent," I think it's a typo. He meant to write "This is OS dependent" The Stack Overflow link he provided has info for both Windows and Linux. On Thu, Apr 2, 2020 at 4:59 PM Jeff Newmiller wrote: > What does SO dependent mean? Cross posted with Stack Overflow? > > Th

Re: [R] error: Error in if (any(DF[A, ] != DF[B, ])) { : missing value where TRUE/FALSE needed

2020-04-04 Thread Eric Berger
Hi Orlando, This is not a reproducible example because of the line MyGraphData <- read.graph ( file = "0.edges" , directed = FALSE ) We don't have the file "0.edges" . But here's an example that reproduces the error message. Maybe it will help you find your problem. DF <- data.frame( x=NA, y=5

Re: [R] Error with devTools

2020-04-14 Thread Eric Berger
RStudio provides a terminal window. You could print out the environment variables there and then adjust the ones in your R console session appropriately. I could give you some guidance under linux, but it seems you use Windows. Perhaps others can help with the details. On Tue, Apr 14, 2020 at 12:1

Re: [R] A simple string alienation question.

2020-04-14 Thread Eric Berger
Hi Sam, This should be straightforward. But to help out the people who could give you an answer it would be better if you could provide the information a bit more clearly as follows: 1. send your email in plain text mode. If you use gmail, when you are composing your email, you can click on the 3 d

Re: [R] A simple string alienation problem

2020-04-14 Thread Eric Berger
Hi Sam, My code below adds new columns to your data frame so you have the original columns in order to compare. (Also this could help in case there are a few rows that don't work in the full set.) > x <- read.csv("Fight.csv", stringsAsFactors = F, header = F) > x$V3 <- sub("\\\"","",x$V1) # remo

Re: [R] calculate row median of every three columns for a dataframe

2020-04-17 Thread Eric Berger
Some comments on the contributions: a) for Petr's suggestion, to return the desired structure modify the statement to t(aggregate(t(dfr), list(idx), median)[,-1]) And, although less readable, can certainly be put in a one-liner solution by removing the idx definition t(aggregate(

Re: [R] Help to download data from multiple URLs with API key

2020-04-21 Thread Eric Berger
Hi Bhaskar, Why not just create a function that does the repetitive work, such as doOne <- function( suffix ) { base_url <- "abcd" # This remains constant b <- "api_key"# the api key - this remains constant c <- paste("series_id=",suffix,sep="") full_url = paste0(

Re: [R] Error in colouring by group in core plot R

2020-04-24 Thread Eric Berger
Hi Luigi, the problem is not the first graph vs the second graph. The first graph would also show the same effect if you added type='l' to the plot command. There are various ways to approach this. A quick search turned up the following which gives you different options. https://stackoverflow.com/q

Re: [R] Help with Kmeans output and using broom to tidy etc..

2020-05-12 Thread Eric Berger
Can you create a reproducible example? Your question involves objects that are unknown to us. (geo1, trnd1_tbl) On Tue, May 12, 2020 at 2:41 PM Poling, William via R-help < r-help@r-project.org> wrote: > #RStudio Version Version 1.2.1335 need this one--> 1.2.5019 > sessionInfo() > # R version 4.0

Re: [R] Help with Kmeans output and using broom to tidy etc..

2020-05-12 Thread Eric Berger
2352 8 0.00340 > 5 CHICAGO IL2352 17 0.00723 > 6 COLUMBUS OH2352 11 0.00468 > 7 CUMMING GA2352 8 0.00340 > 8 DALLASTX2352 8 0.00340 > 9 ERIE PA

Re: [R] Sometimes commands do not terminate after upgrading to R 4.0 and Ubuntu 20.04

2020-05-12 Thread Eric Berger
Adrien, you posted this same item 3 days ago to this list. And someone responded to it. Why are you posting the identical thing again to this list? As Bert writes, you should post to the r-sig-debian list. Eric On Wed, May 13, 2020 at 4:38 AM Bert Gunter wrote: > Please, please, please ... RSt

Re: [R] Notational derivative in R

2020-05-14 Thread Eric Berger
Hi Christofer, Look at https://cran.r-project.org/web/views/NumericalMathematics.html and within that page search for Symbolic Mathematics. It shows two packages: Ryacas and rSymPy. I have no experience with them but they may be a good place to start. HTH, Eric On Thu, May 14, 2020 at 8:43 PM Ch

Re: [R] Notational derivative in R

2020-05-15 Thread Eric Berger
ing... and for > > interactive use I prefer wxMaxima and some manual translation to R. > > On May 14, 2020 10:50:56 AM PDT, Eric Berger > wrote: > > >Hi Christofer, > > >Look at https://cran.r-project.org/web/views/NumericalMathematics.html > > >and within tha

Re: [R] how to show percentage of individuals for two groups on histogram?

2020-05-21 Thread Eric Berger
Hi Ana, This is a very common question about ggplot. A quick search turns up lots of hits that answer your question. Here are a couple https://community.rstudio.com/t/trouble-scaling-y-axis-to-percentages-from-counts/42999 https://stackoverflow.com/questions/3695497/show-instead-of-counts-in-charts

Re: [R] How to use R0 package?

2020-05-22 Thread Eric Berger
Hi Luigi, I am not familiar with the R0 package but I took a quick look. The example in the documentation sets begin and end to integers. Try setting begin = 1, end = 121 and see if that works. HTH, Eric On Fri, May 22, 2020 at 1:17 PM Luigi Marongiu wrote: > > Hello, > I am trying ot get the R0

Re: [R] How to use R0 package?

2020-05-22 Thread Eric Berger
> : > If both 'begin'= 1 and 'end'= 117 are provided, they must be of the same > class (dates, character strings or integers). > ``` > > > > On Fri, May 22, 2020 at 1:51 PM Eric Berger wrote: >> >> Hi Luigi, >> how about begin=1

Re: [R] Bayesian estimation with MCMC

2020-05-23 Thread Eric Berger
Hi Christofer, Did you try web search? I entered 'R CRAN Bayesian parameter estimation with MCMC' and it came back with the following which seems relevant. https://cran.r-project.org/web/packages/airGR/vignettes/V02.2_param_mcmc.html There are other search results, such as: https://cran.r-project

Re: [R] all.equal and use.names

2020-05-28 Thread Eric Berger
Why not just reorder the elements of the list so they should match? t1 <- t1[ names(t1)[order(names(t1))]] t2 <- t2[ names(t2)[order(names(t2))]] identical(t1,t2) On Thu, May 28, 2020 at 7:52 AM John Harrold wrote: > Is there a way to compare t1 and t2 above such that the name is used > ins

Re: [R] bug or just me

2020-05-30 Thread Eric Berger
Hi Martin, This is a known bug. Definitely related to Ubuntu (debian), libopenblas and possibly specific hardware. Here's a bug report on the Debian list https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=961725 Best, Eric On Sun, May 31, 2020 at 4:38 AM Bert Gunter wrote: > No clue. > > Worke

Re: [R] Package installation problem

2020-06-03 Thread Eric Berger
Hi John, This is a bit off-topic for this mailing list as your issue is a linux, specifically Fedora, issue, and not R. I don't use Fedora but I did a quick Google search on fedora missing package .pc file and that came back with a lot of hits. This one in particular should be a good place to

Re: [R] Error plotting the results form a Holt Winters model with no seasonality

2020-06-19 Thread Eric Berger
Hi Jeff, I tried to reproduce your problem with the package's example and I did not get an error. Here's the output from my sessionInfo(). R version 3.6.3 (2020-02-29) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 18.04.3 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-g

Re: [R] How to use mle2 function?

2020-06-30 Thread Eric Berger
Hi Luigi, I took a quick look. First error: You wrote O = mle2(minuslogl = holling, start = list(a = A, h = B, x = X)) it should be b=B (h is not an argument of holling()) The error message gave very precise information! Second error: You wrote O = mle2(minuslogl = nll, start = list(a = A, h =

Re: [R] How to use mle2 function?

2020-06-30 Thread Eric Berger
use the log-likelihood function: > ``` > O = mle2(minuslogl = nll, start = list(p = c(A, B), n = 5720, x = X)) > > Error in mle2(minuslogl = nll, start = list(p = c(A, B), n = 5720, : > some named arguments in 'start' are not arguments to the specified > log-li

Re: [R] Help with effectsize package

2020-07-02 Thread Eric Berger
Hi Emma, You write "I get numbers that are exponential (e.g., 1.877030e+01) " 1.877030e+01 is scientific notation. It means 1.877030 * 10 ( = 18.7703). This seems like a perfectly good percentile. HTH, Eric On Thu, Jul 2, 2020 at 4:12 PM Emma Parrish wrote: > Hello all, > I am having some t

Re: [R] Fwd: Help with looping a function over a list of dataframes:

2020-07-04 Thread Eric Berger
Hi Kathan, How about trying to create a *minimal* reproducible example, e.g. with a list of two data frames, where each data frame has 5 rows,? My guess is that there is a good chance that when you try to create such an example, you will discover the problem yourself. In the event that you create t

Re: [R] [External] challenging data merging/joining problem

2020-07-06 Thread Eric Berger
Hi Christopher, This seems pretty standard and straightforward, unless I am missing something. You can do the "full join" without changing variable names. Here's a small code example with two tibbles, a and b, where the column 'x' in a corresponds to the column 'u' in b. a <- tibble(x=1:15,y=21:35

Re: [R] Character (1a, 1b) to numeric

2020-07-10 Thread Eric Berger
xn <- as.numeric(sub("c",".7",sub("b",".5",sub("a",".3",xc On Sat, Jul 11, 2020 at 5:09 AM Richard O'Keefe wrote: > This can be done very simply because vectors in R can have > named elements, and can be indexed by strings. > > > stage <- c("1" = 1, "1a" = 1.3, "1b" = 1.5, "1c" = 1.7, > +

Re: [R] Year and month from a sequence

2020-07-15 Thread Eric Berger
Hi Milu, Jim gave a good solution. Another approach is to use standard packages and objects. In particular 'ts' (time series) objects from the stats package, and 'xts' (extensible time-series) objects from the xts package. library(xts) # construct dummy data z <- rnorm(36) # convert it into a mont

Re: [R] levels

2020-07-15 Thread Eric Berger
Hi Andy, I believe this is because R 4.0 has changed the default behavior of data.frame(). Prior to 4.0, the default was stringsAsFactors=TRUE. In 4.0, the default is stringsAsFactors=FALSE. If you run your code in R 3.6.1 and change the command to data <- data.frame(name,values,stringsAsFactors=

Re: [R] Reading help functions

2020-07-23 Thread Eric Berger
Hi Pedro, Reading R help pages definitely takes practice. Here's a tip: when you bring up the help page, scroll down to the bottom to see if there are examples (there usually are.) I find that seeing examples often provides enough information to let you figure out what you need to do. HTH, Eric

Re: [R] Windows, R version 4.0.2, read.csv() - -Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'hw1_data': No such file or

2020-07-24 Thread Eric Berger
What happens when you give the command list.files(".","hw1_data") ? On Fri, Jul 24, 2020 at 3:53 PM Mounica Miriyala < mounicamiriyala0...@gmail.com> wrote: > HI, > I am currently taking my week 1 quiz 1. The quiz has 1 to 20 questions in > which 11 to 20 should be dealt with dataset given by th

Re: [R] Accessing the C++ source associated with the rgl function shade3d

2020-07-30 Thread Eric Berger
Duncan writes: >> " ... If you're using RStudio, a really convenient way to view the source >> ..." This is fantastic! Thank you for this Duncan. On Thu, Jul 30, 2020 at 3:45 PM Duncan Murdoch wrote: > > On 29/07/2020 6:34 p.m., Jeff Newmiller wrote: > > To begin with, don't assume it is in C++

Re: [R] Parsing a Date

2020-08-02 Thread Eric Berger
If the forecast.date column is of type character you can use lubridate to do this: > library(lubridate) > a <- "2020-08-01 12:00:00" > year(a) # [1] 2020 > month(a) # [1] 8 etc On Sun, Aug 2, 2020 at 7:24 PM Philip wrote: > Below is some Weather Service data. I would like to parse the foreca

Re: [R] add trailing dates with rbind

2020-08-12 Thread Eric Berger
Hi Frederik, (short answer) modify the assignment statement to agg_d_h <- rbind( agg_d_h, data.frame(Group.date=next_date,x=0) ) Note: replace x=0 by your-variable-name=0 Note: left-hand-side of the assignment statement should be agg_d_h (longer answer) Your approach is far from the b

Re: [R] Date Conversion Problem

2020-08-12 Thread Eric Berger
library(lubridate) a <- "20200403" lubridate::ymd(a) # 2020-04-03 HTH, Eric On Wed, Aug 12, 2020 at 5:57 PM Stephen P. Molnar wrote: > i have written an R script which allow me to plot the number of Covid-10 > cases reported by he state of Ohio. In that se t of data the date format > is in the

Re: [R] Date Conversion Problem

2020-08-12 Thread Eric Berger
t;2001-01-02" ## the default format for the print method for Date > objects > > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along and > sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County&qu

Re: [R] Reorganize the data (dplyr or other packages?)

2020-08-17 Thread Eric Berger
Alternatively, melt() from the reshape2 package. library(reshape2) melt(x,id.vars="date",measure.vars=c("down","uc","up"),variable.name ="direction",value.name="percentage") HTH, Eric On Mon, Aug 17, 2020 at 10:49 AM Thierry Onkelinx via R-help < r-help@r-project.org> wrote: > You are looking

Re: [R] Reorganize the data (dplyr or other packages?)

2020-08-17 Thread Eric Berger
swer does not > ensure that a reasonable answer can be extracted from a given body of data. > ~ John Tukey > > /////// > > <https://www.inbo.be> > > > Op ma 17 aug. 2020 om 09:52 schre

Re: [R] Change how minpack.lm:::summary.nls.lm calculates degrees of freedom

2020-08-19 Thread Eric Berger
Hi Valerio, I did a copy-paste on your reproducible example and I had no problem with chol(nls.out$hessian). In addition to summary() you can look at str() to display the structure of any R object. > str(nls.out) List of 9 $ par :List of 3 ..$ a: num 8.99 ..$ b: num -1.01 ..$ c: num 6.

Re: [R] & and |

2020-08-19 Thread Eric Berger
mydata[ intersect( grep("ConfoMap", mydata), grep("GuineaPigs", mydata) ) ] On Wed, Aug 19, 2020 at 6:13 PM Bert Gunter wrote: > "&" is not a regex metacharacter. > See ?regexp > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along and > sticking things int

Re: [R] filter() question

2020-08-21 Thread Eric Berger
Hi Eberhard, Here is one possibility using dplyr. library(dplyr) set.seed(3) ## set up some fake data dtV <- as.Date("2020-08-01") + 0:4 x <- sample(dtV,20,repl=TRUE) provider <- sample(LETTERS[1:3],20,repl=TRUE) lDf <- data.frame(Provider=provider,CollectionDate=x,stringsAsFactors=FALSE) ## get

Re: [R] Importing data using Foreign

2020-08-26 Thread Eric Berger
Hi Elham, You are not giving us much to go on here. Show us the commands that (a) confirm there are no NA's in the first column of z and (b) output a row of z that has an NA in the first column. Here's how one might do this: (a) sum(is.na(z[,1])) (b) z[ match(TRUE, z[,8] %in% c("11","12","14")), ]

Re: [R] Importing data using Foreign

2020-08-26 Thread Eric Berger
Good point! :-) On Wed, Aug 26, 2020 at 5:55 PM peter dalgaard wrote: > Offhand, I suspect that the NAs are in the 8th column. > > > On 26 Aug 2020, at 10:57 , Elham Daadmehr wrote: > > > > Hi all, > > > > I have a simple problem. I get stuck in using the imported spss data > (.sav) > > using

Re: [R] Importing data using Foreign

2020-08-26 Thread Eric Berger
c(1:3)[c(1,NA,3)] [1] 1 NA 3 On Wed, Aug 26, 2020 at 6:06 PM Elham Daadmehr wrote: > Thanks guys. but I'm a bit confused. the input is the first column (z[,1] > and z1[,1]). > How is it possible that a subset of a non-NA vector, contains NA? > > On Wed, Aug 26, 2020 at

Re: [R] Some R code works on Linux, but not Linux via Windows Subsystem Linux

2020-09-08 Thread Eric Berger
Hi Robert, You don't provide a self-contained reproducible example, so I am just guessing here. I doubt your theory that the error is related to R. More likely the step that creates a data frame from reading the CSV is probably resulting in different data frames in the two cases. I recommend that y

Re: [R] Is there a sexy way ...?

2024-09-27 Thread Eric Berger
v <- as.numeric(matrix(unlist(x),ncol=5,byrow=TRUE)) v [1] 7 2 6 13 5 9 1 14 15 4 8 12 10 11 3 On Fri, Sep 27, 2024 at 8:33 AM Deepayan Sarkar wrote: > > > unsplit(x, f) > [1] 7 2 6 13 5 9 1 14 15 4 8 12 10 11 3 > > Is more general (works if the subgroups are imbalanced), and

Re: [R] Problem installing some r-packages via spack

2024-11-26 Thread Eric Berger
I have never used Spack but I took a quick look at their website. They have the option to install binaries. Perhaps this could work for you and avoid the compilation error. Here is where they describe how to do it: https://spack.io/spack-binary-packages/ On Wed, Nov 27, 2024 at 9:29 AM Oren Shani

Re: [R] Possible bug in direct.evidence.plot?

2025-01-06 Thread Eric Berger
might work but netmetabin may cause problems. > I'll notify Mathias Harrer! > > BW > Miland > > -- > *From:* Eric Berger > *Sent:* 06 January 2025 08:24 > *To:* Miland Joshi > *Cc:* r-help@R-project.org > *Subject:* Re: [R] Possible

Re: [R] Possible bug in direct.evidence.plot?

2025-01-06 Thread Eric Berger
The explanation is likely that class(x) returns a character vector of length > 1. If you go into the code you can achieve what is probably intended without triggering this error by replacing that statement with the following: if (inherits(x,"netmeta")) ... HTH, Eric On Mon, Jan 6, 2025 at 9:57 

Re: [R] dplyr summarize by groups

2024-11-23 Thread Eric Berger
This is because options(digits=3) specifies the number of significant digits, not the number of decimal places. See ?options and search for digits. > a <- 12.345 > options(digits=4) > print(a) [1] 12.35 > options(digits=5) > print(a) [1] 12.345 > options(digits=2) > print(a) [1] 12 > On Sat, Nov

Re: [R] Weird tcl error with R on WSL Ubuntu

2025-03-23 Thread Eric Berger
Hi Erin, I plugged your question into CatGPT 4o and it gave the following message, which might help: If R was installed *before* you installed the Tcl/Tk development packages, it might not have been built with Tcl/Tk support. Check if R has Tcl/Tk support: > capabilities("tcltk") If that return

<    1   2   3   4   5   6