Re: [R] saveRDS() and readRDS() Why? [solved, kind of]

2018-11-07 Thread Patrick Connolly
Many thanks to Berwin, Eric, Robert, and Jan for their input. I had hoped it was as simple as because I typed saveRDS("rawData", file = "rawData.rds") on the Windows side. but that wasn't the case. Robert Burbridge suggested: windows (not run) f <- file("rawData.rds", open="w")

Re: [R] Identify row indices corresponding to each distinct row of a matrix

2018-11-07 Thread Jeff Newmiller
Perhaps which( ! duplicated( m, MARGIN=1 ) ) ? (untested) On November 7, 2018 9:20:57 PM PST, Bert Gunter wrote: >A mess -- due to your continued use of html formatting. > >But something like this may do what you want (hard to tell with the >mess): > >> m <- matrix(1:16,nrow=8)[rep(1:8,2),] >>

Re: [R] Identify row indices corresponding to each distinct row of a matrix

2018-11-07 Thread Bert Gunter
A mess -- due to your continued use of html formatting. But something like this may do what you want (hard to tell with the mess): > m <- matrix(1:16,nrow=8)[rep(1:8,2),] > m [,1] [,2] [1,]19 [2,]2 10 [3,]3 11 [4,]4 12 [5,]5 13 [6,]6 14 [7,]

[R] Identify row indices corresponding to each distinct row of a matrix

2018-11-07 Thread li li
Hi all, I use the following example to illustrate my question. As you can see, in matrix C some rows are repeated and I would like to find the indices of the rows corresponding to each of the distinct rows. For example, for the row c(1,9), I have used the "which" function to identify the row

[R-es] Fwd: FW: Apply now! 1-2 December | Barcelona

2018-11-07 Thread Marco Giannitrapani
Hola a Tod@s, Solo comentar a quien le pueda interesar que habrĂ¡ un Hackathon en Barcelona el 1 y 2 Diciembre! Saludos, Marco

Re: [R] Problem with the matrix() function.

2018-11-07 Thread David L Carlson
There are other functions where R handles a vector argument differently. The first value may be silently used, used with a warning, or trigger an error. > x <- 1:3 > x:9 [1] 1 2 3 4 5 6 7 8 9 Warning message: In x:9 : numerical expression has 3 elements: only the first used > seq(x, 9) Error in

Re: [R] Problem with the matrix() function.

2018-11-07 Thread Bert Gunter
I have no opinion on your queries, but whatever is done, it should be properly documented, which appears not to be the case presently afaics. -- Bert On Wed, Nov 7, 2018 at 12:33 PM Rolf Turner wrote: > > In the course of writing a bit of somewhat convoluted code I recently > made a silly

[R] Problem with the matrix() function.

2018-11-07 Thread Rolf Turner
In the course of writing a bit of somewhat convoluted code I recently made a silly error that revealed the following phenomenon: m <- matrix(1:10,nrow=2,ncol=c(5,4)) produces [,1] [,2] [,3] [,4] [,5] [1,]13579 [2,]2468 10 That is, the nonsense

Re: [R] Optimization with Parallel Processing Functions/Packages

2018-11-07 Thread Jeff Newmiller
This is highly problem dependent... and you appear to already know the answer. Note that some differential evolution solution approaches may benefit from parallelizing evaluation of generations since within that sub-problem the optimization dependencies don't apply. A theoretical discussion

[R] Optimization with Parallel Processing Functions/Packages

2018-11-07 Thread Doran, Harold
More of a general query, but looking to see if others have successfully used something like the foreach package (or other parallel style functions) with certain functions that minimize likelihood or objective functions (e.g., optim/nlminb). I have had great success with embarrassingly parallel

Re: [R] saveRDS() and readRDS() Why?

2018-11-07 Thread Robert David Burbidge via R-help
Patrick, I cannot reproduce this behaviour. I'm using: Windows 8.1; R 3.5.1; RStudio 1.1.463 running in a VirtualBox on Ubuntu 18.04 with R 3.4.4; RStudio 1.1.456 The file size of rawData.rds is always 88 bytes in my example and od gives the same results on Windows and Linux. I am using a

Re: [R] saveRDS() and readRDS() Why?

2018-11-07 Thread Jan van der Laan
Are you sure you didn't do saveRDS("rawData", file = "rawData.rds") instead of saveRDS(rawData, file = "rawData.rds") ? This would explain the result you have under linux. In principle saveRDS and readRDS can be used to copy objects between R-sessions without loosing information. What

Re: [R] saveRDS() and readRDS() Why?

2018-11-07 Thread Robert David Burbidge via R-help
If the file sizes are the same, then presumably both contain the binary data. From the serialize function help: "As almost all systems in current use are little-endian, xdr = FALSE can be used to avoid byte-shuffling at both ends when transferring data from one little-endian machine to

Re: [R] saveRDS() and readRDS() Why?

2018-11-07 Thread Eric Berger
Your understanding is correct. It works fine for me. On Wed, Nov 7, 2018 at 10:48 AM Patrick Connolly wrote: > On Wed, 07-Nov-2018 at 08:27AM +, Robert David Burbidge wrote: > > |> Hi Patrick, > |> > |> From the help: "save writes a single line header (typically > |> "RDXs\n") before the

Re: [R] saveRDS() and readRDS() Why?

2018-11-07 Thread Patrick Connolly
On Wed, 07-Nov-2018 at 08:27AM +, Robert David Burbidge wrote: |> Hi Patrick, |> |> From the help: "save writes a single line header (typically |> "RDXs\n") before the serialization of a single object". |> |> If the file sizes are the same (see Eric's message), then the |> problem may be

Re: [R] saveRDS() and readRDS() Why?

2018-11-07 Thread Patrick Connolly
They're both about 3kb. On 7/11/18 9:13 PM, Eric Berger wrote: > What do you see at the OS level? > i.e. on windows > DIR rawData.rds > on linux > ls -l rawData.rds > compare the file sizes on both. > > > On Wed, Nov 7, 2018 at 9:56 AM Patrick Connolly > mailto:p_conno...@slingshot.co.nz>>

Re: [R] saveRDS() and readRDS() Why?

2018-11-07 Thread Robert David Burbidge via R-help
Hi Patrick, From the help: "save writes a single line header (typically "RDXs\n") before the serialization of a single object". If the file sizes are the same (see Eric's message), then the problem may be due to different line terminators. Try serialize and unserialize for low-level control

Re: [R] saveRDS() and readRDS() Why?

2018-11-07 Thread Eric Berger
What do you see at the OS level? i.e. on windows DIR rawData.rds on linux ls -l rawData.rds compare the file sizes on both. On Wed, Nov 7, 2018 at 9:56 AM Patrick Connolly wrote: > From a Windows R session, I do > > > object.size(rawData) > 31736 bytes # from scraping a non-reproducible web