Re: [R] Opening R

2019-01-20 Thread Eric Berger
Hi Sydney, This mailing list is a text-only list so your pictures are not coming through. I am guessing that you are clicking on the setup (installation) program and not on R. That would explain why you are being led to the installation process again. You can try to search for another desktop icon

Re: [R] large number of scrollable histograms....

2019-01-22 Thread Eric Berger
Another alternative is to use ggplot2 to create the various plots, then put them into a list and use cowplot::plot_grid to plot the grid of plots with a specified number of rows and columns. Here's some pseudo code to give you the general idea Step 1: generate the plots and put them into a list fo

Re: [R] Vectorizing a for-loop for cross-validation in R

2019-01-23 Thread Eric Berger
Charles writes about saving execution time by eliminating redundancies. If you see redundancies related to calling a time-consuming function multiple times with the same arguments, a very easy way to speed up your program is to memoise the functions using the package memoise. HTH, Eric On Wed,

Re: [R] Question about bindata lib in high dimensions

2019-02-11 Thread Eric Berger
Hi Eman, It helps if you create a small example that reproduces the problem and then post the code with your question. This will help people determine what is causing the problem. Best, Eric ‪On Mon, Feb 11, 2019 at 11:52 AM ‫إيمان إسماعيل محمد‬‎ < emanismail...@gmail.com> wrote:‬ > I need to s

Re: [R] Finding the Mean of a Specific Set of Columns

2019-02-14 Thread Eric Berger
Hi Isaac, I am sure you will get lots of answers to this. Here is one using the dplyr package. Assuming that your data frame is called 'a', then library(dplyr) b <- dplyr::group_by(a,plot) %>% dplyr::summarise( mean(lai) ) b # A tibble: 4 x 2 plot `mean(lai)` 1 104243. 2 10

Re: [R] Problem with combining 2 data frame

2019-02-15 Thread Eric Berger
Hi Javad, You have a number of problems with your code, such as: 1. you should set df1 and df2 without factors 2. you define a function f(x,y) but the body of the function never refers to x and y The following code does what I think you are looking for: df1 = data.frame(x1 = letters[1:26],x2 = NA

Re: [R] Obtaining values of estimates from a regression; How do I get values from a list?

2019-02-21 Thread Eric Berger
You have some choices fitchange$coefficients[2] zz$coefficients[2,1] Note that class(zz$coefficients) shows that it is a matrix. HTH, Eric On Fri, Feb 22, 2019 at 9:45 AM Sorkin, John wrote: > I am trying to obtain the coefficients from a regression (performed using > lm). I would like to

Re: [R] Which dependency list to build first?

2019-02-28 Thread Eric Berger
These two pathnames are different /usr/lib/R/library/lib/later/later.so /usr/lib/R/library/later.so Was that your intention? On Wed, Feb 27, 2019 at 11:45 PM Rich Shepard wrote: > On Wed, 27 Feb 2019, William Dunlap wrote: > > > Did you use 'R CMD ldd .../later.so', as I recommended? > > Bill

Re: [R] R installation Ubuntu 10.04 missing dependency

2019-03-03 Thread Eric Berger
Hi John, Is the subject line of your question correct? Ubuntu 10.04? If that is not a typo, that could be contributing to your problem. I believe that the current stable release of Ubuntu is 18.04. According to the following link ubuntu 10.04 was released almost 10 years ago and was "retired" about

Re: [R] rounding off problem.....

2019-03-08 Thread Eric Berger
"Is there any way ..." Two quick answers: 1. using base R functions and data types the answer is 'no' - a double (i.e. numeric) contains about 15 significant digits. So 5.678e-100 is fine but 0.01 + 5.678e-100 will keep the .0100 as the significant digits and "drop" the digits 80

Re: [R] lag function row name with

2019-03-25 Thread Eric Berger
Hi John, dplyr::lag expects a vector. The following should work dplyr::lag(temp[,1],2) HTH, Eric On Mon, Mar 25, 2019 at 9:45 AM John wrote: > Hi, > >I have a dataset whose row names corresponds to months. When I apply lag > function (dplyr package) on this dataset, I get NAs with warning

Re: [R] simulation of PowerGARCH,Threshold GARCH,and GJR GARCH

2019-03-25 Thread Eric Berger
Doing a web search on R CRAN GJR GARCH brought up the rugarch package. The models you mentioned are discussed in the documentation to that package https://cran.r-project.org/web/packages/rugarch/vignettes/Introduction_to_the_rugarch_package.pdf On Mon, Mar 25, 2019 at 2:06 PM Amon kiregu wrot

Re: [R] Fwd: Error message: object of type 'closure' is not subsettable

2019-04-01 Thread Eric Berger
You may be calling a function when you think you are referring to an array. You can reproduce this error message as follows: f <- function(x) {x} f[1] HTH, Eric On Mon, Apr 1, 2019 at 5:49 PM Simrit Rattan wrote: > hey everyone :), > Subject: Re: Error message: object of type 'closure' is not

