Re: [R] converting MATLAB -> R | element-wise operation

2024-02-28 Thread Richard O'Keefe
The first vector-oriented programming language I ever learned or used was APL, and APL makes *no* distinction between row vectors and column vectors. It has rank-0 (scalar), rank-1 (vector), rank-2 (matrix), rank-3 ... and so on arrays. A rank-1 array is a rank-1 array is a rank-1 array and

Re: [R] converting MATLAB -> R | element-wise operation

2024-02-28 Thread peter dalgaard
Agree that sweep is the tool here. (If you think it is clunky, check how more general array-sweep operations can be done in Matlab.) However, it isn't really true that sweep isn't moving things around. Notice the call to aperm() at the end of the code for sweep(): perm <- c(MARGIN,

Re: [R] Trouble reading a UTF-16LE file

2024-02-28 Thread Ebert,Timothy Aaron
Yea, that worked. Thank you. :) From: jim holtman Sent: Wednesday, February 28, 2024 12:52 PM To: Ebert,Timothy Aaron Cc: r-help@r-project.org Subject: Re: [R] Trouble reading a UTF-16LE file [External Email] Try this: > x <- file("C:\\Users\\Jim\\Downloads\\PV2-ch2 - R_Help.ANA", +

Re: [R] Trouble reading a UTF-16LE file

2024-02-28 Thread jim holtman
Try this: > x <- file("C:\\Users\\Jim\\Downloads\\PV2-ch2 - R_Help.ANA",+ > encoding = "UTF-16")> y <- readLines(x)> head(y)[1] "1\t36,74\t0" > "2\t269,02\t-44" "1\t326,62\t29""2\t354,52\t24" [5] "8\t390,75\t1838" "2\t395,11\t-1053"> > Thanks Jim Holtman *Data Munger

[R] Trouble reading a UTF-16LE file

2024-02-28 Thread Ebert,Timothy Aaron
The earlier post had an attached text file that did not go through. I hope this link works. I tested it with a coworker, but that is no guarantee. https://uflorida-my.sharepoint.com/:u:/g/personal/tebert_ufl_edu/EXf5u_CtTwJCrhdfTBIPr7wBefZHx4P_suj4wAWb8i8HFA?e=iQawhh Regards, Tim

[R] Trouble reading a UTF-16LE file

2024-02-28 Thread Ebert,Timothy Aaron
Dear R-help, I am having trouble reading a UTF-16LE formatted file. The issue appears to be a byte order mark at the beginning of the file. I have tried readLines(file, encoding='utf-16LE') but that got me [1]"\xff\xfe1" "" "" "" "" "" This is a tab delimited text

Re: [R] Trouble reading a UTF-16LE file

2024-02-28 Thread Jeff Newmiller via R-help
When you specify LE you are overriding any useful information that the BOM could convey... see https://softwareengineering.stackexchange.com/questions/370088/is-the-bom-optional-for-utf-16-and-utf-32. ?Encoding On February 28, 2024 5:44:49 AM PST, "Ebert,Timothy Aaron" wrote: >Dear R-help, >

Re: [R] Trouble reading a UTF-16LE file

2024-02-28 Thread Ivan Krylov via R-help
В Wed, 28 Feb 2024 13:44:49 + "Ebert,Timothy Aaron" пишет: > readLines(file, encoding='utf-16LE') There are two ways you could encounter an encoding in R. First are encoding markers placed on every string object, which declare the string to be encoded in UTF-8, Latin-1, the native locale

Re: [R] [External] converting MATLAB -> R | element-wise operation

2024-02-28 Thread Evan Cooch
Many thanks for the collective answers -- consider this a thank you to the group. I had 'guessed' it had something to do with 'columns then rows' or vice versa (MATLAB convention vs R convention), but had never heard about 'sweep' before. Most of the time when I run into 'matrix orientation'

[R] Trouble reading a UTF-16LE file

2024-02-28 Thread Ebert,Timothy Aaron
Dear R-help, I am having trouble reading a UTF-16LE formatted file. The issue appears to be a byte order mark at the beginning of the file. I have tried readLines(file, encoding='utf-16LE') but got me [1]"\xff\xfe1" "" "" "" "" "" Regards, Tim

Re: [R] [EXT] Initializing vector and matrices

2024-02-28 Thread Eik Vettorazzi
Hi Steven, It's not entirely clear what you actually want to achieve in the end. As soon as you "know" x1, and assuming that the different "xi" do not differ in length in the real application, you know the length of the target vector. Instead of the loop, you can use 'Reduce' without having to

Re: [R] converting MATLAB -> R | element-wise operation

2024-02-28 Thread Berwin A Turlach
On Tue, 27 Feb 2024 14:54:26 -0500 Evan Cooch wrote: > So, trying to convert a very long, somewhat technical bit of lin alg > MATLAB code to R. Most of it working, but raninto a stumbling block > that is probaably simple enough for someone to explain. On

Re: [R] converting MATLAB -> R | element-wise operation

2024-02-28 Thread Berwin A Turlach
On Tue, 27 Feb 2024 13:51:25 -0800 Jeff Newmiller via R-help wrote: > The fundamental data type in Matlab is a matrix... they don't have > vectors, they have Nx1 matrices and 1xM matrices. Also known as column vectors and row vectors. :) > Vectors don't have any concept of "row" vs.

Re: [R] Initializing vector and matrices

2024-02-28 Thread Steven Yen
OK. I initialize real large vector and matrix and then shrink them when I use them in the loop. The following lines worked. I'd glad to know of better approaches. bsum<-rep(0,1000); bsum vsum<-matrix(rep(0,100),nrow=1000); vsum for (ind in 1:3) { mydata <- read.csv(paste0("midata", ind,

Re: [R] [External] converting MATLAB -> R | element-wise operation

2024-02-28 Thread Berwin A Turlach
On Tue, 27 Feb 2024 21:37:52 + "Richard M. Heiberger" wrote: > > t(t(NN)/lambda) > [,1] [,2] [,3] > [1,] 0.5 0.667 0.75 > [2,] 2.0 1.667 1.50 > > > > R matrices are column-based. MATLAB matrices are row-based. It might depend on what you mean with this statement,

[R] Initializing vector and matrices

2024-02-28 Thread Steven Yen
Is there as way to initialize a vector (matrix) with an unknown length (dimension)? NULL does not seem to work. The lines below work with a vector of length 4 and a matrix of 4 x 4. What if I do not know initially the length/dimension of the vector/matrix? All I want is to add up (accumulate) 

Re: [R] Clustering Functions used by Reverse-Dependencies

2024-02-28 Thread Ivan Krylov via R-help
В Sat, 24 Feb 2024 03:08:26 + Leo Mada via R-help пишет: > Are there any tools to extract the function names called by > reverse-dependencies? For well-behaved packages that declare their dependencies correctly, parsing the NAMESPACE for importFrom() and import() calls should give you the