[R] optimisation, pseudo maximum likehood and family exponential in R

2010-04-21 Thread Eric
Hello, By fixing log_vraisemblance, gradient and hessian function linked to a family density like exp(theta.xi), I'm looking for some efficients estimators by PML. So I've seen optim,nlminb, et maxLik procedure. But I 'm not sure that the heteroscedacity of my estimators are considered. Does an

Re: [R] Obtaining partial output from a function that does not run to completion.

2009-12-31 Thread Eric
To heck with print(), use R's debugging capabilities instead: trace ( minBMI, browser ) Be sure to ?trace and ?browser so you can figure out how to interactively debug. Eric On 12/31/09 6:29 AM, John Sorkin wrote: I have written a function that contains runs lm() vif() and glm()

[R] Creating dates to plot

2012-11-15 Thread eric
I have a dataframe that looks like this: head(x) Period AP AlMA BB All 1 200812 903,231 1,985,460 905,422 3,312,088 7,106,201 2 200901 880,491 1,924,111 892,980 3,006,050 6,703,631 3 200902 883,994 1,926,169

Re: [R] Dealing with factors ???

2012-11-15 Thread eric
The table is much bigger than what was shown. I just displayed a few rows. Seems like there should be a better way that the approach you are proposing. What is also not clear to me is why the factors are coming at all. I do a read.csv on a table full of numbers from excel and I'm seeing factors eve

[R] Dealing with factors ???

