Displaying 20 results from an estimated 8000 matches similar to: "Problem with order() and I()"
2010 Jan 16
1
order() fails on a chr object of class "AsIs" with "\265" in it
Here's an example (session info at the end).
> tmpv <- c('\265g/L','Bq/L')
> order(tmpv)
[1] 2 1
> tmpv <- I(tmpv)
> order(tmpv)
Error in if (xi > xj) 1L else -1L : missing value where TRUE/FALSE needed
> foov <- gsub('\265','',tmpv)
> order(foov)
[1] 2 1
> str(tmpv)
Class 'AsIs' chr [1:2] "\265g/L"
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
2008 Oct 22
1
R 2.8.0 qqnorm produces error with object of class zoo?
Dear list-reader,
by running the following script:
library(zoo)
sessionInfo()
search()
packageDescription("zoo")
data(EuStockMarkets)
dax <- as.zoo(EuStockMarkets[1:10, "DAX"])
daxr <- diff(log(dax))
identical(as.vector(qnorm(daxr)), qnorm(coredata(daxr)))
qqnorm(coredata(daxr))
qqnorm(daxr)
qqnorm() produces an error:
> qqnorm(daxr)
Fehler in if (xi == xj) 0L
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 Sep 09
1
windowing
Is there a package or a command that does window aggregation like
select
sum(col1) over
(partition by col2, col3 order by col4
rows between unbounded preceding and current row) as sum1
from table1 ;
the above is Netezza syntax, but Postgre has same capability.
Stephen B
[[alternative HTML version deleted]]
2017 Jun 14
3
about fitting a regression line
Thanks. I thought lm() function is for linear model, such as the
correlation below:
Y= aX + b
On Wed, Jun 14, 2017 at 5:25 PM, MacQueen, Don <macqueen1 at llnl.gov> wrote:
> Start with the lm() function; i.e., see
>
> ?lm
>
> -Don
>
> --
> Don MacQueen
>
> Lawrence Livermore National Laboratory
> 7000 East Ave., L-627
> Livermore, CA 94550
>
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 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
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
2017 Jun 15
3
about fitting a regression line
Thanks for your replies. I tried the regression, but then got a NA value
for the slope. And here is the error message:
Coefficients: (1 not defined because of singularities)
On Thu, Jun 15, 2017 at 12:20 AM, PIKAL Petr <petr.pikal at precheza.cz> wrote:
> Hi
>
> But X can be some function like - sin, cos, log, exp...
>
> Cheers
> Petr
>
> > -----Original
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
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.
2004 May 24
1
as.matrix.data.frame() in R 1.9.0 converts to character when it should (?) convert to numeric
Conversion of a data frame to a matrix using as.matrix() when a
column of the data frame is POSIXt and all other columns are numeric
has changed in R 1.9.0 from R 1.8.1. The new behavior issues a
warning message and converts to a character matrix. In R 1.8.1, such
an object was converted to a numeric matrix.
Here is an example.
#### R 1.9.0 ####
> foo <- data.frame(
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
--
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,
>
2013 Jan 03
5
splitting matrices
Dear useRs,
i want to split a matrix having 1116rows and 12 columns. i want to split that matrix into 36 small matrices each having 12 columns and 31 rows. The big matrix should be splitted row wise. which means that the first small matrix should copy values which are in first 31 rows and 12 columns of the big matrix. similarly 2nd small matrix should contain values from 32nd to 63rd row of the
2017 Jul 13
2
Help with R script
Using Ulrik?s example data (and assuming I understand what is wanted), here is what I would do:
ex.dat <- c("FName: fname1", "Fval: Fval1.name1", "Fval: ", "FName: fname2", "Fval: Fval2.name2", "FName: fname3")
tst <- data.frame(x = ex.dat, stringsAsFactors=FALSE)
sp <- strsplit(tst$x, ':', fixed=TRUE)
chk <-
2018 May 11
1
add one variable to a data frame
Um, maybe just
dat1$C <- match(dat1$B, unique(dat1$B))
Indexing 1:k with numbers between 1 and k is a bit of a no-op...
AFAICT, this even works without stringsAsFactors=FALSE
-pd
> On 11 May 2018, at 21:30 , MacQueen, Don <macqueen1 at llnl.gov> wrote:
>
> dat1$C <- seq(length(unique(dat1$B)))[ match( dat1$B, unique(dat1$B) )]
--
Peter Dalgaard, Professor,
Center for
2017 Jun 14
0
about fitting a regression line
Start with the lm() function; i.e., see
?lm
-Don
--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
On 6/14/17, 3:40 PM, "R-help on behalf of lily li" <r-help-bounces at r-project.org on behalf of chocold12 at gmail.com> wrote:
Hi R users,
I have some data points (Xi, Yi), and they may follow such a