file names in some folder, and save to a new folder.
Tim
-Original Message-
From: R-help On Behalf Of Kai Yang via R-help
Sent: Friday, September 16, 2022 1:52 PM
To: R-help Mailing List ; Rui Barradas
Subject: Re: [R] rename files in R
[External Email]
Hello,Here is the ex
qual to that.
>
> Do a for loop using current file names in some folder, and save to a new
> folder.
>
> Tim
>
> -Original Message-
> From: R-help On Behalf Of Kai Yang via R-help
> Sent: Friday, September 16, 2022 1:52 PM
> To: R-help Mailing List ; Rui B
are in the first row, selecting the first element from
> colnames() and setting the file name equal to that.
> >
> > Do a for loop using current file names in some folder, and save to a new
> folder.
> >
> > Tim
> >
> > -Original Message-
> > Fr
-Original Message-
> From: R-help On Behalf Of Kai Yang via R-help
> Sent: Friday, September 16, 2022 1:52 PM
> To: R-help Mailing List ; Rui Barradas
>
> Subject: Re: [R] rename files in R
>
> [External Email]
>
> Hello,Here is the example:
> file name
s
Subject: Re: [R] rename files in R
[External Email]
Hello,Here is the example:
file namefirst row file1.txt abc.txt file2.txt bed.txt
file3.txt gogo.txt . . file1243.txtlast.txt
I want to use loop because I need to read the first row information for first file,
and
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,
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
>Also, I checked my options and I have my email set to plain text...
The warning inserted by the mailing list at the bottom of your message below
> [[alternative HTML version deleted]]
indicates that you may still need to understand your mail client better.
On October 6, 2021 10:30:49 AM
Hello,
Thank you for your help, I really appreciate it, I was able to solve the
problem!
Here is a part of my dataframe (just in case...):
> dput( head( behavioral_df) )
structure(list(ID = c(1, 2, 3, 4, 5, 6), DOB = c("9/53/1959",
"4/8/1953", "2/21/1961", "10/11/1948", "9/4/1962", "8/22/1953"
Hi Anne,
As mentioned above, you may have to do nothing. Here is an example
that might clarify that:
azdat<-read.table(text="subject 1 2 3
1 10 20 30
2 11 22 33",
header=TRUE,stringsAsFactors=FALSE)
azdat
subject X1 X2 X3
1 1 10 20 30
2 2 11 22 33
As you can see, R simply prepends an
... and to add to what Eric and Duncan have said, what you have as column
names depends on how the data were imported. e.g.:
> d1 <-data.frame(a = 1:3, `1b` = letters[1:3]) ## check.names has a
default of TRUE
> names(d1)
[1] "a" "X1b" ## note the conversion to a syntactically valid name. See
On 04/10/2021 2:02 p.m., Anne Zach wrote:
Dear R users,
I have a dataframe that contains several variables, among which 105
correspond to scores on certain trials. Unfortunately, when I imported this
dataframe into R, I realised that the variable names corresponding to each
trial begin with digi
Hi Anne,
It would be helpful to include at least part of behavioral_df for people to
understand the issue better.
Please do the following in R and post the output.
dput( head( behavioral_df) )
Also, set your email to plain text as HTML is stripped from emails on this
list.
Best,
Eric
On Tue,
Hello,
I think you have to use 'matches' instead of 'starts_with', I believe
starts_with does not accept a regular expression whereas matches does.
On Tue, Oct 5, 2021 at 12:15 PM Anne Zach wrote:
> Dear R users,
>
> I have a dataframe that contains several variables, among which 105
> corresp
Dear R users,
I have a dataframe that contains several variables, among which 105
correspond to scores on certain trials. Unfortunately, when I imported this
dataframe into R, I realised that the variable names corresponding to each
trial begin with digits, which violates R naming conventions.
I
Hi John,
After a bit of thinking:
# fill in the appropriate path and pattern
filenames<-list.files(path=???,pattern=???)
for(filename in filenames) {
filefirst<-sapply(strsplit(filename,"[.]"),"[",1)
# delete all non-digits
fileno<-gsub("[^[:digit:]]","",filefirst)
file.rename(filename,paste("
The combination of list.files(), gsub() and file.rename() should to the
trick.
ir. Thierry Onkelinx
Statisticus/ Statistician
Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
FOREST
Team Biometrie & Kwaliteitszorg / Team Biometr
> On 28 Sep 2017, at 12:57 , Eric Berger wrote:
>
> Hi John,
> Thanks to Jim for pointing out the file.rename() function. You can try this:
>
> # define the filename templates
> strIn <- "XYZW--Genesis_ABC.mp3"
> strOut <- "01Gen--.mp3"
>
> # create the strings "01", "02", ..., "50"
> v <- sa
Hi John,
Thanks to Jim for pointing out the file.rename() function. You can try this:
# define the filename templates
strIn <- "XYZW--Genesis_ABC.mp3"
strOut <- "01Gen--.mp3"
# create the strings "01", "02", ..., "50"
v <- sapply(1:50, function(i) sprintf("%02d",i) )
# perform all the file rena
Hi John,
Maybe this:
filenames<-c("XYZW01Genesis_ABC.mp3","XYZW02Genesis_ABC.mp3")
for(filename in filenames) {
filefirst<-sapply(strsplit(filename,"[.]"),"[",1)
fileno<-sub("_","",gsub("[[:alpha:]]","",filefirst))
file.rename(filename,paste("01Gen",fileno,".mp3",sep=""))
}
Jim
On Thu, Sep 28
Hi John,
I don't know how to do this with R, but on Linux I'd use rename (or maybe
even by hand if it's a one time event). On Windows I believe there is a
tool called Bulk Rename.
HTH
Ulrik
On Thu, 28 Sep 2017 at 11:37 John wrote:
> Hi,
>
>I have 50 files whose names are
>
> XYZW01Genesis_
Hi,
I have 50 files whose names are
XYZW01Genesis_ABC.mp3
XYZW02Genesis_ABC.mp3
...
XYZW50Genesis_ABC.mp3
As you can tell, the only difference across the files are 01, 02,
03,50.
I would like to rename them to
01Gen01.mp3
01Gen02.mp3
...
01Gen50.mp3
If I store them in on
Thanks Sven,
I started with the first function.
The values are not in a list but in df. it is more easy for me
the output is a df:
Genesbrca_tcga gbm_tcga color_brca color_gbm
name1 v1v2col1 col2
name2 v3v4
Hi Karim,
you should learn ?Map to iterate along the list and supply mutliple list
arguments (there is also parallel:::mcMap for multicore).
The magic of the color code generation you figure out yourself, I guess...
Here 'i' intends to be the value, 'n' the name, e.g.
# returns color by charact
Hi all,
I have a list like this
expBefore <-
list(HM450=list(brac_tcga=list("ATM"=0.19,"ATR"=0.02,"BRCA1"=0.02,"BRCA2"=0.89,"CHEK1"=0.71,"CHEK2"=0.03),
gbm_tcga=list("ATM"=0.19,"ATR"=0.02,"BRCA1"=0.02,"BRCA2"=0.89,"CHEK1"=0.71,"CHEK2"=0.03)
),
HM27=list(brac_tcga=list("ATM"=0.19,
Dear Raj,
names(dff)[1:6] <- paste("bp",1:6,sep="_")
Alain
On 2015-01-12 15:17, Kuma Raj wrote:
> I want to rename columns 1 to 6 in the sample data set as bp_1 to
> bp_6. How could I do that in R?
>
> Thanks
>
>> dput(dff)
> structure(list(one = c(1.00027378507871, 0.982313483915127, 1.153127
Read the help page for the names function:
?names
... note particularly the examples section.
You might also find the fact that the paste0 function works on vectors to be
helpful:
paste0( "bp_", 1:6 )
---
Jeff Newmiller
Hi!
Nice example!
You just need to learn about the functions names() and paste():
names(dff)[1:6] <- paste("bp", 1:6, sep="_")
HTH,
Ivan
--
Ivan Calandra, ATER
University of Reims Champagne-Ardenne
GEGENAA - EA 3795
CREA - 2 esplanade Roland Garros
51100 Reims, France
+33(0)3 26 77 36 89
ivan.
I want to rename columns 1 to 6 in the sample data set as bp_1 to
bp_6. How could I do that in R?
Thanks
> dput(dff)
structure(list(one = c(1.00027378507871, 0.982313483915127, 1.1531279945243,
1.07400410677618, 1.22710472279261, 1.19762271047046, 1.10904859685147,
1.32060232717317), two = c(1.0
Your question is not clear to me. Do you wish to start numbers from 200
using 'formatC()'?
> formatC(seq(from=200, to=1200, by=500), width=5, flag="0")
[1] "00200" "00700" "01200"
You can do the same job using function 'sprintf()' as shown in the below:
> sprintf("%05d", seq(from=200, to=1200
You could read the help file:
?formatC
which says that flag modifies how the numbers are formatted... it does not
affect what numbers are used.. that is given by the "x" argument (typically
the first item in the argument list to formatC). In your case I think that came
from a call to the seq
Hi Chel,
I got it right.
Many thanks.
file.rename(file_names, to=paste0("rcp45_Daily_Sim", 200:210))
list.files(pattern="rcp45_Daily_Sim")
[1] "rcp45_Daily_Sim200" "rcp45_Daily_Sim201" "rcp45_Daily_Sim202"
On Friday, December 5, 2014 9:35 AM, Zilefac Elvis
wrote:
Hi Chel,
How can I modify th
Hi Chel,
How can I modify the script such that the numbering starts from 200,... instead
of 001?
flag="0" does not accept anything other than 0.
Thanks,
Asong.
On Thursday, December 4, 2014 11:17 PM, Chel Hee Lee
wrote:
I see that a function 'format()' is used in your code.
> format(c(1,5,32
I see that a function 'format()' is used in your code.
> format(c(1,5,32,100), width=3, flag="0")
[1] " 1" " 5" " 32" "100"
> formatC(c(1,5,32,100), width=3, flag="0")
[1] "001" "005" "032" "100"
I hope this helps.
Chel Hee Lee
On 12/04/2014 10:54 PM, Zilefac Elvis wrote:
Hi Chel,
Thanks
Hi Chel,
Thanks for the timely reply.
It works but a minor problem remains.
Here is the modified version of your code:
file_names<- list.files(pattern="Sim1971-2000_Daily_")
new_names <- paste("rcp45_Daily_Sim",format(seq(length(file_names)), width=3,
flag="00"), ".dat", sep="")
#files <- pas
I put five data files (example1.dat, example2.dat, example3.dat,
example4.dat, example5.dat, example6.dat) in my working directory.
>
> file_names <- list.files(pattern="*.dat")
> file_names
[1] "example1.dat" "example2.dat" "example3.dat" "example4.dat"
"example5.dat"
[6] "example6.dat"
>
> n
Hello,
I would like to rename multiple files in a directory. Filenames are read using:
lfile <- list.files(pattern="rcp45_Daily_")
files <- paste(paste(getwd(),lfile,sep="/"), list.files(lfile),sep="/")# getwd
of these files
dput(lfile)
c("rcp45_Daily_Sim001.dat", "rcp45_Daily_Sim002.dat")
On Sat, Jun 15, 2013 at 1:45 AM, David Winsemius wrote:
>
> On Jun 14, 2013, at 1:25 PM, Bert Gunter wrote:
>
>> For the record:
>>
>> ...
>>
>>
>>>
>>> A bit of commentary: Something did happen. It's just that you didn't do
>>> anything with _what_ happened. The copy of the 'dataset
On Jun 14, 2013, at 1:25 PM, Bert Gunter wrote:
> For the record:
>
> ...
>
>
>>
>> A bit of commentary: Something did happen. It's just that you didn't do
>> anything with _what_ happened. The copy of the 'dataset'-object got modified
>> but you never returned it from the funct
For the record:
...
>
> A bit of commentary: Something did happen. It's just that you didn't do
> anything with _what_ happened. The copy of the 'dataset'-object got modified
> but you never returned it from the function, and and also didn't reassign it
> to the original 'dataset'
On Jun 14, 2013, at 6:34 AM, Arman Eshaghi wrote:
> Dear all,
>
> I have different data frames for which I would like to modify names of each
> column such that the new name would include the name of the first column
> added to the name of other columns; I came up with the following code.
> Noth
Thanks all!
On Fri, Jun 14, 2013 at 6:40 PM, Rainer Schuermann <
rainer.schuerm...@gmx.net> wrote:
> df1 <- data.frame( A = runif( 10 ), B = runif( 10 ) * 5, C = runif( 10 ) *
> 10, D = runif( 10 ) * 20 )
> df2 <- data.frame( X = runif( 10 ), Y = runif( 10 ) * 5, Z = runif( 10 ) *
> 10 )
> renam
df1 <- data.frame( A = runif( 10 ), B = runif( 10 ) * 5, C = runif( 10 ) * 10,
D = runif( 10 ) * 20 )
df2 <- data.frame( X = runif( 10 ), Y = runif( 10 ) * 5, Z = runif( 10 ) * 10 )
rename_columns <- function( dataset )
{
for( i in 2:ncol( dataset ) )
colnames( dataset )[i]
CT
> ",sep="",header=TRUE,stringsAsFactors=FALSE)
>
>
> rename_columns(dat1)
> # chr chr_pos chr_ref chr_alt
> #1 chr1 5 A G
> #2 chr1 8 T C
> #3 chr2 2 C T
> A.K.
>
>
>
> ----- Origin
uot;",header=TRUE,stringsAsFactors=FALSE)
rename_columns(dat1)
# chr chr_pos chr_ref chr_alt
#1 chr1 5 A G
#2 chr1 8 T C
#3 chr2 2 C T
A.K.
- Original Message -
From: Arman Eshaghi
To: r-help@r-project.org
Cc:
Sent: Friday, Ju
Dear all,
I have different data frames for which I would like to modify names of each
column such that the new name would include the name of the first column
added to the name of other columns; I came up with the following code.
Nothing changes when I run the following code. I would be grateful i
I do not think it is possible with the 'R CMD Sweave' interface, but
you can always use the 'R -e' approach, e.g. R -e 'Sweave("foo.Rnw");
file.rename("foo.tex", "foo-bar.tex"); tools::texi2dvi('foo-bar.tex')'
(not tested, but idea is there)
To make this more natural, you can try the knitr package
HI,
I am working on R and Latex.
R CMD Sweave Test.Rnw (this generates Rnw.Tex file )
R CMD pdflatex Test.tex (It generated Test.pdf)
Is there any way to change the name of of output file (Test.pdf). I want it
to pass the output file name as parameter.
R CMD Sweave Test.Rnw Output_File
On 05/22/2012 06:08 PM, HAOLONG HOU wrote:
Dear list,
The name of R-language is too short and is not friendly to search engines.
Do you think it can be renamed to something like "Rsio" or "Radio" ?
Thank you so much for this useful software!
Aw, come on guys, here is somebody praising R and try
On 12-05-22 4:08 AM, HAOLONG HOU wrote:
Dear list,
The name of R-language is too short and is not friendly to search engines.
Do you think it can be renamed to something like "Rsio" or "Radio" ?
Thank you so much for this useful software!
You use gmail, so I assume you're familiar with Google.
Hi
>
> On May 22, 2012, at 4:08 AM, HAOLONG HOU wrote:
>
> > Dear list,
> >
> > The name of R-language is too short and is not friendly to search
> > engines.
Did you try it? Even with plain Google
something R will usually lead to quite good hit. Try e.g.
linear model R
Regards
Petr
> > Do
No. There are search tools that work. The RSiteSearch() function and the
rseek.org website are two such options.
---
Jeff NewmillerThe . . Go Live...
DCN:Basics: ##.#. #
On May 22, 2012, at 4:08 AM, HAOLONG HOU wrote:
Dear list,
The name of R-language is too short and is not friendly to search
engines.
Do you think it can be renamed to something like "Rsio" or "Radio" ?
Thank you so much for this useful software!
The notion of renaming R to 'radio' seems
Dear list,
The name of R-language is too short and is not friendly to search engines.
Do you think it can be renamed to something like "Rsio" or "Radio" ?
Thank you so much for this useful software!
Best wishes.
[[alternative HTML version deleted]]
__
Thanks Jim,
I didn't think it worked on directories but I've got it working now.
Cheers,
Gavin.
-Original Message-
From: jim holtman [mailto:jholt...@gmail.com]
Sent: 08 November 2011 14:18
To: Gavin Blackburn
Cc: r-help@r-project.org
Subject: Re: [R] Rename a directory in
apropos('rename')
you will find 'file.rename' which also works on directories.
On Tue, Nov 8, 2011 at 7:45 AM, Gavin Blackburn
wrote:
> Hi,
>
> I want to be able to rename a folder using R, similar to file.rename. I want
> to paste " - done" onto the folder name. The reason for this is we run a
Hi,
I want to be able to rename a folder using R, similar to file.rename. I want to
paste " - done" onto the folder name. The reason for this is we run a loop on a
large number of folders on a server and it would be nice for people to be able
to log in and instantly see if their data has been p
this isn't a whole lot different, but if x is a data.frame (and not a
matrix), you could also try this:
names(x)[which(names(x)=="oldname")]= "newname"
--
View this message in context:
http://r.789695.n4.nabble.com/Rename-column-or-row-names-tp2288122p2288183.html
Sent from the R help mailing
Hello All,
Suppose that x is a data.frame. I want to change the colname 'oldname'
to 'newname'. I have the following code. Could anybody let me know if
there is any better way to change a column name?
colnames(x)[grep('oldname', colnames(x))]='newname'
--
Tom
__
wenjun zheng wrote:
Hi, R Users,
Can maintainer rename the package on F-Forge?
Any suggestions will be appreciated.
use svn mv
if your directory structure is
pkg/
pkg/R/
pkg/man/
pkg/DESCRIPTION
like that
then create a directory under pkg that is the new package name that you want
pkg
Hi, R Users,
Can maintainer rename the package on F-Forge?
Any suggestions will be appreciated.
Wenjun
--
Wenjun
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE d
Here is one way using a 'list':
> x <- data.frame(a=1:10, b=21:30, c=41:50)
> out <- lapply(x, function(z){
+ hist(z, plot=FALSE)
+ })
>
> str(out)
List of 3
$ a:List of 7
..$ breaks : num [1:6] 0 2 4 6 8 10
..$ counts : int [1:5] 2 2 2 2 2
..$ intensities: num [1:5] 0.1 0.1 0.1
Hi all,
I am trying to find a way to rename R objects with names pulled from a
vector of names. For example, I have a data frame, my.data.frame, and
a list of names, my.names. My.names is simply the column names of
my.data.frame.
I want save the histogram with the column name as the name of the
The Hmisc package's upData function makes it easy to rename variables, and
at the same time you can provide labels, value labels (factor levels),
units of measurement, and other things.
Frank
> Dear R-helpers,
>
> I hope someone can help me with the following problem:
>
> I derived a variable fro
On 17/11/2007 3:45 PM, [EMAIL PROTECTED] wrote:
> Dear R-helpers,
>
> I hope someone can help me with the following problem:
>
> I derived a variable from many others and produced data.frame: toktempo
> When I look at the variable name I get:
>
> names(toktempo)
> [1] "otok.V5"
>
> But I wa
Dear R-helpers,
I hope someone can help me with the following problem:
I derived a variable from many others and produced data.frame: toktempo
When I look at the variable name I get:
names(toktempo)
[1] "otok.V5"
But I want the variable name to be Tempo so I googled around to find info
abo
66 matches
Mail list logo