2012-11-15 Thread eric
I have a data frame x that came from read.csv. It seemed to read in ok but then I tried doing some plotting of the values and ran into difficulties. The plot command seems to be plotting factors instead of the values. How do I get rid of these factors ? The plot command I use is : plot (x$dat, x$T

[R] Reshaping a dataframe

2012-11-17 Thread eric
Seems like this should be easy but I'm struggling a bit. How do I rearrange a data frame to go from the first one to the second shown below ? State Datelbs TX 200701 400 TX 200702 650 TX 200703 950 TX 200704 1000 FL 200701 200 FL

Re: [R] Reshaping a dataframe

2012-11-17 Thread eric
_names(res$labels[[2]]) : 'names' attribute [4] must be the same length as the vector [1] -Original Message- From: arun kirshna [via R] To: eric Sent: Sat, Nov 17, 2012 5:23 pm Subject: Re: Reshaping a dataframe HI, Try this: dat1<-read.table(text=" State D

Re: [R] Reshaping a dataframe

2012-11-17 Thread eric
Didn't try the other two methods as I spent a bit of time trying to learn about reshape2. I was also able to melt the data and that went fine (although based on your post, melting is not needed). Any ideas on why reshape2 dcast is giving fits ? -- View this message in context: http://r.78969

Re: [R] Reshaping a dataframe

2012-11-17 Thread eric
705 200706 200707 200708 200709 200710 ... $ kg : Factor w/ 284 levels "-18,646","-3,199,893",..: 123 137 97 175 107 96 173 178 121 146 .. -Original Message- From: arun kirshna [via R] To: eric Sent: Sat, Nov 17, 2012 5:47 pm Subject: Re: Reshaping a dataframe

[R] Replace with something else

2012-11-18 Thread eric
I am reading some data into R from an Excel spreadsheet using read.csv. Some of the original data that comes into column 1 from the spreadsheet is text that says NA. The NA stands for north america. As it comes in, R converts the NA over to . What is the cleanest way to change the values to so

Re: [R] Replace with something else

2012-11-18 Thread eric
I inserted na.strings='' and that seemed to work except for a problem with a plot statement plot(x1$NA,type='l',ylab='M kg/ y ',xlab='') Error: unexpected numeric constant in "plot(x1$NA" > tail(x1) AP EU LANA total Jun 2012 2.32 2.26 5.38 13.74 23.70 Jul 2012 2.46 2.21 5.33 1

[R] Help with loess

2012-11-19 Thread eric
Not sure what I'm doing wrong. Can't seem to get loess values. It looks like loess is returning the same values as the input. j <-loess(x1$total~as.numeric(index(x1) plot(x1$total,type='l', ylab='M coms/y global',xlab='') lines(loess(total~as.numeric(index(x1)),x1)) The plot statement works fine

Re: [R] how to get bootstrap estimates

2012-11-19 Thread eric
You might want to check out the bootstrap package. Also consider clarifying what you want to bootstrap ...mec or vec or what Lastly, it is not clear what you mean when you say ... and I have the next errors: ro 12 = ro (mec,vec) ro 34 = ro (alg,ana) ro 35 = ro (alg,sta) ro 45 = ro (ana,sta

[R] Plotting specific points with type='l'

2012-11-22 Thread eric
I have a dataframe (x) and I'm plotting the 5th column vs the index. I also have a vector (v) with a few select points that I want to emphasize with a dot for those points > head(x) period AP EU LA NA 1 Jan 2007 0.18 0.45 0.19 3.19 2 Feb 2007 0.14 0.48 0.36 3.55 3 Mar 2007 0.14 0.42 0.

[R] How do I subtract sequential values ?

2010-11-28 Thread eric
Just starting to learn R so excuse me if this is a simple question. I'm wondering how I get the percent difference in sequential values in one column of a dataframe. If I had a dataframe and one of the columns was "value", how would I go about calculating (v2-v1)/v1 (v3-v2)/v2 (v4-v3)/v3

[R] pdf package help files

2010-12-18 Thread eric
Newbie here...just learning Do most packages come with pdf versions of the help files ? If yes, how to I access the entire pdf file to be able to print it ? Is there a standard command for that ? -- View this message in context: http://r.789695.n4.nabble.com/pdf-package-help-files-tp3093926p30

[R] package update

2010-12-26 Thread eric
I'm running Linux Ubuntu and tried to update my packages using the update.package() command. It appeared to download the updates ok but I got the following message: The downloaded packages are in ‘/tmp/RtmpFM82Ry/downloaded_packages’ Warning in install.packages(update[instlib == l, "Package"], l

[R] data frame column name change

2011-01-16 Thread eric
How do I change the name of one column in a data frame ? Suppose I have a data frame x with 5 columns. If the names were date, col1, col2, col3, col4 and I wanted to simply change the name of date, what would the command be ? I tried the following and it didn't seem to work : names(x[1]) <- "newn

[R] Log difference in a dataframe column

2011-01-17 Thread eric
What am I doing wrong here ? And what's the right way to calculate the log differences in a column in a df ? # first 3 rows of 5000 rows y[1:3,] Date Open High Low Close 1 1983-03-30 29.96 30.51 29.96 30.35 2 1983-03-31 30.35 30.55 30.20 30.24 3 1983-04-04 30.25 30.65 30.24 30.39 #equation

Re: [R] Log difference in a dataframe column

2011-01-18 Thread eric
Just learning so excuse me if I'm being too basic here. But I'm wondering how should I know that as.ts would be needed for lag ? Is there a thought process or way to inspect that I should have gone through to know that log would work on y[,5] but lag would not work on [,5] ? Is the general rule

[R] Vectorization

2011-01-23 Thread eric
Is there a way to vectorize this loop or a smarter way to do it ? y [1] 0.003990746 -0.037664639 0.005397999 0.010415496 0.003500676 [6] 0.001691775 0.008170774 0.011961998 -0.016879531 0.007284486 [11] -0.015083581 -0.006645958 -0.013153103 0.028148639 -0.005724317 [16] -0.027408025

[R] Using diff and transform

2011-01-25 Thread eric
I want to use diff to take the differences in a column "Close" of a data frame "y". But I'd like to do it using the transform function so a new data frame is created with a difference column. The problem is that diff gives one less than the number of elements in the original data frame. So transfo

[R] why doesn't ifelse work ?

2011-04-28 Thread eric
I have the following lines of code: ind <- rollapply(GSPC, 200, mean) signal <- ifelse(diff(ind, 5) > 0 , 1 , -1) signal[is.na(signal)] <- 0 I never get a value of -1 for signal even though I know diff(ind , 5) is less than zero frequently. It looks like when diff(ind , 5) is less than zero, sign

Re: [R] why doesn't ifelse work ?

2011-04-28 Thread eric
equire(quantmod) require(PerformanceAnalytics) rm(list=ls()) getSymbols("^GSPC", src="yahoo", from="1990-01-01", to=Sys.Date()) GSPC <-na.omit(Ad(GSPC)) ind <- rollapply(GSPC, 200, mean) signal <- ifelse(diff(ind, 5) > 0 , 1 , -1) signal[is.na(signal)] <- 0 -- View this message in context: http:/

Re: [R] why doesn't ifelse work ?

2011-04-28 Thread eric
from the console ... > table(signal) signal 01 1286 3885 note there is no -1 value. This is consistent with what I see if if plot(signal). When I issue that statement from the console, I see signal vary between 0 and 1.0 but it never goes to - 1 -- View this message in context: http

[R] package update

2011-05-08 Thread eric
I tried to update my packages using update.packages() I got the following message: The downloaded packages are in ‘/tmp/RtmpyDYdTX/downloaded_packages’ Warning in install.packages(update[instlib == l, "Package"], l, contriburl = contriburl, : 'lib = "/usr/lib/R/library"' is not writab

Re: [R] package update

2011-05-10 Thread eric
ok, how do I do root permissions from the RStudio GUI ? What is the specific command that allows me to do that when I type ...update.packages() ? Also, why are the packages installing in the first place if I can't write to that location ? Currently running linux ubuntu 10.04 by the way. -- Vie

[R] Need help with text processing / string split

2011-05-15 Thread eric
I used screen scraping to extract some information and put it into a table called tbl. Now I want to modify the table a bit so the data can be more useful. Here's the code I used: library(XML) rm(list=ls()) url <- "http://webapp.montcopa.org/sherreal/salelist.asp?saledate=05/25/2011"; tbl <-data.f

[R] What am I doing wrong with sapply ?

2011-05-25 Thread eric
Statement 9 using sapply does not seem to give the correct answer (or at least to me). Yet I do what I think is the same thing with statement 11 and I get the answer I'm looking for. 9 : s <-sapply(unlist(v[c(1:length(v))]), max) 11: for(i in 1 :length(v)) v1[i] <- max(unlist(v[i])) Shouldn't I

[R] newbie xml parsing question

2011-05-28 Thread eric
I am trying to read some data off the zillow site. Newbie to xml, html, parsing and the xml package. I've been able to load the web page I'm interested with the following code but I'm not sure of the next step to get the information I'm interested in into R : library(XML) url <- "http://www.zillow

[R] Need help reading website info with XML package and XPath

2011-05-30 Thread eric
Hi, I'm looking for help extracting some information of the zillow website. I'd like to do this for the general case where I manually change the address by modifying the url (see code below). With the url containing the address, I'd like to be able to extract the same information each time. The spe

Re: [R] advice?

2010-05-05 Thread Eric
Download the trial version of UltraEdit (windows only) to open, inspect and edit the file. Rename columns as needed. Set a long Tab stop, Find/replace your delimiters to tabs (^t) and use column mode to remove unneeded columns. You can also split the file and check if loading in increments help.

[R] How do I fix this ?

2011-01-26 Thread eric
Just when I think I'm starting to learn Statement z1 works, statement z doesn't. Why doesn't z work and what do I do to fix it ? Clearly the problem is with the first NA, but I would think it's handled through the loop vectorization. y1 <- rnorm(20, 0, .013) y1 [1] -0.0068630836 -0.01011

[R] There must be a smarter way

2011-01-27 Thread eric
Newbie and trying to learn the right way of doing things in R. in this case, I just have that feeling that my convoluted line of code is way more complicated than it needs to be. Please help me in seeing the easier way. I want to do something pretty simple. I have a dataframe called x that is 694

[R] How to do a moving window on standard deviation

2011-01-30 Thread eric
I'd like to use vectorization to take a 4 point moving window on standard deviation on the close column and create another variable (st.dev) in the dataframe. Here's the dataframe head(xyz) Date Close 1 2011-01-28 56.42 2 2011-01-27 57.37 3 2011-01-26 56.48 4 2011-01-25 56.39 5 2011-01-2

Re: [R] How to do a moving window on standard deviation

2011-01-30 Thread eric
I'd rather do this without getting into zoo objects at the moment. OK, how about with a simple loop ? Why doesn't this work ? attach(xyz) j <- for(i in 4: length(Close)) sd(Close[i]:Close[(i-3)]) -- View this message in context: http://r.789695.n4.nabble.com/How-to-do-a-moving-window-on-standar

[R] Accessing DF index

2011-02-19 Thread eric
I have a dataframe called x2. It seems to have a date column but I can't access it or give it a name or convert it to a date. How do I refer to that first column and make it a date ? When I try x2[1,] I get the second column. head(x2) FAIRXSP500delta 2000-08-31

Re: [R] Accessing DF index

2011-02-19 Thread eric
So how would I convert those row names to dates and give that column the name "Date" so that I can use subset and other functions on the Date column ? -- View this message in context: http://r.789695.n4.nabble.com/Accessing-DF-index-tp3314649p3314689.html Sent from the R help mailing list archiv

[R] Plotting two lines on a graph when using par(mfrow=)

2011-02-27 Thread eric
Basic question but still learning How do I plot two lines (f$equity and f$bh.equity) on one of the three graphs under mfrow ? I tried putting brackets around the first plot and lines command but that didn't work. par(mfrow=c(3,1)) {plot(f$Date,f$equity, col="blue", type="l", main="equity") l

[R] What am I doing wrong with this loop ?

2011-03-02 Thread eric
What is wrong with this loop ? I am getting an error saying incorrect number of dimensions y[i,2] x <- as.data.frame(runif(2000, 12, 38)) z <-numeric(length(x)) y <- as.data.frame(z) for(i in 1:length(x)) { y <- ifelse(i < 500, as.data.frame(lowess(x[1:i,1], f=1/9)) , as.data.frame(lowess(x[(i-

Re: [R] What am I doing wrong with this loop ?

2011-03-03 Thread eric
Bill, I addressed the first issue with the data frames and length(x). But my loops still isn't working. More importantly, you commented that I should be using if(...) ... else ... rather than ifelse(.,.,). Please help me understand the difference. I thought ifelse was just a faster way of doing if

Re: [R] What am I doing wrong with this loop ?

2011-03-03 Thread eric
Never mind Billgot it. Always seems to happen this way. Can't figure something out. Post to the site and wham, 5 min later (after posting), it's all clear. Oh well, thanks for the tips -- View this message in context: http://r.789695.n4.nabble.com/What-am-I-doing-wrong-with-this-loop-tp3332

[R] Why doesn't this work ?

2011-03-16 Thread eric
Why doesn't this work and is there a better way ? z <-ifelse(t==1 || 2 || 3, 1,0) t <-3 z [1] 1 t <-4 z [1] 1 trying to say ...if t == 1 or if t== 2 or if t ==3 then true, otherwise false -- View this message in context: http://r.789695.n4.nabble.com/Why-doesn-t-this-work-tp3383656p3383656.html

[R] How do I modify uniroot function to return .0001 if error ?

2011-04-03 Thread eric
I am calling the uniroot function from inside another function using these lines (last two lines of the function) : d <- uniroot(k, c(.001, 250), tol=.05) return(d$root) The problem is that on occasion there's a problem with the values I'm passing to uniroot. In those instances uniroot stops and

[R] Where did my packages go ?

2011-04-18 Thread eric
Running linux 10.04 ubuntu. Looks like Ubuntu automatically updated to version 2.13. I was running version 2.12 until today. But now I'm getting error messages when I use the require or library command and one of the packages I've downloaded in the past. For example: > require(quantmod) Loading

[R] How do I subset a dataframe

2011-08-14 Thread eric
I have a dataframe zeespan. One of the columns has the name "customer". The data in the customer column is text. I would like to return a subset of the dataframe with all rows that DON'T begin with either "ibm" or "exxon", or "sears" in the customer column. I tried subset(zeespan, customer !

[R] Not sure how to use aggregate, colSums, by

2011-08-14 Thread eric
I have a data frame called test shown below that i would like to summarize in a particular way : I want to show the column sums (columns y ,f) grouped by country (column e1). However, I'm looking for the data to be split according to column e2. In other words, two tables of sum by country. One tab

[R] factor coercion with read.csv or read.table

2012-06-06 Thread eric
How do I fix this error ? I tried coercion to a vector but that didn't work. msci <-read.csv("..MSCIexUS.csv", header=TRUE) head(msci) Date index 1 Dec 31, 1969100 2 Jan 30, 1970 97.655 3 Feb 27, 1970 96.154 4 Mar 31, 1970 95.857 5 Apr 30, 1970 85.564 6 May 29, 1970 79.005 > str(m

[R] Gaps on merging xts objects

2012-06-10 Thread eric
Looking for a little help figuring out what's driving gaps in data after merging two xts objects (msci.m and x2). The merge statement I'm using is ... y <-merge(x2,msci.m, all=FALSE). Here's info on the output , y: head(y) t-bill msci Sep 1985 7.310 316.963 Mar 1986 6.560 463.47

Re: [R] Gaps on merging xts objects

2012-06-10 Thread eric
An update ... I did a bit more search on the internet and got some ideas i set the start month for the series to the same date. That didn't help. Then I tried .index(x2)==.index(msci.m) FALSE i was able to fix the problem with : index(x2) <- as.Date(index(x2)) index(msci.m) <- as.Date(index(ms

[R] Stuck ...can't get sapply and xmlTreeParse working

2011-07-04 Thread eric
Can't seem to get the code below working. It gets stuck on line 24 inside the function hm; comments show the line in question. The function hm is called by sapply and is at the bottom of the code. Other stuff above line 24 works correctly including the first couple of lines of the function hm. Shou

[R] Help with tryCatch

2011-07-10 Thread eric
Having a hard time understanding the help files for tryCatch. Looking for a little help with the following statement which sits inside a for loop zest[i] <- tryCatch(sapply(getNodeSet(zdoc, "//zestimate/amount"), xmlValue), error=function() zest[i] <-"NA") zest is a numeric vector If the sapply

Re: [R] Help with tryCatch

2011-07-10 Thread eric
I tried the following: zest[i] <- tryCatch(sapply(getNodeSet(zdoc, "//zestimate/amount"), xmlValue), error=function() NA) Here's what happens : Error in zest[i] <- tryCatch(sapply(getNodeSet(zdoc, "//zestimate/amount"), : replacement has length zero -- View this message in context: http:

Re: [R] Help with tryCatch

2011-07-10 Thread eric
Bill, first off, thanks much for helping me through this. I think the best approach might be for me to attach the actual code. I could probably do the if-else-else that you suggested. But I have eight different variables with the same basic issue (note that six of the eight are commented out whil

[R] Is there a better way ?

2011-07-10 Thread eric
Is there a more compact way to say this ? r <-numeric(length(p)) ; s <-numeric(length(p)); t <- numeric(length(p)); u <- numeric(length(p)); v <- numeric(length(p)) ; x <-numeric(length(p)) all these variables will be used in a loop for (i in 1 : length(p)) { r[i] <- s[i] <- t[i] <- etc } -- V

[R] install.packages problem

2011-11-05 Thread eric
led for package ‘RCurl’ The install continued after the error but looks like it was completed. I'm trying to figure out what the error means and how I fix it. Here's what I'm seeing ...ideas on how to address this would be appreciated : install.packages('rdatamarket')

[R] DESeq

2011-11-07 Thread Eric
eady, so I'm a bit confused. Thanks, Eric [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and

[R] Warning message interpretation

2011-11-07 Thread eric
Using the rmarketdata package and getting a warning message. What does this warning message tell me ? What could I do to eliminate or address it ? require(rdatamarket) Loading required package: rdatamarket Loading required package: zoo Warning message: In assignInNamespace("as.Date.numeric", f

[R] update.packages() issue

2011-11-09 Thread eric
I updated packages using the update.packages() command but now having problems. i now know I should have done this from the terminal (sudo rstudio and then update.packages()). Instead I just opened rstudio without the sudo command. So I know what to do going forward but how do I resolve the existin

[R] Error in axis ????

2011-11-09 Thread eric
I did an update of both rstudio and my packages. I had some trouble but was able to move a lot of the packages so most troubles seem to be behind me. But having a problem with code that previously ran fine. See below: require(quantmod) Loading required package: quantmod Loading required package: D

[R] Error in axis ????

2011-11-09 Thread eric
Recently updated my packages (update.packages() and also updated rstudio to the latest version. Had some problems but I thought I was able to get around them by moving my folders. However, now I'm seeing a bit of a snag with some code that previously ran fine. Hoping someone can suggest a fix. Her

Re: [R] Question about which kind of plot to use

2007-12-19 Thread Eric
u might also check out whether ggplot2 might be an option. I did a quick and dirty version (which I'm sure Hadley can improve and also remind me how to get rid of the legend that shows the "3" that I set the size to). Assuming your data is re-shaped, so it comes out something like mine in

Re: [R] adding layers in ggplot2 (data and code included)

2008-09-21 Thread Eric
t;- p + geom_smooth(aes(group=factor(Group),color=factor(Group)),method=lm,se=F) p Eric Juliet Hannah wrote: Here is some sample data: mydata <- read.table(textConnection("Est GroupTri 00 4.639644 10 4.579189 20 4.590714 0

Re: [R] ggplot2 problem

2008-11-26 Thread Eric
aes() does not have an argument, "Year" but it does have an argument "x" so try: df <- data.frame(Year = rep(1:5,2)) m <- ggplot(df, aes(x=Year)) m + geom_bar() (It works for me.) Eric steve wrote: I'm using ggplot2 2.0.8 and R 2.8.0 df = data.frame(Year =

Re: [R] as.data.frame doesn't set col.names

2017-10-25 Thread Eric Berger
e reference that works fine for me.) Regards, Eric On Wed, Oct 25, 2017 at 2:27 PM, Peter Dalgaard wrote: > > > On 24 Oct 2017, at 22:45 , David L Carlson wrote: > > > > You left out all the most important bits of information. What is yo? Are > you trying to assign a

Re: [R] R encountered a fatal error. The session was terminated. + *** caught illegal operation ***

2017-10-26 Thread Eric Berger
How about going back to earlier versions if you don't need the latest ones? On Thu, Oct 26, 2017 at 12:59 PM, Klaus Michael Keller < klaus.kel...@graduateinstitute.ch> wrote: > Dear all, > > I just installed the "Short Summer" R update last week. Now, my R Studio > doesn't open anymore! > > -->

Re: [R] My function and NA Values Problem

2017-10-27 Thread Eric Berger
na.rm=TRUE (you need to capitalize) On Fri, Oct 27, 2017 at 10:43 AM, Engin YILMAZ wrote: > Dear R Staff > > My working file is in the annex. "g1.csv" > I have only 2 columns. Rice and coke. > I try to execute following(below) function, but do not work. > Because "Coke" value has NA values. >

Re: [R] Count non-zero values in excluding NA Values

2017-10-29 Thread Eric Berger
If one does not need all the intermediate results then after defining data just one line: grand_total <- nrow(data)*ncol(data) - sum( sapply(data, function(x) sum( is.na(x) | x == 0 ) ) ) # 76 On Sun, Oct 29, 2017 at 2:38 PM, Rui Barradas wrote: > Hello, > > Your attachment didn't came throu

Re: [R] Pass Parameters to RScript?

2017-10-30 Thread Eric Berger
I did a simple search and got hits immediately, e.g. https://www.r-bloggers.com/passing-arguments-to-an-r-script-from-command-lines/ On Mon, Oct 30, 2017 at 2:30 PM, Morkus via R-help wrote: > Is it possible to pass parameters to an R Script, say, from Java or other > language? > > I did some

Re: [R] Pass Parameters to RScript?

2017-10-30 Thread Eric Berger
/showtutorial.php?tutorialid=8 On Mon, Oct 30, 2017 at 5:10 PM, Morkus wrote: > Thanks Eric, > > I saw that page, too, but it states: > > "This post describes how to pass external arguments to *R* when calling a > Rscript *with a command line.*" > > Not what I&#

Re: [R] convertTime package.

2017-10-31 Thread Eric Berger
r R version 3.4.1)" I did a Google search and found a package called SGP that has a function "convertTime". I have no idea if it is the function you are looking for but installing that package worked fine in R version 3.4.1. So you can try > install.packages("SGP") H

Re: [R] beta binomial distribution installation

2017-11-01 Thread Eric Berger
Hi, I did a quick search for other packages that provide the beta binomial distribution and found "rmutil". > install.packages("rmutil") The package has the CDF (pbetabinom) and inverse CDF (qbetabinom) among other functions. HTH, Eric On Wed, Nov 1, 2017 at 7:50 AM

Re: [R] Function to save results

2017-11-01 Thread Eric Berger
l code) sink( "filename" ) do something that prints output which will be captured by sink sink() HTH, Eric On Wed, Nov 1, 2017 at 1:32 PM, Priya Arasu via R-help wrote: > Hi,I want the results to be saved automatically in a output text file > after the script has finished running.

Re: [R] Function to save results

2017-11-01 Thread Eric Berger
lysis_all genes//synaptogenesis//attr.txt") net <- loadNetwork("C://Users//Priya//Desktop//Attractor analysis_all genes//synaptogenesis//regulationof_dopamine_signaling_submodule3.txt") attr <- getAttractors(net, type="asynchronous") sink() HTH, Eric On Wed, Nov 1, 2

Re: [R] beta binomial distribution installation

2017-11-01 Thread Eric Berger
ion(x,N,u,v) { rmutil::pbetabinom(x,N,u/(u+v),u+v) } # CDF myqbb <- function(x,N,u,v) { rmutil:qbetabinom{x,N,u/(u+v),u+v) } # inverse CDF HTH, Eric On Wed, Nov 1, 2017 at 6:09 PM, Amany Abdel-Karim wrote: > Hello, > > Thank you for your response. I need to install RankTail p

Re: [R] Correct subsetting in R

2017-11-01 Thread Eric Berger
matches <- merge(training,data,by=intersect(names(training),names(data))) HTH, Eric On Wed, Nov 1, 2017 at 6:13 PM, Elahe chalabi via R-help < r-help@r-project.org> wrote: > Hi all, > I have two data frames that one of them does not have the column ID: > > > str

Re: [R] Function to save results

2017-11-01 Thread Eric Berger
mentation ?saveRDS and ?readRDS HTH, Eric On Wed, Nov 1, 2017 at 6:02 PM, David L Carlson wrote: > Let's try a simple example. > > > # Create a script file of commands > > # Note we must print the results of quantile explicitly > > cat("x <- rnorm(50)\nprint

Re: [R] Correct subsetting in R

2017-11-01 Thread Eric Berger
training$TrainingRownum <- 1:nrow(training) data$DataRownum <- 1:nrow(data) matches <- merge(training,data,by=intersect(names(training),names(data))) The data frame 'matches' now has additional columns telling you the row in each data frame corresponding to the matched items.

Re: [R] Adding Records to a Table in R

2017-11-01 Thread Eric Berger
y="TransitDate", all.x=TRUE ) # replace the NA's by zero dfNew[is.na(dfNew)] <- 0 HTH, Eric On Wed, Nov 1, 2017 at 9:45 PM, Paul Bernal wrote: > Dear R friends, > > I am currently working with time series data, and I have a table(as data > frame) that has looks like

Re: [R] FW: Time Series

2017-11-07 Thread Eric Berger
Following Erin's pointer: library(zoo) times <- seq(from=as.POSIXct("2015-12-18 00:00:00"), to=as.POSIXct("2017-10-24 23:00:00"), by="hour") mydata <- rnorm(length(times)) tseri <- zoo( x=mydata, order.by=times ) HTH, Eric On Tue, Nov 7, 20

[R] Fwd: FW: Time Series

2017-11-07 Thread Eric Berger
erstand why some of your attempts worked and some did not work. Regards, Eric Hi Erin and Eric As both of you suggested I followed the Erin’s command It is failed with the following command when I wrote x , which is numeric vector. I says that unused argument. tseri <- zoo( x=mydat

Re: [R] Fitdistrplus and Custom Probability Density

2017-11-07 Thread Eric Berger
e.g. d <- function(x) { exp(-x^2/2)/(sqrt(2*pi)) } # just an example for you to test with; use your own density d(x) in your case Then define myCumDist, myQuantile as above and compare with pnorm, qnorm. HTH, Eric On Tue, Nov 7, 2017 at 4:22 PM, Lorenzo Isella wrote: > Dear All, > Ap

Re: [R] Ggplot error

2017-11-08 Thread Eric Berger
I was not able to reproduce this problem. I tried two environments 1. Ubuntu 14.04.5 LTS, R version 3.4.2 (same R version as yours) 2. Windows 10, same R version On Wed, Nov 8, 2017 at 9:50 AM, Zeki ÇATAV wrote: > Hello, > I've an error recently. > > ggplot(data = mtcars, aes(x= wt, y= mpg)) +

Re: [R] Adding Records to a Table in R

2017-11-08 Thread Eric Berger
;), by = "month")) dataset1NEW <- merge(TransitDateFrame, dataset1, by="TransitDate", all.x=TRUE) HTH, Eric On Wed, Nov 8, 2017 at 4:32 PM, PIKAL Petr wrote: > Hi > > Instead of attachments copy directly result of dput(TransitDateFrame) and > dput(dataset1) to

Re: [R] Calculating frequencies of multiple values in 200 colomns

2017-11-10 Thread Eric Berger
How about this workaround - add 1 to the vector x <- c(1,0,2,1,0,2,2,0,2,1) tabulate(x) # [1] 3 4 tabulate(x+1) #[1] 3 3 4 On Fri, Nov 10, 2017 at 4:34 PM, Marc Schwartz wrote: > Hi, > > To clarify the default behavior that Boris is referencing below, note the > definition of the 'bin' argument

Re: [R] effects package x axis labels

2017-11-11 Thread Eric Berger
y also supply a lot of examples at the end of the help page). A few experiments and the following seems to do what you asked for: > plot(allEffects(mylogit), + axes=list(x=list(gre=list(lab="black"),gpa=list(lab="white"),rank=list(lab="green")), +y=list(l

Re: [R] R6 object that is a list of referenced object

2017-11-16 Thread Eric Berger
length(self$e) + 1]] <<- person } ) ) > crowd <- Community$new() > crowd$add(Person1) > crowd$add(Person2) > crowd$e HTH, Eric On Thu, Nov 16, 2017 at 9:55 AM, Jeff Newmiller wrote: > See below. > > On Wed, 15 Nov 2017, Cristina Pascual wro

Re: [R] Risks of using "function <- package::function" ?

2017-11-17 Thread Eric Berger
without the pkg:: prefix and which are part of a name collision? One could then edit the code to include the pkg:: prefix to disambiguate those cases and verify via a repeated use of such a tool that there are no outstanding cases. Or alternative approaches to the issue? Thanks, Eric On Fri, Nov

Re: [R] Do I need to transform backtest returns before using pbo (probability of backtest overfitting) package functions?

2017-11-21 Thread Eric Berger
Hi Joe, The centering and re-scaling is done for the purposes of his example, and also to be consistent with his definition of the sharpe function. In particular, note that the sharpe function has the rf (riskfree) parameter with a default value of .03/252 i.e. an ANNUAL 3% rate converted to a DAIL

Re: [R] Do I need to transform backtest returns before using pbo (probability of backtest overfitting) package functions?

2017-11-21 Thread Eric Berger
that each column has mean MU_D and std deviation SIGMA_D. HTH, Eric On Tue, Nov 21, 2017 at 2:33 PM, Eric Berger wrote: > Hi Joe, > The centering and re-scaling is done for the purposes of his example, and > also to be consistent with his definition of the sharpe function. > I

Re: [R] Do I need to transform backtest returns before using pbo (probability of backtest overfitting) package functions?

2017-11-21 Thread Eric Berger
Correct Sent from my iPhone > On 21 Nov 2017, at 22:42, Joe O wrote: > > Hi Eric, > > Thank you, that helps a lot. If I'm understanding correctly, if I’m wanting > to use actual returns from backtests rather than simulated returns, I would > need to make su

Re: [R] Scatterplot of many variables against a single variable

2017-11-27 Thread Eric Berger
LOL. Great reply Jim. (N.B. Jim's conclusion is "debatable" by a judicious choice of seed. e.g. set.seed(79) suggests that making the request more readable will actually lower the number of useful answers. :-)) On Mon, Nov 27, 2017 at 11:42 AM, Jim Lemon wrote: > Hi Engin, > Sadly, your illustr

Re: [R] DeSolve Package and Moving Average

2017-11-29 Thread Eric Berger
Since you only provide pseudo-code I will give a guess as to the source of the problem. It is easy to get "burned" by use of the ifelse statement. Its results have the same "shape" as the first argument. My suggestion is to try replacing ifelse by a standard if ( ) { }

Re: [R] source files in temp environment

2017-12-02 Thread Eric Berger
I totally agree with Duncan's last point. I find it hard to reconcile your early remarks (which indicate a deep knowledge of programming) with the idea that your code is not built up from combining small(ish) functions. Small functions would generally be considered best practices. Try searching on

Re: [R] Rcpp, dyn.load and C++ problems

2017-12-02 Thread Eric Berger
.Call("compute_values_cpp") Also, if you were passing arguments to the C++ function you would need to declare the function differently. Do a search on "Rcpp calling C++ functions from R" HTH, Eric On Sun, Dec 3, 2017 at 3:06 AM, Martin Møller Skarbiniks Pedersen < trax

Re: [R] problem with the behaviour of dashed lines in R plots

2017-12-04 Thread Eric Berger
$yhat,type="l", col="black", mgp=c(2,0.5,0),cex.lab=1.6, lwd=2, lty=2,xlim=range(c(1.2,1.7)),ylim=rev(range(c(-19,-8 par(new = TRUE) plot(df1$B,as.numeric(df1$A),type="p", col="black", mgp=c(2,0.5,0),cex.lab=1.6,cex=2, xlab = "", ylab = "

Re: [R] Curiously short cycles in iterated permutations with the same seed

2017-12-07 Thread Eric Berger
of n (n=10 in your case). Enjoy! Eric On Fri, Dec 8, 2017 at 6:39 AM, Boris Steipe wrote: > I have noticed that when I iterate permutations of short vectors with the > same seed, the cycle lengths are much shorter than I would expect by > chance. For example: > > X <- 1:10 &g

[R] inefficient for loop, is there a better way?

2017-12-12 Thread Morway, Eric
The code below is a small reproducible example of a much larger problem. While the script below works, it is really slow on the true dataset with many more rows and columns. I'm hoping to get the same result to examp, but with significant time savings. The example below is setting up a data.frame

Re: [R] difference between ifelse and if...else?

2017-12-13 Thread Eric Berger
ifelse returns the "shape" of the first argument In your ifelse the shape of "3 > 2" is a vector of length one, so it will return a vector length one. Avoid "ifelse" until you are very comfortable with it. It can often burn you. On Wed, Dec 13, 2017 at 5:33 PM, jeremiah rounds wrote: > ifel

Re: [R] help with recursive function

2017-12-14 Thread Eric Berger
You seem to have a typo at this expression (and some others like it) Namely, you write any(!dat2$norm_sd) >= 1 when you possibly meant to write !( any(dat2$norm_sd) >= 1 ) i.e. I think your ! seems to be in the wrong place. HTH, Eric On Thu, Dec 14, 2017 at 3:26 PM, DIGHE, NILESH [A

  1   2   3   4   5   6   7   8   9   10   >