Re: [R] NaN produced from log() with positive input

2015-07-11 Thread Arne Henningsen
Dear Maram On 8 July 2015 at 17:52, Maram Salem wrote: > Dear Arne, > > On a second thought, as per your mail "the warning messages occur each time, > when maxLik() tries to calculate > the logLik value for theta[1] <= 0, theta[1] + theta[2] <= 0, theta[3] <= 0 > or something similar." > > The co

Re: [R] Do grep() and strsplit() use different regex engines?

2015-07-11 Thread Bert Gunter
Thanks, Chuck (he says, red-faced). Maybe I should read the man page more carefully ...! And as for grep(), similar issues: (from ?grep) "POSIX 1003.2 mode of gsub and gregexpr does not work correctly with repeated word-boundaries (e.g., pattern = "\b"). Use perl = TRUE for such matches (but tha

Re: [R] Knitr/Lattice/Lyx [was: Trellis Plots: translating lattice xyplot() to ggplot()]

2015-07-11 Thread David Winsemius
On Jul 11, 2015, at 5:47 PM, David Winsemius wrote: > > On Jul 11, 2015, at 5:30 PM, Rich Shepard wrote: > >> On Sat, 11 Jul 2015, Rich Shepard wrote: >> >>> The .RData and .lyx files were stripped off. I'll try sending them again. >> >> .RData didn't make it. Perhaps now. > > Please stop tr

Re: [R] Knitr/Lattice/Lyx [was: Trellis Plots: translating lattice xyplot() to ggplot()]

2015-07-11 Thread Jeff Newmiller
Read the Posting Guide. Most attachments get stripped on the list to discourage viruses and encourage small, reproducible examples in the body of the email. --- Jeff NewmillerThe . .

Re: [R] Knitr/Lattice/Lyx [was: Trellis Plots: translating lattice xyplot() to ggplot()]

