Re: [R] Problem with base::order

2024-04-10 Thread Ivan Krylov via R-help
В Wed, 10 Apr 2024 09:33:19 +0200 Sigbert Klinke пишет: > decreasing=c(F,F,F) This is only documented to work with method = 'radix': >> For the ‘"radix"’ method, this can be a vector of length equal to >> the number of arguments in ‘...’ and the elements are recycled as >> necessary. For the

Re: [R] Problem with base::order

2024-04-10 Thread Sigbert Klinke
Hi, you are unfortunately right. Executing x <- sample(c(1,2,NA), 26, replace=TRUE) y <- sample(c(1,2,NA), 26, replace=TRUE) o <- order(x, y, decreasing = c(T,F), na.last=c(F,T)) cbind(x[o], y[o]) shows that the second entry of na.last is ignored without warning. Thanks Sigbert Am 10.04.24

[R] Problem with base::order

2024-04-10 Thread Sigbert Klinke
Hi, when I execute order(letters, LETTERS, 1:26) then everything is fine. But if I execute order(letters, LETTERS, 1:26, na.last=c(T,T,T), decreasing=c(F,F,F)) I get the error message Error in method != "radix" && !is.na(na.last) : 'length = 3' in constraint to 'logical(1)' Shouldn't both

Re: [R] Exceptional slowness with read.csv

2024-04-10 Thread Rui Barradas
Às 06:47 de 08/04/2024, Dave Dixon escreveu: Greetings, I have a csv file of 76 fields and about 4 million records. I know that some of the records have errors - unmatched quotes, specifically. Reading the file with readLines and parsing the lines with read.csv(text = ...) is really slow. I

Re: [R] Exceptional slowness with read.csv

2024-04-10 Thread avi.e.gross
It sounds like the discussion is now on how to clean your data, with a twist. You want to clean it before you can properly read it in using standard methods. Some of those standard methods already do quite a bit as they parse the data such as looking ahead to determine the data type for a

Re: [R] Exceptional slowness with read.csv

2024-04-10 Thread Dave Dixon
That's basically what I did 1. Get text lines using readLines 2. use tryCatch to parse each line using read.csv(text=...) 3. in the catch, use gregexpr to find any quotes not adjacent to a comma (gregexpr("[^,]\"[^,]",...) 4. escape any quotes found by adding a second quote (using str_sub from

Re: [R] Exceptional slowness with read.csv

2024-04-10 Thread avi.e.gross
Dave, Your method works for you and seems to be a one-time fix of a corrupted data file so please accept what I write not as a criticism but explaining my alternate reasoning which I suspect may work faster in some situations. Here is my understanding of what you are doing: You have a file in

Re: [R] Question regarding reservoir volume and water level

2024-04-10 Thread javad bayat
Dear all; Thank you for your reply. David has explained an interesting method. David I have DEM file of the region and I have extracted the xyz data from that. Also I can extract bathymetry data as xyz file. I have calculated the storage (volume) of reservoir at the current elevation. But the