Re: [R] Free financial data - equities, equity options and ETFs - for quantmod package (or other packages)

2019-04-03 Thread Eric Berger
You might want to post this to the group R-Sig-Finance https://stat.ethz.ch/mailman/listinfo/r-sig-finance and also check their archives On Wed, Apr 3, 2019 at 1:11 AM H wrote: > I am relatively new to analyzing financial data but have some experience > with R. I understand that the data avai

Re: [R] Create a sequence

2019-04-09 Thread Eric Berger
And just for fun, yet another way > cumsum((1:200)*c(1,-1)) On Tue, Apr 9, 2019 at 9:51 PM David L Carlson wrote: > Here's another approach: > > > x <- c(rbind(1:100, -(1:100))) > > head(x); tail(x) > [1] 1 -1 2 -2 3 -3 > [1] 98 -98 99 -99 100 -100 > > ---

Re: [R] Creating a mean line plot

2019-04-12 Thread Eric Berger
I don't have your data. Are the x-values the same in both plots? Does this example cover the situation? f1 <- function(x) { x^3 - 2 } f2 <- function(x) { 2 - x^2 } xV <- seq(from=0,to=2,length=50) y1 <- f1(xV) y2 <- f2(xV) y3 <- .5*(y1+y2) plot(x=xV,y=y1,col="blue",lwd=2,type='l',xlab="x",ylab="y

Re: [R] Is there a simple way to analyse all the data using dplyr?

2020-09-21 Thread Eric Berger
Hi, I am not sure if the request is about a 'simple way' or requires dplyr. Here's an approach without using dplyr that is just 2 lines (not counting creating the data or outputting the result). n <- 500 myDf <- data.frame( gender=sample(c("Man","Woman","Other"), n, replace = TRUE),

Re: [R] aggregate semi-hourly data not 00-24 but 9-9

2020-09-21 Thread Eric Berger
Hi Stefano, If you mean from 9am on one day to 9am on the following day, you can do a trick. Simply subtract 9hrs from each timestamp and then you want midnight to midnight for these adjusted times, which you can get using the method you followed. I googled and found that lubridate::hours() can be

Re: [R] aggregate semi-hourly data not 00-24 but 9-9

2020-09-22 Thread Eric Berger
e R as.difftime function is perfectly usable to create this offset > without pulling in lubridate. > > On September 21, 2020 8:06:51 AM PDT, Eric Berger > wrote: > >Hi Stefano, > >If you mean from 9am on one day to 9am on the following day, you can > >do a trick. S

Re: [R] highfrequency package-jump test

2020-10-10 Thread Eric Berger
Hi, I tried running your code but it is not complete. When you create the xts you refer to data$PRICE but this has never been defined. I generated synthetic data and used that to create the xts object as follows: x <- runif( length(tm), min=90, max=110 ) data<-xts(x=x,order.by=tm) When I used th

Re: [R] help for R code

2020-10-13 Thread Eric Berger
Hi Ablaye, The CRAN repository has thousands of available R packages. To help people find relevant packages amid such a huge collection, there are some 'task view' pages that group packages according to a particular task. I am guessing that you are interested in kernels because of their use in mach

Re: [R] securing R code....

2020-10-26 Thread Eric Berger
Do you make regular backups? If not, this should push you into such a routine. One approach is to use an external drive. External drives are not expensive and can typically have plenty of room to hold all your code and data. Just before having your computer serviced, copy your code and data onto th

Re: [R] Remove all factor levels from an R dataframe

2020-11-10 Thread Eric Berger
Hi John, I was thinking that you created df1 in a way that set the 'year' column as a factor when this is not what you wanted to do. The data.frame() function takes an argument stringsAsFactors which controls this behavior. For R versions 3.6.3 or earlier, the default setting is stringsAsFactors=TR

Re: [R] Subscript and superscript on one symbol; plotmath.

2020-12-09 Thread Eric Berger
Hi Rolf, This is not addressing your implementation, but reformulates the goal. Specifically, the covariance matrix is normally written as \Sigma (not \sigma^2). So to specify the upper left element you would write (in Latex) \Sigma_{11}. No superscript (so no problem!) HTH, Eric On Wed, Dec 9,

Re: [R] Error Message Cannot use `+.gg()` with a single argument. Did you accidentally put + on a new line?