2015-07-11 Thread David Winsemius
On Jul 11, 2015, at 5:30 PM, Rich Shepard wrote: > On Sat, 11 Jul 2015, Rich Shepard wrote: > >> The .RData and .lyx files were stripped off. I'll try sending them again. > > .RData didn't make it. Perhaps now. Please stop trying to send data types that are explicitly not allowed. (I was sur

Re: [R] Knitr/Lattice/Lyx [was: Trellis Plots: translating lattice xyplot() to ggplot()]

2015-07-11 Thread Yihui Xie
Perhaps it is not obvious to you, but it is fairly obvious to me that the R code in this code chunk is incomplete: <<>>= xyplot(value ~ sampdate | variable, data=carlin.2.melt, rm.na = T, ylab = 'Measured Value', xlab = 'Date' @ There is a ')' missing in the end. When you see errors from parse(),

Re: [R] Knitr/Lattice/Lyx [was: Trellis Plots: translating lattice xyplot() to ggplot()]

2015-07-11 Thread Rich Shepard
On Sat, 11 Jul 2015, Rich Shepard wrote: The .RData and .lyx files were stripped off. I'll try sending them again. .RData didn't make it. Perhaps now. Rich __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/

Re: [R] Knitr/Lattice/Lyx [was: Trellis Plots: translating lattice xyplot() to ggplot()]

2015-07-11 Thread Rich Shepard
On Sat, 11 Jul 2015, Rich Shepard wrote: Attached are the .RData file from the cwd, the test.lyx file (lyx-2.1.3), and the two test files from /tmp/.../lyx_tmpbuf3/. The .RData and .lyx files were stripped off. I'll try sending them again. Rich#LyX 2.1 created this file. For more info see

Re: [R] change font size within the panel.text function (package lattice)

2015-07-11 Thread David Winsemius
On Jul 11, 2015, at 4:46 PM, Luigi Marongiu wrote: > Dear all, > I am adding some text to the panels of a graph generated through the > lattice function using the argument: > xyplot( ..., > panel = > function(x, y,...) > { > panel.xyplo

Re: [R] Knitr/Lattice/Lyx [was: Trellis Plots: translating lattice xyplot() to ggplot()]

2015-07-11 Thread Rich Shepard
On Sat, 11 Jul 2015, Yihui Xie wrote: I guess you didn't tell us you were compiling the document with dvips That's how I preview lyx docs for the past decade-and-a-half or so. The final .pdf is generated with pdflatex. There is now an issue when a second figure is added to the document: i

[R] change font size within the panel.text function (package lattice)

2015-07-11 Thread Luigi Marongiu
Dear all, I am adding some text to the panels of a graph generated through the lattice function using the argument: xyplot( ..., panel = function(x, y,...) { panel.xyplot(x,y,...) panel.text(0,0,labels=V[panel.numb

Re: [R] Do grep() and strsplit() use different regex engines?

2015-07-11 Thread Charles C. Berry
On Sat, 11 Jul 2015, Bert Gunter wrote: David/Jeff: Thank you both. You seem to confirm that my observation of an "infelicity" in strsplit() is real. That is most helpful. I found nothing in David's message 2 code that was surprising. That is, the splits shown conform to what I would expect f

Re: [R] Do grep() and strsplit() use different regex engines?

2015-07-11 Thread Bert Gunter
omigosh -- you're right. -- Bert Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On Sat, Jul 11, 2015 at 3:31 PM, David Winsemius wrote: > > On Jul 11, 2015, at 3:07 PM, Bert Gunter wrote: > >> David/Jeff: >> >> T

Re: [R] [FORGED] data$variable=factor(....)

2015-07-11 Thread Rolf Turner
Try: ggg <- c("F","M","F",M") data$gender <- factor(ggg[data$gender]) This in effect converts the (spurious) " F" and " M" levels into "F" and "M" respectively, giving you a factor with the two levels that you really want. cheers, Rolf Turner P. S. *Not* a good idea to use "data" as the

Re: [R] add outer strip for levels in lattice plot (useOuterStrips alternative for Lattice)

2015-07-11 Thread Luigi Marongiu
Dear Duncan, I tried the solution you indicated in the previous message but I am still obtaining the error length(dimx) == 2 is not TRUE. Assuming that the dataframe is working (it does work on my machine), I added the useOuterStrips bit as you showed: useOuterStrips( strip = strip.custom(

Re: [R] Do grep() and strsplit() use different regex engines?

2015-07-11 Thread David Winsemius
On Jul 11, 2015, at 3:07 PM, Bert Gunter wrote: > David/Jeff: > > Thank you both. > > You seem to confirm that my observation of an "infelicity" in > strsplit() is real. That is most helpful. > > I found nothing in David's message 2 code that was surprising. That > is, the splits shown conform

Re: [R] Do grep() and strsplit() use different regex engines?

2015-07-11 Thread Bert Gunter
David/Jeff: Thank you both. You seem to confirm that my observation of an "infelicity" in strsplit() is real. That is most helpful. I found nothing in David's message 2 code that was surprising. That is, the splits shown conform to what I would expect from "\\b" . But not to what I originally sh

Re: [R] data$variable=factor(....)

2015-07-11 Thread Peter Langfelder
There are two issues here. First, your original factor seems to have 4 levels: " F", " M", "F", "M". Note the extra space in front of the first two F and M. You may want to fix that first: gender.fixed = sub(" ", "", as.character(data$gender)) Check that everything is correct by typing table(gen

Re: [R] Rolling Window Granger Causality

2015-07-11 Thread Jeff Newmiller
This is a rather broad request. If you are looking for help understanding these topics, you should probably ask in a forum where statistical theory is on topic (e.g. stats.stackexchange.com), since in this forum you should already have a good idea of what algorithms you want to apply and in what

Re: [R] data$variable=factor(....)

2015-07-11 Thread Rui Barradas
Hello, Just to add that the op's data$gender has 4 levels, not just 2. So it would be better to remove the leading spaces from " F" and " M", by using ?sub or ?gsub. Hope this helps, Rui Barradas Em 11-07-2015 21:19, Jeff Newmiller escreveu: Well, you can help yourself on this list if you

Re: [R] data$variable=factor(....)

2015-07-11 Thread Jeff Newmiller
Well, you can help yourself on this list if you stop letting your email client determine the format (HTML in this case) that you use since that format gets corrupted on this mailing list leading to frequent misunderstandings. Learn how to make your email client send plain text format. If you

[R] data$variable=factor(....)

2015-07-11 Thread Dagmar Juranková
Hello everybody, I have a problem with R. I uploaded a questionnaire saved as csv into R and I tried to test independence between two variables. data <- read.csv("C:/Users/Me/Desktop/data.csv")> View(data)> df = read.csv("C:/Users/Me/Desktop/data.csv")> ls() [1] "df" "data"> attributes(d

[R] Rolling Window Granger Causality

2015-07-11 Thread Syed Jawad Hussain Shahzad
Dear Sir, Hi I am new to R and want some help on the subject analysis. I need help to apply causality analysis (available in Package 'VARS') with a per-define rolling window (like rollapply in Package 'Zoo'). Best Wishes Jawad __ R-help@r-project.org m

Re: [R] Do grep() and strsplit() use different regex engines?

2015-07-11 Thread Jeff Newmiller
I was going to recommend the regular-expression.info website, but you got to it first. I tried looking at the source, but it is kind of dense. I think stepping through the code below may illustrate why the zero width match returned from "\\b" cannot be allowed as-is or the strsplit algorithm w

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot() [RESOLVED]

2015-07-11 Thread Yihui Xie
I guess you didn't tell us you were compiling the document with dvips (BTW, I'm surprised that dvips is still alive today...), otherwise the solution would be simply to use the postscript device instead of the default pdf device (i.e. use the chunk option dev='postscript'). Hopefully you learned so

Re: [R] Do grep() and strsplit() use different regex engines?

2015-07-11 Thread David Winsemius
On Jul 11, 2015, at 11:05 AM, David Winsemius wrote: > > On Jul 11, 2015, at 7:47 AM, Bert Gunter wrote: > >> I noticed the following: >> >>> strsplit("red green","\\b") >> [[1]] >> [1] "r" "e" "d" " " "g" "r" "e" "e" "n" > > After reading the ?regex help page, I didn't understand why `\b` wo

Re: [R] Do grep() and strsplit() use different regex engines?

2015-07-11 Thread David Winsemius
On Jul 11, 2015, at 7:47 AM, Bert Gunter wrote: > I noticed the following: > >> strsplit("red green","\\b") > [[1]] > [1] "r" "e" "d" " " "g" "r" "e" "e" "n" After reading the ?regex help page, I didn't understand why `\b` would split within sequences of "word"-characters, either. I expected t

Re: [R] Do grep() and strsplit() use different regex engines?

2015-07-11 Thread Bert Gunter
Thanks Jeff. That doesn't explain it for me. Could you go through the algorithm a step at a time to show why it splits at the individual characters rather than the words, perhaps privately. Feel free to refuse, as I'm sure you have better things to do. -- Bert Bert Gunter "Data is not informati

Re: [R] A question about nlmer in lme4 package

2015-07-11 Thread Ben Bolker
Patty Haaem via R-help r-project.org> writes: > Dear all,I have studied “Mixed models in R using the lme4 package > Part 6: Nonlinear mixed models” by Douglas Bates. In this tutorial, > there are some codes to fit nonlinear mixed models for Theoph > data. The codes are as [follows:] Th. start <

Re: [R] Do grep() and strsplit() use different regex engines?

2015-07-11 Thread Jeff Newmiller
"\\b" is a zero length match. strsplit seems to chop at least one character off the beginning of the string if it sees a match, and then it looks at the shortened string that remains and repeats. --- Jeff Newmiller

Re: [R] R 3.1.2 : arima.sim(model=list(ma=0.5), n=250, innov=rnorm(250, mean=0, sd=0.1)) versus arima.sim(model=list(ma=0.5), n=250, mean=0, sd=0.1) => only the first element is not identical !

2015-07-11 Thread Mark Leeds
Hi Fabian: I think one would say that that is not a bug. I looked at the details of arima.sim ( using debug(arima.sim) ) and there are two different series that are created inside the function. one is called innov and the other is start.innov. start.innov is used to create a burn in period for the

[R] Do grep() and strsplit() use different regex engines?

2015-07-11 Thread Bert Gunter
I noticed the following: > strsplit("red green","\\b") [[1]] [1] "r" "e" "d" " " "g" "r" "e" "e" "n" > strsplit("red green","\\W") [[1]] [1] "red" "green" I would have thought that "\\b" should give what "\\W" did. Note that: > grep("\\bred\\b","red green") [1] 1 ## as expected Does strsplit

Re: [R] detecting any element in a vector of strings, appearing anywhere in any of several character variables in a dataframe

2015-07-11 Thread Bert Gunter
Note that John's solution probably includes incorrect partial matches and that mine fails to match "red" in "this is red." If you change my proposal to sapply(strsplit(do.call(paste,zz[,2:3]),"\\W"), function(x)any(x %in% alarm.words)) it should agree with Jeff's. Note, however, that you have mi

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot() [RESOLVED]

2015-07-11 Thread Rich Shepard
On Fri, 10 Jul 2015, Yihui Xie wrote: Your LyX example has two problems: Yihui, et al.: All fixed now. After adding the specific libraries the chuck calling xyplot() to produce the graphic caused an error when I tried to generate a dvips preview: LaTeX Error: File 'figure/unnamed-chunk-7-1

[R] A question about nlmer in lme4 package

2015-07-11 Thread Patty Haaem via R-help
Dear all,I have studied “Mixed models in R using the lme4 package Part 6: Nonlinear mixed models” by Douglas Bates. In this tutorial, there are some codes to fit nonlinear mixed models for Theoph data. The codes are as fallows:  >Th. start <- c(lKe = -2.5, lKa = 0.5 , lCl = -3)> nm1 <- nlmer ( co

[R] R 3.1.2 : arima.sim(model=list(ma=0.5), n=250, innov=rnorm(250, mean=0, sd=0.1)) versus arima.sim(model=list(ma=0.5), n=250, mean=0, sd=0.1) => only the first element is not identical !

2015-07-11 Thread Fabien Tarrade
Dear all, When doing a DataCamp tutorial with R I find the following observation that using 2 different syntax for "arima.sim" give different answer for the first element If I use the the function using the list of argument describe in the help manual : arima.sim(model=list(ma=0.5),n=250,in

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-11 Thread Rich Shepard
On Fri, 10 Jul 2015, Yihui Xie wrote: Your LyX example has two problems: 1) We don't have your .RData; 2) You didn't library(reshape) and library(lattice). Hence it is not a self-contained reproducible example. Yihui, I assumed that reading in the *.csv file would create a local .RData file