[R] Returning Visibly / / Invisibly from C Function

2022-09-16 Thread Andrew Simmons
Hello, I'm working on a function envvars() which I'd like to get, set, and remove environment variables in a manner similar to options(). At the R level, I have this function: envvars <- function (...) .External2(C_envvars, pairlist(...)) and then at the C level: #define set_R_Visible(X) (eval

Re: [R] rename files in R

2022-09-16 Thread Rui Barradas
Hello, My understanding of the problem is different, the files' first row is not tabular data, I might be wrong but it seems to me that it's something like first row [of] file1.txt [is]: abc.txt file2.txt: bed.txt etc. That's why the sapply loop reads one datum only and exits. Hope this h

Re: [R] nlme gls issue

2022-09-16 Thread Rolf Turner
On Fri, 16 Sep 2022 13:48:55 + Kayla Bazzana wrote: > Hi there, > > I'm having issues running a gls within the nlme package that neither > I nor any of my colleagues can figure out. The gls itself seems to > run fine (i.e. doesn't give an error message and produces a seemingly > normal sum

Re: [R] rename files in R

2022-09-16 Thread Kai Yang via R-help
Thank you. I'll try this. --- Kai On Friday, September 16, 2022 at 11:01:33 AM PDT, Rui Barradas wrote: Hello, Something like the following might work. filenames <- list.files(pattern = "^file\\d+\\.txt$") destnames <- sapply(filenames, scan, what = character(), sep = "\n", n = 1L,

[R] rename files in R

2022-09-16 Thread Kai Yang via R-help
Hello,I have a lot of files with not meaningful name, such as:  file1.txt, file2.txt .. I need to rename them using the information from the first row of the files. Now I can get the information from the first row of each file. Now, I need know how to rename them in R (using loop?). Thank yo