2020-12-19 Thread Eric Berger
As the error message says, move the '+' sign from the start of the second line to the end of the preceding line. On Sat, Dec 19, 2020 at 10:29 PM Rosato, Kyle wrote: > For some simple reason, I am unable to see the mistake: > > ggplot(filter(nlsw88, !(is.na(union))), aes(y = wage, x = union, fi

Re: [R] Finance & R

2020-12-23 Thread Eric Berger
Hi Ben, A few comments: 1. you might want to also post this question to the more focused group r-sig-finance 2. as Duncan writes, it would be helpful if you included some topics that are not covered in the packages you mentioned 3. in my experience, the authors/maintainers of the packages you

Re: [R] Finance & R

2020-12-25 Thread Eric Berger
Hi Ben, Abby makes a good suggestion on Rmetrics, although it is no longer current in CRAN. The www.rmetrics.org site looks quite interesting (although not clear whether there are any recent additions.) The suggestion did bring to mind another excellent resource: quantlib - a library for computat

Re: [R] Defining partial list of variables

2021-01-05 Thread Eric Berger
zx<-strsplit("age,exercise,income,white,black,hispanic,base,somcol,grad,employed,unable,homeowner,married,divorced,widowed",",") On Tue, Jan 5, 2021 at 11:01 AM Steven Yen wrote: > Thank you, Jeff. IMO, we are all here to make R work better to suit our > various needs. All I am asking is an ea

Re: [R] Defining partial list of variables

2021-01-05 Thread Eric Berger
;nongov" "married" > > > x<-strsplit("hhsize,urban,male, > + gov,nongov,married",","); x > [[1]] > [1] "hhsize""urban" "male" > "\ngov" > [5] &qu

Re: [R] Defining partial list of variables

2021-01-05 Thread Eric Berger
sc" > "tert" > [9] "gov" "nongov" "married" > > > eq1<-my.formula(y="cig",x=x); eq1 > cig ~ hhsize + urban + male + age3045 + age4659 + age60 + highsc + > tert + gov + nongov + married > > eq2<-my.formula(y="c

Re: [R] Error in UseMethod("predict")

2021-01-17 Thread Eric Berger
Hi Sacha, I never used these packages before but I installed them and tried your code. I have a few observations that may help. 1. the statement ypred = predict(fit18,newdata=Testing) is wrong. Checkout the help page (?robustgam) which shows in the Examples section at the bottom to use so

Re: [R] Error in UseMethod("predict")

2021-01-17 Thread Eric Berger
> fit18<-robustgam(x,y, sp=4356,family=true.family,smooth.basis='ps',K=3) > > ypred=pred.robustgam(fit18,data.frame(X=Testing)) > MSE = mean((y-ypred)^2) > MSE > lst[i]<-MSE > } > mean(unlist(lst)) > > > >

Re: [R] rbind common header to file list

2021-01-20 Thread Eric Berger
for ( file in filelist ) On Wed, Jan 20, 2021 at 2:21 PM Miluji Sb wrote: > Thank you for your reply and the solution. Yes, I would like the date to be > the column header for all the files in the list. > > This is what tried following your suggestion; > > filelist = list.files(pattern = ".*.t

Re: [R] Concatenation?

2021-02-17 Thread Eric Berger
desired <- paste(site,depth,sep="") On Wed, Feb 17, 2021 at 11:10 PM Parkhurst, David wrote: > If I have a vector of site abbreviations and a vector of depths in those > water bodies, is there a simple way in R to combine them to make a third > vector? > Examples: > > sitedepth des

Re: [R] Out from an R package

2021-02-25 Thread Eric Berger
The str() function is your friend. Try str(Output) On Thu, Feb 25, 2021 at 12:09 PM David Winsemius wrote: > > On 2/25/21 7:24 AM, Göran Djurfeldt wrote: > > Help! I am going crazy for a very simple reason. I can’t access the > output from for instance the lme4 package in R. I have been able to

Re: [R] Column-by-column division

2021-03-03 Thread Eric Berger
Why not use standard matrix multiplication which is straightforward here: x %*% diag(1/s) HTH, Eric On Wed, Mar 3, 2021 at 7:13 AM Harold Doran < harold.do...@cambiumassessment.com> wrote: > To make sure the scalar is used instead of using the recycled vector s, > maybe like this > > x <- matr

Re: [R] Adding a title to a plot

2021-03-04 Thread Eric Berger
Untested b1=boxcox( DV ~ IV1 + IV2, data= newdata, main="My main title\n My Subtitle") On Thu, Mar 4, 2021 at 11:56 AM DY Kim wrote: > Greetings! > > I am currently using R x64 4.0.4. > > I used the box-cox power transformation to create a range of lambdas and > log-likelihood values using th

Re: [R] read_csv not recognized

2021-03-08 Thread Eric Berger
Hi Carlos, That is strange. The function read_csv is in the readr package. You could try library(readr) readr::read_csv(etc) Let us know what happens. Eric On Mon, Mar 8, 2021 at 3:57 PM Hasan Diwan wrote: > function (file, col_names = TRUE, col_types = NULL, locale = > default_locale(), >

Re: [R] Surprising behavior and bugs in R 4.0.4

2021-03-20 Thread Eric Berger
I have no familiarity with these packages but I did a search in CRAN on api_create and found it is defined in the plotly package. I then confirmed that the seurat package does reference plotly. You might try installing the plotly package before trying to install seurat. HTH, Eric On Sat, Mar 20

Re: [R] Working with violin plot

2021-03-31 Thread Eric Berger
Try replacing ggplot(ToothGrowth, ... ) with ggplot(mydata,...) HTH, Eric On Wed, Mar 31, 2021 at 12:20 PM Mahmood Naderan-Tahan < mahmood.nade...@ugent.be> wrote: > Hi > > I would like to use the violin plot as described in the manual [1]. In the > example, I see > > ToothGrowth$dose <- as.fac

Re: [R] File corruption?

2021-04-01 Thread Eric Berger
If your workflow involves debugging and rerunning the code, you may experience differences between starting from a clean RStudio session and simply restarting your application. This can be caused by your environment having variables, shared objects etc defined. It is generally quite quick to close

Re: [R] Occurrence by season

2021-04-21 Thread Eric Berger
Hi Ani, Before the for loops add the following line when[,-1] <- when[,-1]%%12 + 1 This changes the month numbering so that Dec becomes 1, Jan becomes 2, etc Then your for loop does what you want. HTH, Eric On Wed, Apr 21, 2021 at 11:09 AM ani jaya wrote: > Dear r community, > > I have a d

Re: [R] R stalling frequently

2021-05-17 Thread Eric Berger
Hi Ramdas, I have no idea what might be causing this but it would probably help those who might be able to help if you supply additional information, such as the output of sessionInfo() in an R session. Also try to send your emails to the list in plain text (not HTML). Good luck, Eric On Mon, Ma

Re: [R] Filtering a dataframe

2021-05-17 Thread Eric Berger
If your data frame is named x then y <- x[ x$id %in% c(1,2), ] would create a new data frame y that has what you want. On Mon, May 17, 2021 at 5:33 PM Admire Tarisirayi Chirume < atchir...@gmail.com> wrote: > Can someone help on how to filter my data frame below such that it retains > a countr

Re: [R] Ubuntu hirsute unable to receive the key to add the repository

2021-05-22 Thread Eric Berger
Hi Victor, This issue has been raised in earlier entries in this list. I have not dug into it myself but the following link was posted as being helpful. https://askubuntu.com/questions/1286545/what-commands-exactly-should-replace-the-deprecated-apt-key/1307181#1307181 HTH, Eric On Sat, May 22,

Re: [R] Pipe precedence

2021-05-22 Thread Eric Berger
This is part of the R-4.1.0 release which came out a few days ago. See 1. https://stat.ethz.ch/pipermail/r-announce/2021/000670.html 2. https://www.jumpingrivers.com/blog/new-features-r410-pipe-anonymous-functions/ 3. https://community.rstudio.com/t/psa-r-4-1-0-release-requires-rstudio-preview/1052

Re: [R] CentOS 8: installing R

2021-05-25 Thread Eric Berger
Hi Roger, I have no experience with Centos 8 but I checked that it is possible to run docker on it. You might consider creating an ubuntu docker image with all the R tools that you need, and then run the image on the Centos 8 machine. You can specify a mount so that your docker image, including its

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

2021-06-04 Thread Eric Berger
Typo num <- num + i should be num <- num + 1 On Sat, Jun 5, 2021 at 9:38 AM Hasan Diwan wrote: > unlist(sapply(seq(1,100), function(n) { if(n %% 2) n })) yields: > > [1] 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 > 47 49 > [26] 51 53 55 57 59 61 63 65 67 69 71 73 75 7

Re: [R] Read fst files

2021-06-09 Thread Eric Berger
You are missing the second closing parenthesis. This is what the error message is telling you. On Wed, Jun 9, 2021 at 2:44 AM Jeff Reichman wrote: > R-Help Forum > > > > Anyone know why the following line of code would error out: myObject <- > read_fst(unz("Dataset.zip", filename = "filename.f

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

2021-06-09 Thread Eric Berger
It's also possible to save a character and gain the added advantage of being less understandable :-) num[!!num%%2] On Wed, Jun 9, 2021 at 12:56 PM Martin Maechler wrote: > > David Carlsonon Sun, 6 Jun 2021 15:21:34 -0400 writes: > > > There is really no need for a loop: > > num <- 1:1

Re: [R] Read fst files

2021-06-09 Thread Eric Berger
; > myObject <- read.csv(unz("C:/Users/reichmaj/Documents/My_Reference_Library > /Regression /Dataset.zip", filename = "myFile.csv")) > > > > My only though is I can’t use the two function s together when dealing > with fst files ?? > > > > *From:* Eric B

Re: [R] Help with selection of continuous data

2021-06-21 Thread Eric Berger
Hi André, It's not 100% clear to me what you are asking. I am interpreting the question as selecting the data from those dates for which all of 1,2,3,4,5,6,7,8 appear in the ID column. My approach determines the dates satisfying this property, which I put into a vector dtV. Then I take the rows of

Re: [R] How to spot/stop making the same mistake

2021-06-23 Thread Eric Berger
In my code, instead of 't', I name a vector of indices with a meaningful name, such as idxV, to make it obvious. Alternatively, a minor change in your style would be to replace your definition of t by t <- as.logical(c(1,1,1,0,0)) HTH, Eric On Wed, Jun 23, 2021 at 6:11 PM Phillips Rogfield wr

Re: [R] Special characters in cell names

2021-06-23 Thread Eric Berger
If no one comes up with a better suggestion: a. Change the column name to "Y" so that you get the plot you want b. Use axis labels and legend text to show the text that you want. (The user never has to know that you changed the column name 😃) HTH, Eric On Wed, Jun 23, 2021 at 9:58 PM Mahmood Nade

Re: [R] Finding the package providing funtion "%du%"

2021-06-30 Thread Eric Berger
> ??'%du%' shows it is in the igraph package (disjoint union) On Wed, Jun 30, 2021 at 1:03 PM Federico Calboli < federico.calb...@kuleuven.be> wrote: > Hello All, > > I am playing with igraph (which seems to work for what I have used it). > Nevetheless: > > demo('community', package="igraph")

Re: [R] concatenating columns in data.frame

2021-07-01 Thread Eric Berger
You can do the same steps but without so much intermediate saving to shorten it f <- function(x) { do.call(rbind,lapply(1:nrow(x), function(r) {paste(x[r,], collapse="_")})) } df_combo <- cbind(df,Combo=f(df[,c(4,2)])) HTH, Eric On Thu, Jul 1, 2021 at 5:37 PM Micha Sil

Re: [R] concatenating columns in data.frame

2021-07-01 Thread Eric Berger
Lovely one-liner Bert. Chapeau On Thu, Jul 1, 2021 at 10:16 PM Berry, Charles wrote: > > > > On Jul 1, 2021, at 11:24 AM, Bert Gunter wrote: > > > > Why not simply: > > > > ## reprex > > set.seed(123) > > df = data.frame("A"=sample(letters, 10), "B"=sample(letters, 10), > >"C"=s

Re: [R] R Function question, (repost to fix the messy work format)

2021-07-02 Thread Eric Berger
Modify the summ() function to start like this summ <- function(Tabname){ query <- sprintf(" SELECT * FROM %s",Tabname) res <- dbGetQuery(con, query) etc HTH, Eric On Fri, Jul 2, 2021 at 9:39 PM Kai Yang via R-help wrote: > Hello List, > > The previous post look massy. I repost my questio

Re: [R] R Function question, (repost to fix the messy work format)

2021-07-02 Thread Eric Berger
ot;GEMD.DISC_SESSION_TYPE", "GEMD.DISCREPANCIES", > "GEMD.DISCREPANCY_QUERY_TEMP", "GEMD.DISCRETE_VALUES", > "GEMD.ENTERED_DATA_ENTRY_PAGES", "GEMD.ENTRY_GROUPS", > "GEMD.ExportSampleListNames", "GEMD.FORM_STATUS_BY_SUBJEC

Re: [R] R Function question, (repost to fix the messy work format)

2021-07-02 Thread Eric Berger
200+ times of the script > to summary each table. So, I'm trying to write the function to do this. > this is my goal. > > > First of all, I'm not sure if this is the right way to do the summary > report, because I'm a new R user. So please correct me if my idea is

Re: [R] Some difficulties to use the apply command on an array

2021-07-05 Thread Eric Berger
Hi Laurent, I am not sure how to get apply() to work but the following uses lapply() and returns the matrices in a list. lapply(1:3, FUN = function(i) diag( svd(x[i,,])$d )) HTH, Eric On Mon, Jul 5, 2021 at 5:56 PM Laurent Rhelp wrote: > Dear R-Help, > > I have an array x made up of three mat

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

2021-07-07 Thread Eric Berger
Hi Evan, I assume you know how to get the data into a data frame (e.g. via read.csv). Here I will create the example data explicitly, creating a data frame x. x <- data.frame( label=c("ABC","DDG","ABB"), count=c(3,5,2) ) Then create a character vector with the data as you want it. y <- unlist(sa

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

2021-07-07 Thread Eric Berger
much nicer On Wed, Jul 7, 2021 at 10:58 AM Ivan Krylov wrote: > On Tue, 6 Jul 2021 09:27:20 -0400 > Evan Cooch wrote: > > > I was wondering if there was an elegant/simple way to do this? > > rep(label, times = count) should give you a character vector with the > answer ready for writeLines(). >

Re: [R] error message from read.csv in loop

2021-07-09 Thread Eric Berger
it complained about ASSAY_DEFINITIONS not about RESPONDENTS. Can you try with the ASSAY_DEFINITIONS file? On Fri, Jul 9, 2021 at 9:10 PM Kai Yang via R-help wrote: > Hello List, > I use for loop to read csv difference file into data frame rr. The data > frame rr will be deleted after a comp

Re: [R] rWind: Error in if (is.numeric(v) && any(v < 0)) { : missing value where TRUE/FALSE needed

2021-07-11 Thread Eric Berger
This error can result from v with NAs. e.g. to reproduce the error message > v <- as.numeric(NA) > if (is.numeric(v) && any(v < 0)) cat("hello world\n") see also https://stackoverflow.com/questions/7355187/error-in-if-while-condition-missing-value-where-true-false-needed HTH, Eric [[al

Re: [R] Assigning categorical values to dates

2021-07-22 Thread Eric Berger
While the base R solution using 'factor' appears to win based on elegance, chapeau to the creativity of the other suggestions. For those who are not aware, R 4.1.0 introduced two features: (1) native pipe |> and (2) new shorter syntax for anonymous functions. Erich's suggestion used the native pipe

Re: [R] Sin curve question

2021-07-24 Thread Eric Berger
Alternatively with base graphics N <- 500 ## number of points (arbitrary) degrees <- seq(from=0,to=180,length=N) degreesToRadians <- function(d) { pi * d / 180.0} ## vectorIzed! plot(x=degrees,y=sin(degreesToRadians(degrees)),type='l', xlab="x",ylab="sin(x)",main="sin(x) vs x\nx is in degree

Re: [R] SOS package: findFn does not work

2021-08-07 Thread Eric Berger
Hi, I was able to reproduce this problem on R 4.0.3 on Ubuntu 20.04. I removed the CRAN sos package and installed the github version per Spencer's advice. After that it worked fine. Eric On Sat, Aug 7, 2021 at 1:50 PM Rui Barradas wrote: > Hello, > > R 4.1.0 on Ubuntu 20.04. > I cannot reprodu

Re: [R] How to modify rows matching patter on multiple columns of dataframe?

2021-08-12 Thread Eric Berger
Hi Luigi, I would take a slightly different approach. Maybe this is helpful. idV <- grep("var[123]",colnames(df)) df[,idV][df[,idV]=="a"] <- "z" df var1 var2 var3 var4 var5 1zAz1 light 2bBb4 light 3cCc9 heavy 4zDz 16 heavy 5b

Re: [R] Getting different results with set.seed()

2021-08-19 Thread Eric Berger
In that case, another interesting test would be to check whether the problem exists when you don't use doParallel(). On Thu, Aug 19, 2021 at 2:28 PM Shah Alam wrote: > > Dear All, > > Thanks a lot for your valuable suggestions. I am going to implement one by > one. > > Jan: > > Yes, I am using t

Re: [R] Find "undirected" duplicates in a tibble

2021-08-20 Thread Eric Berger
x %>% transmute( a=pmin(Source,Target), b=pmax(Source,Target)) %>% unique() %>% rename(Source=a, Target=b) On Fri, Aug 20, 2021 at 2:12 PM Greg Minshall wrote: > Kimmo, > > i'll be curious to see other, maybe more elegant, answers. in the > meantime, this seems to work. > > > x = dat

Re: [R] Find "undirected" duplicates in a tibble

2021-08-20 Thread Eric Berger
Nice Rui. Here's a version in base R with no apply(). unique(data.frame(V1=pmin(x$Source,x$Target), V2=pmax(x$Source,x$Target))) On Fri, Aug 20, 2021 at 6:43 PM Rui Barradas wrote: > Hello, > > This seems elegant to me but it's also the slowest, courtesy sort. > > apply(x, 1, sort) |> t() |> un

Re: [R] showing the complexity of r code.....

2021-08-27 Thread Eric Berger
One approach would be to put some (non-confidential) projects on a site such as GitHub so that people can examine your work. Sent from my iPhone > On 27 Aug 2021, at 9:18, akshay kulkarni wrote: > > dear members, >I am a stock trader and a data science freelancer.

Re: [R] A glitch (???) in tools::texi2pf.

2021-08-28 Thread Eric Berger
As Achim wrote in point (2), Makefile is your friend. On Sat, Aug 28, 2021 at 12:39 PM Rolf Turner wrote: > > On Sat, 28 Aug 2021 09:47:03 +0200 > Achim Zeileis wrote: > > > On Sat, 28 Aug 2021, Rolf Turner wrote: > > > > > I have found that tools::texi2pf() ignores changes to the *.bib file >

Re: [R] Calculate daily means from 5-minute interval data

2021-08-29 Thread Eric Berger
Hi Rich, Your request is a bit open-ended but here's a suggestion that might help get you an answer. Provide dummy data (e.g. 5-10 lines), say like the contents of a csv file, and calculate by hand what you'd like to see in the plot. (And describe what the plot would look like.) It sounds like what

Re: [R] R codes/functions for test procedures

2021-08-30 Thread Eric Berger
You might also try asking the author directly if he knows of any implementations of his procedures. I searched online and found his website at: https://www.unic.ac.cy/pouloukas-stavros/ You can also find his email there. On Mon, Aug 30, 2021 at 12:29 PM AbouEl-Makarim Aboueissa < abouelmakarim1..

Re: [R] A glitch (???) in tools::texi2pf.

2021-08-31 Thread Eric Berger
Thanks Greg! On Tue, Aug 31, 2021 at 1:49 PM Greg Minshall wrote: > by the way, and "fwiw", the emacs org mode community seems to like using > latexmk for moving latex files towards .pdf'ishness: > > https://mg.readthedocs.io/latexmk.html > > cheers, Greg > > ___

Re: [R] how to install npsm package

2021-09-01 Thread Eric Berger
Instructions can be found at https://github.com/kloke/npsm On Wed, Sep 1, 2021 at 6:27 PM wrote: > I need to install the package "npsm" to follow Kloke & McKean book. > However, > npsm is no longer on CRAN. So, please let me know in detail how to proceed > to install it. > > > > Thanks. > > > >

Re: [R] tidyverse: grouped summaries (with summerize)

2021-09-13 Thread Eric Berger
This code is not correct: disc_by_month %>% group_by(year, month) %>% summarize(disc_by_month, vol = mean(cfs, na.rm = TRUE)) It should be: disc %>% group_by(year,month) %>% summarize(vol=mean(cfs,na.rm=TRUE) On Tue, Sep 14, 2021 at 12:51 AM Rich Shepard wrote: > On Mon, 13 Sep 2

Re: [R] Need fresh eyes to see what I'm missing

2021-09-14 Thread Eric Berger
Before you create vel_by_month you can check vel for NAs and NaNs by sum(is.na(vel)) sum(unlist(lapply(vel,is.nan))) HTH, Eric On Tue, Sep 14, 2021 at 6:21 PM Rich Shepard wrote: > The data file begins this way: > year,month,day,hour,min,fps > 2016,03,03,12,00,1.74 > 2016,03,03,12,10,1.75 > 2

Re: [R] Need fresh eyes to see what I'm missing

2021-09-14 Thread Eric Berger
ch Shepard wrote: > > On Tue, 14 Sep 2021, Eric Berger wrote: > > > Before you create vel_by_month you can check vel for NAs and NaNs by > > > > sum(is.na(vel)) > > sum(unlist(lapply(vel,is.nan))) > > Eric, > > There should not be any missing values in

Re: [R] unable to remove NAs from a data frame

2021-09-16 Thread Eric Berger
You are getting this because you asked for the contents of a row that is beyond the number of rows in your data frame. On Thu, Sep 16, 2021 at 5:12 PM Ana Marija wrote: > > Hi All, > > I have lines in file that look like this: > > > df[14509227,] > SNP A1 A2 freq b se p N > 1: NA

Re: [R] how to combine logic test on vectors in R?

2021-09-30 Thread Eric Berger
Alternatively you can modify the test as follows: length(unique(df_b$q)) == 1 On Thu, Sep 30, 2021 at 7:22 PM Bert Gunter wrote: > I haven't followed this thread closely, but to your question I think > maybe this is what you want" > > > z <- c("","") > > all(z == "") > [1] TRUE > > z <- c("a"

Re: [R] Rename variables starting with digits

2021-10-05 Thread Eric Berger
Hi Anne, It would be helpful to include at least part of behavioral_df for people to understand the issue better. Please do the following in R and post the output. dput( head( behavioral_df) ) Also, set your email to plain text as HTML is stripped from emails on this list. Best, Eric On Tue,

Re: [R] How to select given row of conditionally subsetted dataframe?

2021-10-14 Thread Eric Berger
df[(df$Y>0.2) & (df$X<10),][2,] On Thu, Oct 14, 2021 at 10:52 AM Luigi Marongiu wrote: > Hello, > I have selected a subset of a dataframe with the vector syntax (if > this is the name): > ``` > > df[(df$Y>0.2) & (df$X<10),] > YX > 10 0.2200642 1.591589 > 13 0.2941828 1.48595

Re: [R] Does intersect preserve order?

2021-10-17 Thread Eric Berger
As Duncan notes, it is easy to get the current implementation. Just type the function name at the prompt: > intersect { y <- as.vector(y) unique(y[match(as.vector(x), y, 0L)]) } On Sun, Oct 17, 2021 at 12:49 PM Duncan Murdoch wrote: > On 15/10/2021 4:31 p.m., petr smirnov wrote: > > Hi

Re: [R] Wild cards for dataframes

2021-10-22 Thread Eric Berger
You can check out Wikipedia for regular expressions: https://en.wikipedia.org/wiki/Regular_expression On Fri, Oct 22, 2021 at 3:48 PM Steven Yen wrote: > Thanks, it works! > > What can I read to understand more about this part "\\..*$" of the > pattern? And more such as ^ and $ that I know f

Re: [R] I'd like to request that my R CRAN package is not tested on Solaris OS

2021-10-22 Thread Eric Berger
Hi Lampros, I cannot answer your question but I believe the correct place to post such a question would be the r-package-devel list https://stat.ethz.ch/mailman/listinfo/r-package-devel Good luck On Fri, Oct 22, 2021 at 2:13 PM lampros mouselimis wrote: > > Dear R-help team, > > I'm the mainta

Re: [R] cleanup/replacing a value on condition of another value

2021-10-25 Thread Eric Berger
The tibble shows the 'date' column as type date but you are comparing io a string. Perhaps replace that piece by date == as.Date("2021-10-23") Not tested. HTH, Eric On Mon, Oct 25, 2021 at 2:26 PM Dr Eberhard W Lisse wrote: > > Hi, > > I have data from JHU via the 'coronavirus' package which ha

Re: [R] R vs Numpy

2021-10-29 Thread Eric Berger
I think a Cheat Sheet that gives a side-by-side comparison of numpy and R would be relevant here. I found something like that for pandas and R (link below), but not for numpy. https://github.com/yl3738/Python-vs.-R-Cheatsheet/blob/main/community%20contribution_CC%20group14.pdf On Thu, Oct 28, 20

Re: [R] Help needed with data visualization in R

2021-11-01 Thread Eric Berger
I have no experience with this but I did a search and found the following which looks close to what you are looking for https://stackoverflow.com/questions/69755844/is-it-possible-to-draw-the-following-diagram-in-r On Mon, Nov 1, 2021 at 5:06 PM bharat rawlley via R-help < r-help@r-project.org>

Re: [R] Translation of the charter

2021-11-01 Thread Eric Berger
> R.oo::charToInt(x) # [1] 97 98 99 On Mon, Nov 1, 2021 at 9:48 PM Alice wrote: > > Dear members, > > How to translate the charter to the underline inter? > I tried this: > > > x <- c("a","b","c") > > > as.numeric(x) > > [1] NA NA NA > > Warning message: > > NAs introduced by coercion > > > It

Re: [R] How to slice the array?

2021-11-01 Thread Eric Berger
x[ x > 2] On Mon, Nov 1, 2021 at 9:49 PM Alice wrote: > > How to slice the array with the condition? > For example, in perl I can get the elements greater than 2. > > $ perl -le '@x=(1,2,3,4,5);@y=grep {$_>2} @x;print "@y"' > > 3 4 5 > > > in R I know which(x>2), but it will return the indexes in

Re: [R] Code problem with R/Microeconomics

2021-11-01 Thread Eric Berger
Hi Olga, There are many people reading this list who are happy to try to help. Please provide some additional information about what you are trying to do and where you are stuck. Good luck, Eric On Mon, Nov 1, 2021 at 9:49 PM Olga Pervushina wrote: > > > Dear Sir/Madam, > > I am working on a sta

Re: [R] Is there a hash data structure for R

2021-11-02 Thread Eric Berger
One choice is new.env(hash=TRUE) in the base package On Tue, Nov 2, 2021 at 11:48 AM Yonghua Peng wrote: > I know this is a newbie question. But how do I implement the hash structure > which is available in other languages (in python it's dict)? > > I know there is the list, but list's names c

Re: [R] Help with strange RGui behavior? Will not consistently run source.

2021-11-17 Thread Eric Berger
Hi Stephen, Does the problem still occur if you connect remotely to your computer from a different computer? e.g. via remote desktop? On Wed, Nov 17, 2021 at 6:50 PM Stephen Hartley < stephen.hartley@gmail.com> wrote: > So I've got an odd problem that I can't seem to nail down, and I'm not >

Re: [R] Help with strange RGui behavior? Will not consistently run source.

2021-11-18 Thread Eric Berger
k (coincidental timing). So I doubt this is pertinent but >> thought I should mention it just in case. >> >> >> >> Sent from Mail for Windows >> >> >> >> From: Eric Berger >> Sent: Wednesday, November 17, 2021 1:04 PM >> To: Stephe

Re: [R] Date read correctly from CSV, then reformatted incorrectly by R

2021-11-20 Thread Eric Berger
Hi Philip, This is a recurring question and there are many ways to do this. My preference is to use the lubridate package. library(lubridate) a <- "15/01/2010" b <- dmy(a) b # "2010-01-15" class(b) # [1] "Date" HTH, Eric On Sat, Nov 20, 2021 at 7:09 PM Philip Monk wrote: > Hello, > > Simple b

Re: [R] Problem with lm Giving Wrong Results

2021-12-02 Thread Eric Berger
Hi Thomas, I could not reproduce your problem. Both examples worked fine for me. Here is my setup: R version 4.1.2 (2021-11-01) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.3 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 LAPACK

Re: [R] SOMAscan data analysis

2021-12-03 Thread Eric Berger
Hi Kai, Check out https://www.bioconductor.org or the help there at https://www.bioconductor.org/help/ You can also post your question there. Best, Eric On Fri, Dec 3, 2021 at 2:22 AM Kai Yang via R-help wrote: > Hello R team,we have a huge SOMAscan data set. This is an aptamer-based > protec

<    1   2   3   4   5   6   >