Re: [R] Cleaning data

2017-09-26 Thread Jim Lemon
Hi Bayan, Your question seems to imply that the "age" column contains floating point numbers, e.g. df height weight age 170 72 21.5 ... If this is so, you will only find an integer in diff(age) if two adjacent numbers happen to have the same decimal fraction _and_ the subtraction

[R] Adding non-data line to legend ggplot2 Maximum Contaminant Level

2017-09-26 Thread David Doyle
Hello everyone, I have a plot showing chloride concentrations for various point over time. I also have a dotted line that show the Secondary Maximum Contaminant Level (my screening limit) on the graphs at 250 mg/L. But I can not figure out how to include the dotted line / Secondary Maximum

[R] Any package which takes the likelihood function and do Lasso fitting?

2017-09-26 Thread Jixian (Jason) Wang
Dear all, I am looking for a package that takes the likelihood function and use the L1 penalty for MLE. More specifically I would like to fit the Hawke process model using the function likelihoodHawkes() in package "hawkes" https://cran.r-project.org/web/packages/hawkes/hawkes.pdf. Had a

Re: [R] bowed linear approximations

2017-09-26 Thread Evans, Richard K. (GRC-H000)
[solved] -- As always, the solution is simple and I always feel foolish for not having seen it right away. Thank you, John, for showing that the frequency data can be "converted" to log before the linear approximations are made.. once the linear approximations are done with log data, the

Re: [R] bowed linear approximations

2017-09-26 Thread Fox, John
Dear Rich, I think that it's generally a bad idea to give statistical (as opposed to simply technical) advice by email without knowing the context of the research. I think that you'd do well to seek help from a statistician, and not just do what I suggest below. Interpolating the data only

Re: [R] bowed linear approximations

2017-09-26 Thread Evans, Richard K. (GRC-H000)
My apologies for the typos in the code. Here is a corrected version you can copy/paste in R to see the issue. freq <- c(2, 3, 5, 10, 50, 100, 200, 300, 500, 750, 1000, 1300, 1800, 2450, 2900, 3000, 4000, 5000, 6000, 7000, 8200, 9300, 1, 11000, 18000, 26500, 33000, 4); mag <-

Re: [R] bowed linear approximations

2017-09-26 Thread Evans, Richard K. (GRC-H000)
Eric, John, thank you both very much for responding. Ok.. I suppose I need to show more of the actual data. I have this data: freq <- c(2, 3, 5, 10, 50, 100, 200, 300, 500, 750, 1000, 1300, 1800, 2450, 2900, 3000, 4000, 5000, 6000, 7000, 8200, 9300, 1, 11000, 18000, 26500, 33000, 4)

[R] censtats from the NADA package

2017-09-26 Thread Shane Carey
Hi, Has anyone ever used the censtats from the nada package and carried it out per group on a dataframe? I have it working on the entire dataframe but I need to do it by group. Thanks -- Le gach dea ghui, *Shane Carey* *GIS and Data Solutions Consultant* [[alternative HTML version

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

[R] Cleaning data

2017-09-26 Thread bayan sardini
Hi I want to clean my data frame, based on the age column, whereas i want to delete the rows that the difference between its elements (i+1)-i= integer. i used a <- diff(df$age) for(i in a){if(is.integer(a) == true){df <- df[-a,] }} but, it doesn’t work, any ideas Thanks in advance Bayan

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

2017-09-26 Thread Ashraf Afana via R-help
Hi Eric, Thanks for the help.But this will not solve the problem as it will generate a list and what I need is an object of class sp using SpatialLine function from sp package.So, I need to convert each matrix to coordinates and then to a line and then to a spatial line as figured in the code.

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

2017-09-26 Thread Eric Berger
Hi Ashraf, In that case I think you may need to structure the code to first build the list and only at the end supply that to the SpatialLines function, something like test.func <- function(x) { tt <- list() for ( i in ... ) { ... tt[[i]] <- (whatever) }

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

2017-09-26 Thread Chris Evans
Quite so. Very sorry everyone. I realised that I meant "useNA="always"" not "na.rm=TRUE" within minutes of sending that Email ... by which time I was travelling and no longer had internet to beat you to this Eric. Clear evidence that I should never touch the keyboard without the first coffee

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

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,

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

2017-09-26 Thread Chris Evans
I am hitting an odd message "Error in FUN(newX[, i], ...) : all arguments must have the same length". I can't supply the data as it's a huge data frame but I think this has enough diagnostic information to show the issue. I am sure I am missing something obvious. I've put some extra comments