Re: [R] Help with "ERROR: lazy loading failed for package 'psycho'"

2018-06-06 Thread Eric Berger
> install.packages("Matrix") On Wed, Jun 6, 2018 at 2:24 PM, Bill Poling wrote: > Good morning. In my continuing pursuit of self-taught R programming I am > interested in following the tutorial provided by Bloggers.com "Beautiful > and Powerful Correlation Tables in R" > > > https://www.r-blogg

Re: [R] ROC within SEM

2018-06-07 Thread Eric Berger
Hi Ray, Have you done any search at all? I did a search on "R package ROC latent variable" and got several hits. In particular the package randomLCA seems relevant https://cran.r-project.org/web/packages/randomLCA/vignettes/randomLCA-package.pdf I glanced at the documentation which mentions 2 oth

Re: [R] Efficient manipulation with list object

2018-06-10 Thread Eric Berger
Try this. Suppose your list of matrices is in the list locL. nc <- 3 locL2 <- list() for ( i in 1:length(locL ) locL2[[i]] <- as.numeric(t(locL[[i]])) bigMat <- matrix(unlist(locL3), ncol=nc, byrow=TRUE) HTH, Eric On Sun, Jun 10, 2018 at 6:33 PM, Christofer Bogaso < bogaso.christo...@gmail.

Re: [R] Efficient manipulation with list object

2018-06-10 Thread Eric Berger
Sorry typos Try this. Suppose your list of matrices is in the list locL. nc <- 3 locL2 <- list() for ( i in 1:length(locL) ) locL2[[i]] <- as.numeric( t( locL[[i]] ) ) bigMat <- matrix(unlist(locL2), ncol=nc, byrow=TRUE) HTH, Eric On Sun, Jun 10, 2018 at 7:10 PM, Eric B

Re: [R] Calling r-scripts with arguments from other scripts, or possibly R programming conventions/style guide

2018-06-13 Thread Eric Berger
Hi Sam, I use the littler package for scripting. You may find it meets your needs. https://github.com/eddelbuettel/littler HTH, Eric On Wed, Jun 13, 2018 at 5:33 AM, Sam Tuck wrote: > Hi All, > I am new to R and am wondering if there is a way to pass > arguments between rscripts. I

Re: [R] subsetting lists....

2018-06-18 Thread Eric Berger
sapply( 1:length(YH), function(i) { YH[[i]][iuhV[i]]}) On Mon, Jun 18, 2018 at 1:55 PM, akshay kulkarni wrote: > dear members, > I have list YH and index vector iuhV. I want > to select iuhV[1] from YH[[1]], iuhv[2] from YH[[2]], iuhv[3] from > YH[[3]]..iuhv[n] f

Re: [R] Fw: subsetting lists....

2018-06-18 Thread Eric Berger
My response does not have an explicit for loop. On Mon, Jun 18, 2018 at 2:15 PM, akshay kulkarni wrote: > correctionI want the method without a for loop > > From: akshay kulkarni > Sent: Monday, June 18, 2018 4:25 PM > To: R help Mailing list > Subject: subs

Re: [R] Fwd: Quadratic programming, for loop

2018-06-26 Thread Eric Berger
The statement dvec <- -hsmooth looks like it might be the source of the problem, depending on what hsmooth is. On Tue, Jun 26, 2018 at 11:16 AM, Maija Sirkjärvi wrote: > Thanks for the reply! I got that figured out, but still have some problems > with the quadratic programming. > > It seems

Re: [R] R maintains old values

2018-07-02 Thread Eric Berger
If you want a "fresh" R session when you start to run the script you could consider putting as the first line rm(list=ls()) This will remove objects from your environment (variables, functions, ..) HTH, Eric On Mon, Jul 2, 2018 at 5:34 PM, PIKAL Petr wrote: > Hi > > Without code it is just f

Re: [R] Structure to ts Error in attributes(.Data) <- c(attributes(.Data), attrib) :

2018-07-03 Thread Eric Berger
Hi WHP, It should be .Tsp=c(2016,2018.417,12) (off by one error) HTH, Eric On Tue, Jul 3, 2018 at 6:23 PM, Bill Poling wrote: > Hi, obviously missing something here? Getting error: Error in > attributes(.Data) <- c(attributes(.Data), attrib) : invalid time series > parameters specified >

Re: [R] Combine by columns a vector with another vector that is constant across rows

2018-07-03 Thread Eric Berger
For what it's worth, for larger vectors, and following on from your observation that the do.call() approach is faster, the following provides some modest additional speedup: cbind(x,t(do.call(cbind, lapply(x, function(y) vec Rgds, Eric On Tue, Jul 3, 2018 at 8:12 PM, Viechtbauer, Wolfgang

Re: [R] replicate rows

2018-07-08 Thread Eric Berger
Hi Catalin, This should work. I set the number of repetitions and sample sizes as variables so it would be clear how to modify for your actual case. nreps<- 3 sampSize <- 2 w <- unlist( lapply(1:nreps, function(i) { rep(paste("R",i,sep=""),sampSize) } ) ) aa2 <- cbind( as.data.frame(aa), w)

Re: [R] inconsistency in display of character vector....

2018-07-08 Thread Eric Berger
> If (identical(snlcqn, snlcqna)) snlcqn else snlcqna ?? Why not just always return snicqna ? On Mon, Jul 9, 2018 at 9:43 AM, PIKAL Petr wrote: > Hi > > You definitely should not use HTML formated mail. This is plain text > mailing list for reason. > > If you experience space between "NSE/"

Re: [R] Zoo changing time-zone when I merge 2 zoo time series

2018-07-09 Thread Eric Berger
I found the following at https://stackoverflow.com/questions/25269425/merge-zoo-removes-time-zone library(xts) merge2=function(x,y) { as.zoo(merge(as.xts(x), as.xts(y)))} If you define the function merge2() as above then merge2(Dat1,Dat2) should be ok HTH, Eric On Mon, Jul 9, 2018 at 1:22

Re: [R] Using write.csv as a connection for read.csv

2018-07-09 Thread Eric Berger
Hi Kevin, It's good that you provided the background to the problem. Rather than asking this list to "debug" your proposed solution, I think you would be better off showing some of the "corrupted" data frame and ask for suggestions how to deal with it. (Suggestions may or may not match your initial

Re: [R] Something simple not working in group_by

2018-07-10 Thread Eric Berger
Hi Sumit, I was not able to reproduce this problem. I tried it in both R 3.5.1 and R 3.4.4. Both gave the expected output (which differs from yours.) Eric On Tue, Jul 10, 2018 at 1:32 AM, Bert Gunter wrote: > Dunno. > > But if I understand correctly, here's a base R way to do it: > > (## using

Re: [R] inconsistency in display of character vector....

2018-07-10 Thread Eric Berger
> Yours sincerely, > AKSHAY M KULKARNI > > -- > *From:* Eric Berger > *Sent:* Monday, July 9, 2018 12:15 PM > *To:* PIKAL Petr > *Cc:* akshay kulkarni; R help Mailing list > *Subject:* Re: [R] inconsistency in display of character vector > > > If (identical(

Re: [R] Locating data source error in large file

2018-07-20 Thread Eric Berger
Hi Rich, This may not be the most efficient but it will identify the offenders. > foo <- paste(wy2016$date, wy2016$time)) > uu <- sapply(1:length(foo), function(i) { a <- try(as.POSIXct(foo[i]),silent=TRUE) "POSIXct" %in% class(a) }) > which(!uu) HTH, Eric On Fri, J

Re: [R] A couple of batch mode questions

2018-07-25 Thread Eric Berger
Some additional comments that might be relevant to people interested in these topics. 1. For R scripts you should also consider the package littler developed by Dirk Eddelbuettel, Highly recommended. For info http://dirk.eddelbuettel.com/code/littler.html or the github repository. 2. Scripts can

Re: [R] A couple of batch mode questions

2018-07-25 Thread Eric Berger
You should be able to do all this within R. >From what you have written I don't see a compelling reason to use scripts at the shell level. Best, Eric On Wed, Jul 25, 2018 at 9:41 PM, Rich Shepard wrote: > On Wed, 25 Jul 2018, Eric Berger wrote: > > 1. For R scripts you sho

Re: [R] ESS issue: lines moved right 40 spaces

2018-07-27 Thread Eric Berger
Hi Rich, Thanks for posting this question. I also use emacs with ESS for editing R files and I have been living with the comment indentation problem you described. Based on the comments in this thread I did a search and found a posted solution that works for me. See https://stat.ethz.ch/pipermail/e

[R] DBI::dbWriteTable syntax error apparently from quotes

2017-08-29 Thread Eric Berger
I have been successfully using RODBC for a long time (years) to connect to MS SQL Server from R. This week I wanted to try using odbc but I am seeing some problems which may be related to how I set up my driver and/or connection. The dbWriteTable manual page gives as an example command: dbWriteTab

Re: [R] DBI::dbWriteTable syntax error apparently from quotes

2017-08-29 Thread Eric Berger
use my brevity. > > On August 29, 2017 2:21:44 AM PDT, Eric Berger > wrote: > >I have been successfully using RODBC for a long time (years) to connect > >to > >MS SQL Server from R. > >This week I wanted to try using odbc but I am seeing some problems > >which

Re: [R] Avoid duplication in dplyr::summarise

2017-09-09 Thread Eric Berger
Hi Lars, Two comments: 1. You can achieve what you want with a slight modification of your definition of s(), using the hint from the error message that you need an argument '.': s <- function(.) { dplyr::summarise(., x1m = mean(X1), x2m = mean(X2), x3m = mea

Re: [R] compounding precipitation based on whether falls within a day

2017-09-15 Thread Eric Berger
Hi Eric, Bert's solution is very elegant. His final comment prompted me to check out the aperm() function which I have never used. The final step to complete his response is prec_daily2 <- aperm(prec_daily, c(3,1,2)) Regards On Wed, Sep 13, 2017 at 9:06 PM, Bert Gunter wrote: > Thanks for the

Re: [R] require help

2017-09-15 Thread Eric Berger
You did not provide the data frame so I will first create one and then use it to create an xts library(xts) df <- data.frame( year=1980:2009, cnsm=sample(170:180,30,replace=TRUE), incm=rnorm(30,53,1), wlth=rnorm(30,60,1)) dates <- as.Date(paste(df$year,"-01-01",sep="")) myXts <-

Re: [R] require help

2017-09-16 Thread Eric Berger
You can just use the same code that I provided before but now use your dataset. Like this df <- read.csv(file="data2.csv",header=TRUE) dates <- as.Date(paste(df$year,"-01-01",sep="")) myXts <- xts(df,order.by=dates) head(myXts) #The last command "head(myXts)" shows you the first few rows of the x

Re: [R] Help with RDA analysis, function ''varpart'' in vegan

2017-09-17 Thread Eric Berger
I am not familiar with the vegan package, so I am just making a guess here. If 'na.action=na.omit' is part of the call to varpart, try removing it from the function call and moving it above as follows: options(na.action="na.omit") RDA_Ger <- varpart(comm, x1, x2, x3, transfo="hellinger", scale = F

Re: [R] help matching rows of a data frame

2017-09-18 Thread Eric Berger
Hi Terry, I take your question to mean how to label distinct rows of a data frame. If that is not your question please clarify. I found the row.match() function in the package prodlim that can be used to solve this. However since your request requires no additional dependencies I borrowed the relev

Re: [R] Install the Package "ISwR"

2017-09-20 Thread Eric Berger
What if you answer 'Yes' ? On Wed, Sep 20, 2017 at 1:03 PM, AbouEl-Makarim Aboueissa < abouelmakarim1...@gmail.com> wrote: > Dear All: good morning > > I am trying to install the "" package, but I am getting this error message. > > > *> utils:::menuInstallPkgs()* > *Warning in install.packages(NU

Re: [R] "XLConnect" packages; Excel dates read incorrectly

2017-09-23 Thread Eric Berger
Jim, I don't see how that link could be related to John's issue. Symptoms related to your link involve discrepancies of four years whereas John is seeing discrepancies of one day. John, I do not see any attached files. Regards On Sat, Sep 23, 2017 at 1:30 PM, Jim Lemon wrote: > Hi John, > It c

Re: [R] "XLConnect" packages; Excel dates read incorrectly

2017-09-24 Thread Eric Berger
e the shorter date11<-as.Date(as.POSIXlt(a_col$date)) On Sun, Sep 24, 2017 at 8:51 AM, John wrote: > Hi, > >Thank you for all your responses. >For Eric, The files are attached. (I believe it was also attached in my > first message) >For David, Could you send me

Re: [R] build a SpatialLines object from a list

2017-09-25 Thread Eric Berger
Hi Ashraf, It is not obvious to me what your structures are but one problem in your function is the assignment tt1 <- SpatialLines(list(tt[[i]])). This will set tt1 to just have one item. Consider the following test.func <- function(x) { tt1 <- list() for ( i in ... ) { ...

Re: [R] Sample of a subsample

2017-09-25 Thread Eric Berger
Hi David, I was about to post a reply when Bert responded. His answer is good and his comment to use the name 'dat' rather than 'data' is instructive. I am providing my suggestion as well because I think it may address what was causing you some confusion (mainly to use "which", but also the missing

Re: [R] bowed linear approximations

2017-09-26 Thread Eric Berger
Hi Rich, If I understand your comment about "uniformly distributed along the log=x axis" then I think John's (second) set of commands needs a change to the definition of xx, as follows: xx <- exp(seq(from=log(min(x)),to=log(max(x)),length=50)) m <- lm(y ~ log(x)) yy <- predict(m, data.frame(x=xx))

Re: [R] Surprising message "Error in FUN(newX[, i], ...) : all arguments must have the same length"

2017-09-26 Thread Eric Berger
Hi Chris, Maybe the na.rm=TRUE is affecting things. Try this apply(datTAF[,75:78],2,function(x){ sum(!is.na(x)) }) HTH, Eric On Tue, Sep 26, 2017 at 9:53 AM, Chris Evans wrote: > I am hitting an odd message "Error in FUN(newX[, i], ...) : all arguments > must have the same length". I can't su

Re: [R] build a SpatialLines object from a list

2017-09-26 Thread Eric Berger
d to convert each matrix to coordinates > and then to a line and then to a spatial line as figured in the code. > > My data structure is a list of 141 matrices.Each matrix represents > coordinates of the river lines position. > > Ashraf, cheers > > > On Monday, 25 September

Re: [R] Cleaning data

2017-09-26 Thread Eric Berger
Hi Bayan, In your code, 'a' is a vector and is.integer(a) is a logical of length 1 - most likely FALSE if even one element of a is not an integer. (Since R will coerce all the elements of a to the same type.) You need to decide whether something "close enough" to an integer is to be considered an i

Re: [R] rename multiple files by file.rename or other functions

2017-09-28 Thread Eric Berger
Hi John, Thanks to Jim for pointing out the file.rename() function. You can try this: # define the filename templates strIn <- "XYZW--Genesis_ABC.mp3" strOut <- "01Gen--.mp3" # create the strings "01", "02", ..., "50" v <- sapply(1:50, function(i) sprintf("%02d",i) ) # perform all the file rena

Re: [R] Issues with 'Miwa' algorithm in mvtnorm package

2017-10-02 Thread Eric Berger
Hi Hollie, I tried to reproduce your example but could not. Here is what I did. Please explain if you did something different. x <- c(9.358*10^-3, -8.165*10^-3, -1.689*10^-8, -8.165*10^-3, 9.358*10^-3, 1.854*10^-8, -1.689*10^-8, 1.854*10^-8, 9.358*10^-3) A <- matrix(x, nrow=3

Re: [R] Issues with 'Miwa' algorithm in mvtnorm package

2017-10-02 Thread Eric Berger
) should read B <- matrix(y, nrow=3, > byrow = TRUE) > > > Regards, Hollie > ------ > *From:* R-help on behalf of Eric Berger < > ericjber...@gmail.com> > *Sent:* 02 October 2017 16:16:13 > *To:* Bert Gunter > *Cc:* r-help@r-projec

Re: [R] Issues with 'Miwa' algorithm in mvtnorm package

2017-10-02 Thread Eric Berger
3.855762e-6 You can get a positive answer with Miwa by cranking up the number of steps it uses (to its maximum of 4098, for example) pmvnorm( ..., algorithm=Miwa(steps=4098)) But this is still not a "correct" answer and the "error" attribute is set to NA to flag it. HTH, Eric

Re: [R] RFM Analysis Help

2017-10-04 Thread Eric Berger
I don't see any attached dataset. On Wed, Oct 4, 2017 at 11:11 AM, Hemant Sain wrote: > I'm trying to perform a RFM analysis on attached dataset, > i'm able to get the results using the auto_rfm function but i want to > define my own breaks for RFM, > when i tried to define my own breaks i got t

Re: [R] Time series: xts/zoo object at annual (yearly) frequency

2017-10-06 Thread Eric Berger
Hi John, Here's one way to do it: vec <- c(2,4,5) yrs <- seq(from=as.Date("1991-01-01"),by="1 year",length=length(vec)) a <- xts(x=vec, order.by=yrs) HTH, Eric On Fri, Oct 6, 2017 at 9:56 AM, John wrote: > Hi, > >I'd like to make a time series at an annual frequency. > > > a<-xts(x=c(2,4,

Re: [R] load() failed to load .Rdata file in AWS-Ububtu

2017-10-07 Thread Eric Berger
Hi Christofer, The directory /srv/shiny-server would normally be owned by the root user. Your options would seem to be to either (1) bring up the R session as root (dangerous) or (2) try copying the file to your local directory and read it from there (if allowed). e.g. from the Unix shell: > cd ~

Re: [R] load() failed to load .Rdata file in AWS-Ububtu

2017-10-09 Thread Eric Berger
home/ubuntu/Dat.RData") > > shinyServer(function(input, output) { > output$table = renderTable(head(data.frame(1:20, 1:20), 20)) > }) > > with above setup when I deploy my shiny app I get below error : > > 18.221.184.94:3838 says > The application unexpectedly exited > Di

Re: [R] Regular expression help

2017-10-09 Thread Eric Berger
Hi Duncan, You can try this: library(readr) f <- function(s) { t <- unlist(readr::tokenize(paste0(gsub(" ",",",s),"\n",collapse=""))) i <- grep("[a-zA-Z0-9]*/[a-zA-Z0-9]*/",t) u <- sub("[a-zA-Z0-9]*/[a-zA-Z0-9]*/","",t[i]) paste0(u,collapse=" ") } f("f 147/1315/587 2820/1320/587 3624/1321

Re: [R] load() failed to load .Rdata file in AWS-Ububtu

2017-10-09 Thread Eric Berger
; otherwise, locally my shiny app is working but not with AWS. > > On Mon, Oct 9, 2017 at 12:37 PM, Eric Berger > wrote: > > Hi Christofer, > > The shiny code you have written does not depend on loading the Dat.RData > > file. > > I commented out that line and ran y

Re: [R] changing "," to "." in data.frame

2017-10-11 Thread Eric Berger
Along the lines of Petr's followup: AXnew <- data.frame(lapply( AX, function(s) sub(",",".",s))) On Wed, Oct 11, 2017 at 10:59 AM, PIKAL Petr wrote: > And as follow up, > > fff<-function(x) gsub(",", ".", x) > > BX <- apply(apply(AX, 2, fff), 2, as.numeric) > > this seems to be easier. > > Ch

Re: [R] dual y-axis for ggplot

2017-10-12 Thread Eric Berger
Hi John, You can try the following: override.linetype=c("twodash","solid") p <- ggplot(obs, aes(x = Timestamp)) p <- p + geom_line(aes(y = air_temp, colour = "Temperature", linetype ="Temperature")) p <- p + geom_line(aes(y = rel_hum/5, colour = "Humidity", linetype="Humidity")) p <- p + guides(co

Re: [R] comparing two strings from data

2017-10-12 Thread Eric Berger
Combining and completing the advice from Greg and Boris the complete solution is two lines: data_2 <- read.csv("excel_data.csv", stringsAsFactors = FALSE) match_list <- match( data_2$data1, data_2$data2 ) The vector match_list will have the matching position when it exists and NA's otherwise. Its

Re: [R] comparing two strings from data

2017-10-12 Thread Eric Berger
One additional comment. If you want 0 instead of NA when there is no match then the match statement should read: match_list <- match( data_2$data1, data_2$data2, nomatch=0) On Fri, Oct 13, 2017 at 7:39 AM, Eric Berger wrote: > Combining and completing the advice from Greg and Bor

Re: [R] Populate one data frame with values from another dataframe for rows that match

2017-10-14 Thread Eric Berger
Hi Kevin, I think there are issues with Rui's proposed solution. For example, if there are rows in myDF1 which have a studyno which does not match any row in myDF2, then you will lose those rows. In your original request you said that you wanted to keep those rows. To demonstrate my point I need t

Re: [R] ggplot / second axis / just a notation problem

2017-10-17 Thread Eric Berger
Hi John, Why not just try both and see which one makes sense? On Tue, Oct 17, 2017 at 12:24 PM, John wrote: > Hi, > >I have a question on ggplot2 with the second axis, but I don't think one > needs to know ggplot2 package in order to answer this question. > >In this example, > https://r

[R] Problem with tq_mutate_xy() from the tidyquant package

2017-10-18 Thread Eric Berger
I was able to reproduce the problem with this self-contained example. Maybe it could be reproduced with an even smaller one ... library(tidyquant) # Loads tidyverse, tidyquant, financial pkgs, xts/zoo library(xts) dtV <- as.Date("2017-01-01") + 1:100 locL <- list( foo=xts(rnorm(100), order.by=d

Re: [R] dbGetQuery() returns wrong value

2018-07-30 Thread Eric Berger
The ID matches in the first 16 characters. How is your table declared? On Mon, Jul 30, 2018 at 2:00 PM, Christofer Bogaso < bogaso.christo...@gmail.com> wrote: > Session Information for above error: > > > sessionInfo() > R version 3.5.0 (2018-04-23) > Platform: x86_64-w64-mingw32/x64 (64-bi

Re: [R] CODE HELP

2018-08-02 Thread Eric Berger
Hi Saptorshee, Two comments: 1. no attachments made it through to the list. You probably need to include the code directly in your email, and send your email as plain text (otherwise information gets stripped) 2. for anyone interested in following up on Saptorshee's question, I searched for the pap

Re: [R] Philip Morris International - Windows10 migration assessment

2018-08-03 Thread Eric Berger
upporting the R community at large which greatly benefits from the work they do. I hope that helps. Regards, Eric Berger On Fri, Aug 3, 2018 at 11:25 AM, Rolf Turner wrote: > On 03/08/18 19:03, Rainer Krug wrote: > >> Let’s not alienate the business users! >> >> I agree tha

Re: [R] A slightly unorthodox matrix product.

2018-08-04 Thread Eric Berger
Hi Rolf, A few edits because (i) nrow(a) should be nrow(A) and (ii) you have calculated C[j,k,i] = A[i,j]*B[i,k], (iii) minor style change on lapply. library(abind) xxx <- lapply(1:nrow(A),function(i){A[i,]%o%B[i,]}) yyy <- do.call(abind,c(xxx,list(along=3))) zzz <- aperm(yyy,c(3,1,2)) HTH, Eric

Re: [R] loop over matrix: subscript out of bounds

2018-08-06 Thread Eric Berger
Both loops are on 'i', which is a bad idea. :-) Also myMatrix[i,i+1] will be out-of-bounds if i = ncol(myMatrix) On Mon, Aug 6, 2018 at 12:02 PM, Maija Sirkjärvi wrote: > I have a basic for loop with a simple matrix. The code is doing what it is > supposed to do, but I'm still wondering the err

Re: [R] loop over matrix: subscript out of bounds

2018-08-08 Thread Eric Berger
You only need one "for loop" for(i in 2:nrow(myMatrix)) { myMatrix[i-1,i-1] = -1 myMatrix[i-1,i] = 1 } HTH, Eric On Wed, Aug 8, 2018 at 12:40 PM, Maija Sirkjärvi wrote: > Thanks! > > If I do it like this: > > myMatrix <- matrix(0,5,5*2-3) > print(myMatrix) > for(i in 2:nrow(myMatrix)) >

Re: [R] Assistance on Installing Rattle

2018-08-11 Thread Eric Berger
Hi Shivi, I have no experience with the rattle package but I just installed it with no problem. I am using a Windows 10 machine with R version 3.4.2. I suggest you provide additional information so that others may have ideas. e.g. your operating system version and output from sessionInfo() (in R)

Re: [R] Mysterious seg fault.

2018-08-11 Thread Eric Berger
Hi Rolf, When faced with such a situation I take the following approach which often helps. Use the same setup that caused the seg fault (you need a reproducible problem.) Start your R session using valgrind. e.g. in linux I do: $ valgrind R Assuming that a seg fault still occurs then valgrind sho

Re: [R] Cannot set correct miktex path for pdflatex

2018-08-14 Thread Eric Berger
Hi Claire, In Unix (linux) the 'which' command is documented as searching for the command according to the PATH environment variable. The different results from $ which and > Sys.which() would point to the fact that the PATH variable is different in the two cases. Compare: $ echo $PATH versus Sy

Re: [R] Monte Carlo on simple regression

2018-08-22 Thread Eric Berger
Li is defined as d1$a which is a vector. You should use N <- length(Li) HTH, Eric On Wed, Aug 22, 2018 at 6:02 PM, Ogbos Okike wrote: > Kind R-users, > I run a simple regression. I am interested in using the Monte Carlo to test > the slope parameter. > Here is what I have done: > d1<-read.tab

Re: [R] Monte Carlo on simple regression

2018-08-22 Thread Eric Berger
't go. I also tried replacing it > with length(Li). The same error remains. > > Thank so much for looking at this again. > > Ogbos > > > On Wed, Aug 22, 2018 at 5:06 PM Eric Berger wrote: > >> Li is defined as d1$a which is a vector. You should use >>

Re: [R] Monte Carlo on simple regression

2018-08-22 Thread Eric Berger
R") > Error in eval(predvars, data, env) : > numeric 'envir' arg not of length one > Thank you for additional assitance. > Ogbos > > > > On Wed, Aug 22, 2018 at 5:23 PM Eric Berger wrote: > >> You have an extra comma ... it should be >> >&g

Re: [R] Help with DNA Methylation Analysis

2018-08-26 Thread Eric Berger
Your problem is that the command you entered > the_data<-read.csv(file=“c:/file_name.csv,header=TRUE,sep=“,”) is missing a double quote after the .csv. The statement should be > the_data<-read.csv(file=“c:/file_name.csv",header=TRUE,sep=“,”) The '+' sign is a prompt from R that indicates it has

Re: [R] "use of NULL environment is defunct" when trying to lock a reference class

2018-08-27 Thread Eric Berger
Hi Ivan, Unfortunately I cannot answer your question. However, I do have quite a bit of experience using R's reference classes and you might want to consider the more recent R6 package. It provides R6 classes which have advantages over reference classes. See for example: 1. Hadley Wickham on R6 (

Re: [R] Smallest Space Analysis (SSA) in R

2018-09-20 Thread Eric Berger
Hi Andrew, I don't have any experience in this area but I was intrigued by your question. Here is what I learned. 1, A bit of poking around turned up a thread on stats.stackexchange that mentions that "smallest space analysis" (SSA) is a special case of "multidimensional scaling" (MDS). See the th

Re: [R] Packaged exe and Shiny

2018-09-23 Thread Eric Berger
Hi Kevin, I did something along these lines using shiny and I had a good experience with it. You would require a server (virtual or physical) to run the shiny-server program. This approach is particularly suitable if your target users do not know (or use) R. If you go down this route I also suggest

Re: [R] Query on R-squared correlation coefficient for linear regression through origin

2018-09-27 Thread Eric Berger
See also this thread in stats.stackexchange https://stats.stackexchange.com/questions/26176/removal-of-statistically-significant-intercept-term-increases-r2-in-linear-mo On Thu, Sep 27, 2018 at 3:43 PM, J C Nash wrote: > This issue that traces back to the very unfortunate use > of R-squared a

Re: [R] Project in emacs + ess

2018-10-19 Thread Eric Berger
Not exactly sure what you are looking for but here is my workflow which may give you another perspective 1. my OS is linux 2. I edit my files in emacs (with ESS pulled in) 3. I use make (and Makefile) to compile .o's and .so's from .cpp where necessary (i.e. I use Rcpp etc) (and also to build s

Re: [R] match() question or needle haystack problem for a data.frame

2018-10-22 Thread Eric Berger
Hi Knut, You are almost done. > v <- match(Mydata$DATA1, needles, nomatch=NA) > found <- Mydata[ !is.na(v), ] > missing <- Mdata[ is.na(v), ] HTH, Eric On Mon, Oct 22, 2018 at 5:51 PM Bert Gunter wrote: > Re-read ?match and note the examples for %in% > > -- Bert > Bert Gunter > > "The trouble

Re: [R] Ignoring the domain of RV in punif()

2018-10-23 Thread Eric Berger
Hi Hamed, I disagree with your criticism. For a random variable X X: D - - - > R its CDF F is defined by F: R - - - > [0,1] F(z) = Prob(X <= z) The fact that you wrote a convenient formula for the CDF F(z) = (z-a)/(b-a) a <= z <= b in a particular range for z is your decision, and as you noted th

Re: [R] Ignoring the domain of RV in punif()

2018-10-23 Thread Eric Berger
on. > > Please see page 115 in > > https://books.google.co.uk/books?id=FEE8D1tRl30C&printsec=frontcover&dq=statistical+distribution&hl=en&sa=X&ved=0ahUKEwjp3PGZmJzeAhUQqxoKHV7OBJgQ6AEIKTAA#v=onepage&q=uniform&f=false > The > > > Thanks. > Hamed. > &

Re: [R] Calculating just a single row of dissimilarity/distance matrix

2018-10-26 Thread Eric Berger
> first_row_dist <- as.numeric(gower_dist)[1:(attr(gower_dist,"Size")-1)] will give you the distances of the first row from the subsequent rows. HTH, Eric On Fri, Oct 26, 2018 at 4:07 PM Aerenbkts bkts wrote: > I have a data-frame with 30k rows and 10 features. I would like to > calculate

Re: [R] Should package be reinstalled when exterbal library is changed

2018-10-30 Thread Eric Berger
Hi Marc, Normally updating external libraries would not require re-installing an R package that uses it. The R package will be able to "find" the new one, because the updated library would be in the same place (sort of) as the previous library. On a linux system this is handled by system soft links

Re: [R] Question about function scope

2018-10-30 Thread Eric Berger
Hi Sebastien, I like Duncan's response. An alternative approach is to pass around environments, as in the following: bar1 <- function(e) { e$x <- e$y <- e$z <- 1 cat(sprintf('bar1: x=%d, y=%d, z=%d\n', e$x, e$y, e$z)) } bar2 <- function(e) { e$x <- e$y <- e$z <- 2 cat(sprintf('bar2: x=%d,

Re: [R] survival analysis question

2018-10-31 Thread Eric Berger
You need to read the Help page for the function survSplit ?survSplit states that the id argument is a "character string with the name of new id variable to create (optional). This can be useful if the data set does not already contain an identifier" The addicts data.frame has as its first column

Re: [R] OT: R version 1.0.1 is still a success.

2018-11-01 Thread Eric Berger
:-) On Thu, Nov 1, 2018 at 9:06 AM Rui Barradas wrote: > Hello, > > This has nothing to do with R-help and I apologize in advance but this > is really, really strange. > > A SO user is still using R 1.0.1: > > > https://stackoverflow.com/questions/53096176/how-do-i-change-the-str-of-my-diff-time

Re: [R] Application of rolling window in entropy analysis

2018-11-02 Thread Eric Berger
Hi, You have some problems with your setup. You set N based on the number of rows in ts, but then in the call to approx_entropy you write ts[,i]. Note that ts[,i] is the i'th column of ts, whereas your definition of i implies it is based on row numbers. Maybe this is leading you to see problems el

Re: [R] Application of rolling window in entropy analysis

2018-11-02 Thread Eric Berger
> [image: Mailtrack] > <https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&;> > Sender > notified by > Mailtrack > <https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&;

Re: [R] Application of rolling window in entropy analysis

2018-11-02 Thread Eric Berger
> Sender > notified by > Mailtrack > <https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&;> > 11/02/18, > 4:02:18 PM > > On Fri, Nov 2, 2018 at 3:59 PM Eric Berger wrote: > >> How about something like this: &g

Re: [R] saveRDS() and readRDS() Why?

2018-11-07 Thread Eric Berger
What do you see at the OS level? i.e. on windows DIR rawData.rds on linux ls -l rawData.rds compare the file sizes on both. On Wed, Nov 7, 2018 at 9:56 AM Patrick Connolly wrote: > From a Windows R session, I do > > > object.size(rawData) > 31736 bytes # from scraping a non-reproducible web ad

Re: [R] saveRDS() and readRDS() Why?

2018-11-07 Thread Eric Berger
> > Have I misunderstood what the idea is? I thought I'd get an identical > object, irrespective of how different the OS stores and zips it. > > > > |> > |> Rgds, > |> > |> Robert > |> > |> > |> On 07/11/18 08:13, Eric Berger wrote: >

Re: [R] Output of arima

2018-11-13 Thread Eric Berger
Try google'ing for 'variance of an AR(1) process'. With the same seed, if you set n=100, you will get something that will compare well with what you discover from your search. On Tue, Nov 13, 2018 at 2:04 PM Ashim Kapoor wrote: > Dear All, > > Here is a reprex: > > set.seed(123) > b <- arima

Re: [R] Unexpected failure of Cholesky docomposition

2018-11-13 Thread Eric Berger
Eigen shows that the matrix is not positive definite (it has a negative eigenvalue). And isSymmetric() also shows it is not symmetric - compare (3,4) and (4,3) On Tue, Nov 13, 2018 at 5:39 PM Hoffman, Gabriel wrote: > My understanding is that a Cholesky decomposition should work on any > square,

Re: [R] Output of arima

2018-11-14 Thread Eric Berger
Hi Ashim, Per the help page for arima(), it fits an ARIMA model to the specified time series - but the caller has to specify the order - i.e. (p,d,q) - of the model. The default order is (0,0,0) (per the help page). Hence your two calls are different. The first call is equivalent to order=c(0,0,0)

Re: [R] CRAN package NlcOptim query

2018-12-11 Thread Eric Berger
Hi Aveek, 1. This is an "all-text" mailing list. Your attachment did not come through. You can check out the posting guide (see the link at the bottom of your email) and/or use dput(...) on your structures and paste them into your email so that members of the list can try to reproduce

Re: [R] Help with if else branching print out

2018-12-18 Thread Eric Berger
I often use sprintf() to control formatting of text strings. e.g. sprintf("%s is not between 1 or 15\n",nums) See ?sprintf for details HTH, Eric On Tue, Dec 18, 2018 at 10:56 AM Andrew wrote: > Hi all > > Playing around with some branching using if, if else, and else, I wrote > the following

Re: [R] 3D interpolation with R

2018-12-19 Thread Eric Berger
You can do a web search that focuses on R related hits via step 1: go to rseek.org step 2: do your search there - e.g. 3d krig This returns a lot of "hits" that seem to address your question. HTH, Eric On Thu, Dec 20, 2018 at 5:56 AM Francois Chartier wrote: > Hi, > > I would like to create a

Re: [R] Printing with cat in a procedure

2018-12-22 Thread Eric Berger
Hi Steven, Here's one way, using print try5<-function(A,B){ C<-A+B #cat("\nA =",A,"\nC = ",C) cat("\nA = ") print(A) cat("\nC = ") print(C) structure(list(A=A,B=B,C=C)) } HTH, Eric On Sat, Dec 22, 2018 at 4:32 PM Steven Yen wrote: > How do I print a matrix running a procedure? I

Re: [R] fields package question

2018-12-24 Thread Eric Berger
Since you don't provide lambda, rh or qext it is impossible to reproduce what you are seeing. Also note that in this mailing list HTML formatted emails are not passed along. On Tue, Dec 25, 2018 at 4:13 AM M P wrote: > Hello, > I used commands below to obtain a surface, can plot it and all loo

Re: [R] fields package question

2018-12-26 Thread Eric Berger
5,] 0.6467642 0.6467642 0.6467642 >> [6,] 0.5597143 0.5597143 0.5597143 >> [7,] 0.4854133 0.4854133 0.4854133 >> [8,] 0.4278326 0.4278326 0.4278326 >> [9,] 0.3834149 0.3834149 0.3834149 >> [10,] 0.3433031 0.3433031 0.3433031 >> >> >> >> On Tue, D

[R] Fwd: fields package question

2018-12-26 Thread Eric Berger
discussion -- Forwarded message - From: M P Date: Wed, Dec 26, 2018 at 6:32 PM Subject: Re: [R] fields package question To: Eric Berger Thanks, dput outputs below. I'd like to evaluate surface e.g. at (-10.5, 0.935) > dput(x) structure(c(-10.9251387646973, -10.89773

Re: [R] User Interfaces for R

2019-01-10 Thread Eric Berger
Shiny (from RStudio - and free) A wonderful tool. And the app is accessed via the user's browser. On Thu, Jan 10, 2019 at 4:18 PM Bernard McGarvey < mcgarvey.bern...@comcast.net> wrote: > I want to create an R application that includes a user interface where the > user inputs values etc and then

Re: [R] CRAN package NlcOptim query

2019-01-14 Thread Eric Berger
9 = c(0, 0), X60 = c(0, 0), X61 = c(0, > > 0), X62 = c(0, 0), X63 = c(0, 0), X64 = c(0, 0), X65 = c(0, > > 0), X66 = c(0, 0), X67 = c(0, 0), X68 = c(0, 0), X69 = c(0, > > 0), X70 = c(0, 0), X71 = c(0, 0), X72 = c(0, 0), X73 = c(0, > > 0), X74 = c(0, 0), X75 =

Re: [R] Extrapolate x values from a defined y sequence

2019-01-14 Thread Eric Berger
Hi Lionel, Your choice of variable names is a bit odd (the roles of x and y seem to be reversed from the usual.) Assuming that you are looking for linear interpolation (in spite of the subject of your email), does the following give you what you need? u1 <- approx(x=y1,y=x1,xout=y) u2 <- approx(x=

Re: [R] Operator Overloading in R

2019-01-16 Thread Eric Berger
I have experience with R6 classes but I have not used operator overloading with them. Out of curiosity I did a quick search and found this link which provides a step by step (I am not claiming it is the only way) https://stackoverflow.com/questions/49463235/arithmetic-operators-overload-for-r6class

<    1   2   3   4   5   6   >