similar to: Stability and reliability of R (comment on Re: as.vector() broken on a matrix or array of type "list")

Displaying 20 results from an estimated 10000 matches similar to: "Stability and reliability of R (comment on Re: as.vector() broken on a matrix or array of type "list")"

2018 Sep 26
2
as.vector() broken on a matrix or array of type "list"
Hi, Unlike on an atomic matrix, as.vector() doesn't drop the "dim" attribute of matrix or array of type "list": m <- matrix(list(), nrow=2, ncol=3) m # [,1] [,2] [,3] # [1,] NULL NULL NULL # [2,] NULL NULL NULL as.vector(m) # [,1] [,2] [,3] # [1,] NULL NULL NULL # [2,] NULL NULL NULL is.vector(as.vector(m)) # [1] FALSE
2018 Sep 26
0
as.vector() broken on a matrix or array of type "list"
>>>>> Herv? Pag?s >>>>> on Tue, 25 Sep 2018 23:27:19 -0700 writes: > Hi, Unlike on an atomic matrix, as.vector() doesn't drop > the "dim" attribute of matrix or array of type "list": > m <- matrix(list(), nrow=2, ncol=3) > m > # [,1] [,2] [,3] > # [1,] NULL NULL NULL > # [2,] NULL NULL
2018 Jun 01
2
Time-series moving average question
You are right that there are no NAs in the practice data. But there are NAs in the moving average data. To see this, break your work into two separate steps, like this: tnr.ma <- ma(dat3[1:28], order=3) TNR_moving_average <- forecast(tnr.ma, h=8) I think you will find that the warning comes from the second step. Print tnr.ma and you will see some NAs. -Don -- Don MacQueen Lawrence
2018 Jun 01
0
Time-series moving average question
Hi Don, wow, you are so right. I picked that piece up from the bloggers tutorial and since I am R naive yet, I thought it was all one step moving_average = forecast(ma(tdat[1:31], order=2), h=5) Truly, I usually print and check at every step I can, as painful as it is sometimes. Great lesson for this novice usR. So the first and last values are NA in each case? Do you know why? Should I replace
2018 Jun 01
0
Time-series moving average question
Hello Don, thank you for your response. I appreciate your help. I am using the forecast package, originally I found it following a forecasting example on bloggers.com https://www.r-bloggers.com/time-series-analysis-using-r-forecast-package/ And subsequently located the complete pdf https://cran.r-project.org/web/packages/forecast/forecast.pdf Since I created this practice data using the
2018 Apr 25
0
Copy text from Script syntax into .txt
Try putting this options(echo=TRUE) at the beginning of your script See ?source for a clue -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 Lab cell 925-724-7509 ?On 4/24/18, 2:23 AM, "R-help on behalf of P. Roberto Bakker" <r-help-bounces at r-project.org on behalf of robertobakker at gmail.com> wrote:
2018 Jun 01
2
Time-series moving average question
My guess would be that if you inspect the output from ma(dat3[1:28], order=3) you will find some NAs in it. And then forecast() doesn't like NAs. But I can't check, because I can't find the ma() and forecast() functions. I assume they come from some package you installed; it would be helpful to say which package. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000
2017 Dec 15
1
something weird has happened....!!!!!!!!!!
You could try this and see what you get: unique( yguii(ZEEL.NS, "o") - yguii(ZEEL.NS, "o") ) or maybe table( yguii(ZEEL.NS, "o") - yguii(ZEEL.NS, "o") ) You showed two sets of output from the expression yguii(ZEEL.NS, "o") Were they done one right after the other? Or could ZEEL.NS have changed in between? The function could be
2018 Apr 30
0
How to visualise what code is processed within a for loop
Thank you for both replies Don & Rui, The very issue here is that there is a search that needs to be done within a text field and I agree with Rui later comment that regexpr might indeed be the time consuming piece of code. I might try to optimise this piece of code later on, but for the time being I am working on the following part of building a neural network to try indeed classifying some
2018 Jan 26
2
Help in Plotting in "fArma" Package
What Dave said, plus here's a hint. Try this example (which uses base graphics): plot(1:5) plot(1:5, cex.lab=2) Then look at the help page for par help('par') or ?par to search for other graphics parameters (base graphics) you can use to change various things. Success will depend, as Dave indicated, on how the package author handled the plotting options in rsFit(). -Don --
2018 Apr 30
3
How to visualise what code is processed within a for loop
Luca, If speed is important, you might improve performance by making d0 into a true matrix, rather than a data frame (assuming d0 is indeed a data frame at this point). Although data frames may look like matrices, they aren?t, and they have some overhead that matrices don?t. I don?t think you would be able to use the [[nm]] syntax with a matrix, but [ , nm] should work, provided the matrix has
2013 Mar 04
3
What package can I use to help me categorize comment responses?
Hi, We have comment questions from a survey that we need to categorize. What package and functions can I use in R to help do this? Daniel Lopez Lawrence Livermore Labs SHRM [[alternative HTML version deleted]]
2018 Jan 26
0
Help in Plotting in "fArma" Package
> On Jan 26, 2018, at 9:51 AM, MacQueen, Don <macqueen1 at llnl.gov> wrote: > > What Dave said, plus here's a hint. Try this example (which uses base graphics): > > plot(1:5) > plot(1:5, cex.lab=2) > > Then look at the help page for par > help('par') > or > ?par > to search for other graphics parameters (base graphics) you can use to
2017 Dec 14
0
Errors in reading in txt files
In addition to which, I would recommend df <- read.table("DATAM", header = TRUE, fill = TRUE, stringsAsFactors=FALSE) and then converting the Time column to POSIXct date-time values using as.POSIXct() specifying the format using formatting codes found in ?strptime because the times are not in the POSIXct default format. This example might indicate the idea: >
2017 Dec 15
2
Errors in reading in txt files
I use the method, df$Time = as.POSIXct(df$Time), but it has the warning message: Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format On Thu, Dec 14, 2017 at 1:31 PM, MacQueen, Don <macqueen1 at llnl.gov> wrote: > In addition to which, I would recommend > > df <- read.table("DATAM", header = TRUE, fill = TRUE, >
2018 Apr 25
0
How to visualise what code is processed within a for loop
Your code doesn't make sense to me in a couple of ways. Inside the loop, the first line assigns a value to an object named "t". Then, the second line does the same thing, assigns a value to an object named "t". The value of the object named "t" after the second line will be the output of the ifelse() expression, whatever that is. This has the effect of making
2018 Mar 29
0
Creating the right table from lapply list
Perhaps this toy example will help: ## example data output <- list(1:5, 1:7, 1:4) lens <- lapply(output, length) maxlen <- max(unlist(lens)) outputmod <- lapply(output, function(x, maxl) c(x, rep(NA, maxl-length(x))), maxl=maxlen) outputmat <- do.call(cbind, outputmod) write.csv(outputmat, na='') The idea is to pad the shorter vectors with NA (missing) before converting
2018 Apr 30
0
How to visualise what code is processed within a for loop
Hi Rui Thank you for your suggestion, I have tested the code suggested by you against that supplied by Don in terms of timing and results are very much aligned: to populate a 5954x899 0/1 matrix on my machine your procedure took 79 secs, while the one with ifelse employed 80 secs, hence unfortunately not really any significant time saved there. Nevertheless thank you for your contribution.
2018 Apr 28
2
How to visualise what code is processed within a for loop
Thanks Don, for (i in 1:10){ nm <- paste0("V", i) d0[[nm]] <- ifelse( regexpr(d1[i,1], d0$X0) > 0, 1, 0) } is exaclty what I needed. Best regards, Luca 2018-04-25 23:03 GMT+02:00 MacQueen, Don <macqueen1 at llnl.gov>: > Your code doesn't make sense to me in a couple of ways. > > Inside the loop, the first line assigns a value to an
2018 Apr 28
2
How to visualise what code is processed within a for loop
I forgot to explain why my suggestion. The logical condition returns FALSE/TRUE that in R are coded as 0/1. So all you have to do is coerce to integer. This works because the ifelse will return a 1 or a 0 depending on the condition. Meaning exactly the same values. And is more efficient since ifelse creates both vectors, the true part and the false part, and then indexes those vectors in