[R-es] saben si el paquete kmeans++ funciona en R?

2021-11-20 Thread Carlos Santos
Hola a todos,

Queria preguntarles si saben por casualidad si el paquete kmeans++ funciona
en R o solo en Python, y si funciona en R, saben como se llama la
libreria para cargarlo, porque he estado buscando pero no veo nada por
ningun lado.

El hermano de este, osea el kmeans, ya se que funciona y esta dentro de R,
pero no veo nada sobre este otro

Muchas gracias por vuestra gran ayuda

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] Date read correctly from CSV, then reformatted incorrectly by R

2021-11-20 Thread Avi Gross via R-help
This seems to be a topic that comes up periodically. The various ways in R
and other packages for reading in data often come with methods that simply
guess wrong or encounter one or more data items in a column that really do
not fit so fields may just by default become a more common denominator of
character or perhaps floating point.

There are ways that some such programs can be given a hint of what you
expect or even be supplied with a way to coerce them into what you want
while being read in. But realistically, often a more practical  method might
be to take the data.frame variety you read in and before using it for other
purposes, check it for validity and make any needed changes. Simplistic ones
might be to see how many columns were read in to see if it matches
expectations or generate an error. Or you may trim columns (or rows) that
are not wanted.

In that vein, are there existing functions available that will accept what
types you want one or more columns to be in and that validate if the current
type is something else and then convert if needed? I mean we have functions
like as.integer(df$x ) or more flexibly as(df$x, "integer") and you may
simply build on a set of those and create others to suit any special needs.

Of course a good method carefully checks the results before over-writing as
sometimes the result may not be the same length (as shown below) or may
violate some other ideas or rules:

> as(c(NULL, NA, 3, 3.1, "3.1", list(1,2,"a")), "character")
[1] "NA"  "3"   "3.1" "3.1" "1"   "2"   "a"  

So if you have dates in some format, or sometimes an unknown format, there
are ways, including some others have shown, to make them into some other
date format or even make multiple columns that together embody the format.

What people sometimes do is assume software is perfect and should do
anything they want. It is the other way around and the programmer or data
creator has some responsibilities to use the right software on the right
data and that may also mean sanity checks along the way to  see if the data
is what you expect or alter it to be what you need.


-Original Message-
From: R-help  On Behalf Of Philip Monk
Sent: Saturday, November 20, 2021 3:28 PM
To: Jeff Newmiller 
Cc: R-help Mailing List 
Subject: Re: [R] Date read correctly from CSV, then reformatted incorrectly
by R

Thanks, Jeff.

I follow what you're doing below, but know I need to read up on Date /
POSIXct.  Helpful direction!  :)

On Sat, 20 Nov 2021 at 18:41, Jeff Newmiller 
wrote:
>
> Beat me to it! But it is also worth noting that once converted to Date or
POSIXct, timestamps should be treated as data without regard to how that
data is displayed. When you choose to output that data you will have options
as to the display format associated with the function you are using for
output.
>
> My take:
>
> dta <- read.table( text=
> "Buffer28/10/201619/11/2016  31/12/201616/01/2017
05/03/2017
> 1002.437110889-8.696748953.2392998162.443183304
2.346743827
> 2002.524329899-7.6888620683.3868117342.680347706
2.253885237
> 3002.100784256-8.0598558353.1437865072.615152896
2.015645973
> 4001.985608385-10.67072062.8945727912.591925038
2.057913137
> 5001.824982163-9.1225197362.5603507272.372226799
1.995863839
> ", header=TRUE, check.names=FALSE, as.is=TRUE)
>
> dta
>
> library(dplyr)
> library(tidyr)
>
> dt_fmt <- "%d/%m/%Y"
>
> dta_long <- (   dta
> %>% pivot_longer( cols = -Buffer
> , names_to = "dt_chr"
> , values_to = "LST"
> )
> %>% mutate( dt_date = as.Date( dt_chr, format = dt_fmt )
>   , dt_POSIXct = as.POSIXct( dt_chr, format = dt_fmt,
tz = "Etc/GMT+8" )
>   )
> )
>
> dta_long
>
> On November 20, 2021 10:01:56 AM PST, Andrew Simmons 
wrote:
> >The as.Date function for a character class argument will try reading 
> >in two formats (%Y-%m-%d and %Y/%m/%d).
> >
> >
> >This does not look like the format you have provided, which is why it 
> >doesn't work. Try something like:
> >
> >
> >x <- c("28/10/2016", "19/11/2016", "31/12/2016", "16/01/2016", 
> >"05/03/2017") as.Date(x, format = "%d/%m/%Y")
> >
> >
> >which produces this output:
> >
> >
> >> x <- c("28/10/2016", "19/11/2016", "31/12/2016", "16/01/2016",
> >"05/03/2017")
> >> as.Date(x, format = "%d/%m/%Y")
> >[1] "2016-10-28" "2016-11-19" "2016-12-31" "2016-01-16" "2017-03-05"
> >>
> >
> >
> >much better than before! I hope this helps
> >
> >On Sat, Nov 20, 2021 at 12:49 PM Philip Monk  wrote:
> >
> >> Thanks Eric & Jeff.
> >>
> >> I'll certainly read up on lubridate, and the posting guide (again) 
> >> (this should be in plain text).
> >>
> >> CSV extract below...
> >>
> >> Philip
> >>
> >> Buffer28/10/201619/11/201631/12/201616/01/2017
> >> 05/03/2017
> >> 1002.437110889-8.696748953.239299816

Re: [R] Date read correctly from CSV, then reformatted incorrectly by R

2021-11-20 Thread Philip Monk
I am.  Long day, poorly small children!

P

On Sat, 20 Nov 2021, 21:08 Bert Gunter,  wrote:

> "I also know that '/' is a special character in R (if that's the right
> term) "
>
> That is false. I think you are confusing "/" with "\", which is R's
> *escape* character.
>
> > cat("a/nb")
> a/nb
> > cat("a\nb")
> a
> b
>
> It gets confusing especially in regex's, because "\" is used in regex
> syntax also.
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
> On Sat, Nov 20, 2021 at 12:23 PM Philip Monk  wrote:
> >
> > Thanks, Andrew.  I didn't realise as.Date *only* read two formats, I
> > think I was tripped up by using %y instead of %Y, though I also know
> > that '/' is a special character in R (if that's the right term) and as
> > such know there is special syntax to use (which I don't know).
> >
> > On Sat, 20 Nov 2021 at 18:02, Andrew Simmons  wrote:
> > >
> > > The as.Date function for a character class argument will try reading
> in two formats (%Y-%m-%d and %Y/%m/%d).
> > >
> > >
> > > This does not look like the format you have provided, which is why it
> doesn't work. Try something like:
> > >
> > >
> > > x <- c("28/10/2016", "19/11/2016", "31/12/2016", "16/01/2016",
> "05/03/2017")
> > > as.Date(x, format = "%d/%m/%Y")
> > >
> > >
> > > which produces this output:
> > >
> > >
> > > > x <- c("28/10/2016", "19/11/2016", "31/12/2016", "16/01/2016",
> "05/03/2017")
> > > > as.Date(x, format = "%d/%m/%Y")
> > > [1] "2016-10-28" "2016-11-19" "2016-12-31" "2016-01-16" "2017-03-05"
> > > >
> > >
> > >
> > > much better than before! I hope this helps
> > >
> > > On Sat, Nov 20, 2021 at 12:49 PM Philip Monk  wrote:
> > >>
> > >> Thanks Eric & Jeff.
> > >>
> > >> I'll certainly read up on lubridate, and the posting guide (again)
> > >> (this should be in plain text).
> > >>
> > >> CSV extract below...
> > >>
> > >> Philip
> > >>
> > >> Buffer28/10/201619/11/201631/12/201616/01/2017
> 05/03/2017
> > >> 1002.437110889-8.696748953.2392998162.443183304
> 2.346743827
> > >> 2002.524329899-7.6888620683.3868117342.680347706
> 2.253885237
> > >> 3002.100784256-8.0598558353.1437865072.615152896
> 2.015645973
> > >> 4001.985608385-10.67072062.8945727912.591925038
> 2.057913137
> > >> 5001.824982163-9.1225197362.5603507272.372226799
> 1.995863839
> > >>
> > >>
> > >> On Sat, 20 Nov 2021 at 17:08, Philip Monk  wrote:
> > >> >
> > >> > Hello,
> > >> >
> > >> > Simple but infuriating problem.
> > >> >
> > >> > Reading in CSV of data using :
> > >> >
> > >> > ```
> > >> > # CSV file has column headers with date of scene capture in format
> dd/mm/
> > >> > # check.names = FALSE averts R incorrectly processing dates due to
> '/'
> > >> > data <- read.csv("C:/R_data/Bungala (b2000) julian.csv",
> check.names = FALSE)
> > >> >
> > >> > # Converts data table from wide (many columns) to long (many rows)
> and creates the new object 'data_long'
> > >> > # Column 1 is the 'Buffer' number (100-2000), Columns 2-25 contain
> monthly data covering 2 years (the header row being the date, and rows 2-21
> being a value for each buffer).
> > >> > # Column headers for columns 2:25 are mutated into a column called
> 'Date', values for each buffer and each date into the column 'LST'
> > >> > data_long <- data %>% pivot_longer(cols = 2:25, names_to = "Date",
> values_to = "LST")
> > >> >
> > >> > # Instructs R to treat the 'Date' column data as a date
> > >> > data_long$Date <- as.Date(data_long$Date)
> > >> > ```
> > >> >
> > >> > Using str(data), I can see that R has correctly read the dates in
> the format %d/%m/%y (e.g. 15/12/2015) though has the data type as chr.
> > >> >
> > >> > Once changing the type to 'Date', however, the date is
> reconfigured.  For instance, 15/01/2010 (15 January 2010), becomes
> 0015-01-20.
> > >> >
> > >> > I've tried ```data_long$Date <- as.Date(data_long$Date, format =
> "%d/%m.%y")```, and also ```tryformat c("%d/%m%y")```, but either the error
> persists or I get ```NA```.
> > >> >
> > >> > How do I make R change Date from 'chr' to 'date' without it going
> wrong?
> > >> >
> > >> > Suggestions/hints/solutions would be most welcome.  :)
> > >> >
> > >> > Thanks for your time,
> > >> >
> > >> > Philip
> > >> >
> > >> > Part-time PhD Student (Environmental Science)
> > >> > Lancaster University, UK.
> > >> >
> > >> > ~
> > >> >
> > >> > I asked a question a few weeks ago and put together the answer I
> needed from the responses but didn't know how to say thanks on this list.
> So, thanks Andrew Simmons, Bert Gunter, Jeff Newmiller and Daniel Nordlund!
> > >>
> > >> __
> > >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > >> https://stat.ethz.ch/mailman/listinfo/r-help
> > >> PLEASE do read the 

Re: [R] Date read correctly from CSV, then reformatted incorrectly by R

2021-11-20 Thread Bert Gunter
"I also know that '/' is a special character in R (if that's the right term) "

That is false. I think you are confusing "/" with "\", which is R's
*escape* character.

> cat("a/nb")
a/nb
> cat("a\nb")
a
b

It gets confusing especially in regex's, because "\" is used in regex
syntax also.

Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Sat, Nov 20, 2021 at 12:23 PM Philip Monk  wrote:
>
> Thanks, Andrew.  I didn't realise as.Date *only* read two formats, I
> think I was tripped up by using %y instead of %Y, though I also know
> that '/' is a special character in R (if that's the right term) and as
> such know there is special syntax to use (which I don't know).
>
> On Sat, 20 Nov 2021 at 18:02, Andrew Simmons  wrote:
> >
> > The as.Date function for a character class argument will try reading in two 
> > formats (%Y-%m-%d and %Y/%m/%d).
> >
> >
> > This does not look like the format you have provided, which is why it 
> > doesn't work. Try something like:
> >
> >
> > x <- c("28/10/2016", "19/11/2016", "31/12/2016", "16/01/2016", "05/03/2017")
> > as.Date(x, format = "%d/%m/%Y")
> >
> >
> > which produces this output:
> >
> >
> > > x <- c("28/10/2016", "19/11/2016", "31/12/2016", "16/01/2016", 
> > > "05/03/2017")
> > > as.Date(x, format = "%d/%m/%Y")
> > [1] "2016-10-28" "2016-11-19" "2016-12-31" "2016-01-16" "2017-03-05"
> > >
> >
> >
> > much better than before! I hope this helps
> >
> > On Sat, Nov 20, 2021 at 12:49 PM Philip Monk  wrote:
> >>
> >> Thanks Eric & Jeff.
> >>
> >> I'll certainly read up on lubridate, and the posting guide (again)
> >> (this should be in plain text).
> >>
> >> CSV extract below...
> >>
> >> Philip
> >>
> >> Buffer28/10/201619/11/201631/12/201616/01/2017
> >> 05/03/2017
> >> 1002.437110889-8.696748953.2392998162.443183304
> >> 2.346743827
> >> 2002.524329899-7.6888620683.3868117342.680347706
> >> 2.253885237
> >> 3002.100784256-8.0598558353.1437865072.615152896
> >> 2.015645973
> >> 4001.985608385-10.67072062.8945727912.591925038
> >> 2.057913137
> >> 5001.824982163-9.1225197362.5603507272.372226799
> >> 1.995863839
> >>
> >>
> >> On Sat, 20 Nov 2021 at 17:08, Philip Monk  wrote:
> >> >
> >> > Hello,
> >> >
> >> > Simple but infuriating problem.
> >> >
> >> > Reading in CSV of data using :
> >> >
> >> > ```
> >> > # CSV file has column headers with date of scene capture in format 
> >> > dd/mm/
> >> > # check.names = FALSE averts R incorrectly processing dates due to '/'
> >> > data <- read.csv("C:/R_data/Bungala (b2000) julian.csv", check.names = 
> >> > FALSE)
> >> >
> >> > # Converts data table from wide (many columns) to long (many rows) and 
> >> > creates the new object 'data_long'
> >> > # Column 1 is the 'Buffer' number (100-2000), Columns 2-25 contain 
> >> > monthly data covering 2 years (the header row being the date, and rows 
> >> > 2-21 being a value for each buffer).
> >> > # Column headers for columns 2:25 are mutated into a column called 
> >> > 'Date', values for each buffer and each date into the column 'LST'
> >> > data_long <- data %>% pivot_longer(cols = 2:25, names_to = "Date", 
> >> > values_to = "LST")
> >> >
> >> > # Instructs R to treat the 'Date' column data as a date
> >> > data_long$Date <- as.Date(data_long$Date)
> >> > ```
> >> >
> >> > Using str(data), I can see that R has correctly read the dates in the 
> >> > format %d/%m/%y (e.g. 15/12/2015) though has the data type as chr.
> >> >
> >> > Once changing the type to 'Date', however, the date is reconfigured.  
> >> > For instance, 15/01/2010 (15 January 2010), becomes 0015-01-20.
> >> >
> >> > I've tried ```data_long$Date <- as.Date(data_long$Date, format = 
> >> > "%d/%m.%y")```, and also ```tryformat c("%d/%m%y")```, but either the 
> >> > error persists or I get ```NA```.
> >> >
> >> > How do I make R change Date from 'chr' to 'date' without it going wrong?
> >> >
> >> > Suggestions/hints/solutions would be most welcome.  :)
> >> >
> >> > Thanks for your time,
> >> >
> >> > Philip
> >> >
> >> > Part-time PhD Student (Environmental Science)
> >> > Lancaster University, UK.
> >> >
> >> > ~
> >> >
> >> > I asked a question a few weeks ago and put together the answer I needed 
> >> > from the responses but didn't know how to say thanks on this list.  So, 
> >> > thanks Andrew Simmons, Bert Gunter, Jeff Newmiller and Daniel Nordlund!
> >>
> >> __
> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide 
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
>
> __
> 

Re: [R] Date read correctly from CSV, then reformatted incorrectly by R

2021-11-20 Thread Philip Monk
Thanks, Jeff.

I follow what you're doing below, but know I need to read up on Date /
POSIXct.  Helpful direction!  :)

On Sat, 20 Nov 2021 at 18:41, Jeff Newmiller  wrote:
>
> Beat me to it! But it is also worth noting that once converted to Date or 
> POSIXct, timestamps should be treated as data without regard to how that data 
> is displayed. When you choose to output that data you will have options as to 
> the display format associated with the function you are using for output.
>
> My take:
>
> dta <- read.table( text=
> "Buffer28/10/201619/11/2016  31/12/201616/01/201705/03/2017
> 1002.437110889-8.696748953.2392998162.4431833042.346743827
> 2002.524329899-7.6888620683.3868117342.680347706
> 2.253885237
> 3002.100784256-8.0598558353.1437865072.615152896
> 2.015645973
> 4001.985608385-10.67072062.8945727912.5919250382.057913137
> 5001.824982163-9.1225197362.5603507272.372226799
> 1.995863839
> ", header=TRUE, check.names=FALSE, as.is=TRUE)
>
> dta
>
> library(dplyr)
> library(tidyr)
>
> dt_fmt <- "%d/%m/%Y"
>
> dta_long <- (   dta
> %>% pivot_longer( cols = -Buffer
> , names_to = "dt_chr"
> , values_to = "LST"
> )
> %>% mutate( dt_date = as.Date( dt_chr, format = dt_fmt )
>   , dt_POSIXct = as.POSIXct( dt_chr, format = dt_fmt, tz 
> = "Etc/GMT+8" )
>   )
> )
>
> dta_long
>
> On November 20, 2021 10:01:56 AM PST, Andrew Simmons  
> wrote:
> >The as.Date function for a character class argument will try reading in two
> >formats (%Y-%m-%d and %Y/%m/%d).
> >
> >
> >This does not look like the format you have provided, which is why it
> >doesn't work. Try something like:
> >
> >
> >x <- c("28/10/2016", "19/11/2016", "31/12/2016", "16/01/2016", "05/03/2017")
> >as.Date(x, format = "%d/%m/%Y")
> >
> >
> >which produces this output:
> >
> >
> >> x <- c("28/10/2016", "19/11/2016", "31/12/2016", "16/01/2016",
> >"05/03/2017")
> >> as.Date(x, format = "%d/%m/%Y")
> >[1] "2016-10-28" "2016-11-19" "2016-12-31" "2016-01-16" "2017-03-05"
> >>
> >
> >
> >much better than before! I hope this helps
> >
> >On Sat, Nov 20, 2021 at 12:49 PM Philip Monk  wrote:
> >
> >> Thanks Eric & Jeff.
> >>
> >> I'll certainly read up on lubridate, and the posting guide (again)
> >> (this should be in plain text).
> >>
> >> CSV extract below...
> >>
> >> Philip
> >>
> >> Buffer28/10/201619/11/201631/12/201616/01/2017
> >> 05/03/2017
> >> 1002.437110889-8.696748953.2392998162.443183304
> >> 2.346743827
> >> 2002.524329899-7.6888620683.3868117342.680347706
> >> 2.253885237
> >> 3002.100784256-8.0598558353.1437865072.615152896
> >> 2.015645973
> >> 4001.985608385-10.67072062.8945727912.591925038
> >> 2.057913137
> >> 5001.824982163-9.1225197362.5603507272.372226799
> >> 1.995863839
> >>
> >>
> >> On Sat, 20 Nov 2021 at 17:08, Philip Monk  wrote:
> >> >
> >> > Hello,
> >> >
> >> > Simple but infuriating problem.
> >> >
> >> > Reading in CSV of data using :
> >> >
> >> > ```
> >> > # CSV file has column headers with date of scene capture in format
> >> dd/mm/
> >> > # check.names = FALSE averts R incorrectly processing dates due to '/'
> >> > data <- read.csv("C:/R_data/Bungala (b2000) julian.csv", check.names =
> >> FALSE)
> >> >
> >> > # Converts data table from wide (many columns) to long (many rows) and
> >> creates the new object 'data_long'
> >> > # Column 1 is the 'Buffer' number (100-2000), Columns 2-25 contain
> >> monthly data covering 2 years (the header row being the date, and rows 2-21
> >> being a value for each buffer).
> >> > # Column headers for columns 2:25 are mutated into a column called
> >> 'Date', values for each buffer and each date into the column 'LST'
> >> > data_long <- data %>% pivot_longer(cols = 2:25, names_to = "Date",
> >> values_to = "LST")
> >> >
> >> > # Instructs R to treat the 'Date' column data as a date
> >> > data_long$Date <- as.Date(data_long$Date)
> >> > ```
> >> >
> >> > Using str(data), I can see that R has correctly read the dates in the
> >> format %d/%m/%y (e.g. 15/12/2015) though has the data type as chr.
> >> >
> >> > Once changing the type to 'Date', however, the date is reconfigured.
> >> For instance, 15/01/2010 (15 January 2010), becomes 0015-01-20.
> >> >
> >> > I've tried ```data_long$Date <- as.Date(data_long$Date, format =
> >> "%d/%m.%y")```, and also ```tryformat c("%d/%m%y")```, but either the error
> >> persists or I get ```NA```.
> >> >
> >> > How do I make R change Date from 'chr' to 'date' without it going wrong?
> >> >
> >> > Suggestions/hints/solutions would be most welcome.  :)
> >> >
> >> > Thanks for your time,
> >> >
> >> > Philip
> >> >
> >> > Part-time PhD Student (Environmental Science)
> >> > 

Re: [R] Date read correctly from CSV, then reformatted incorrectly by R

2021-11-20 Thread Philip Monk
Thanks, Andrew.  I didn't realise as.Date *only* read two formats, I
think I was tripped up by using %y instead of %Y, though I also know
that '/' is a special character in R (if that's the right term) and as
such know there is special syntax to use (which I don't know).

On Sat, 20 Nov 2021 at 18:02, Andrew Simmons  wrote:
>
> The as.Date function for a character class argument will try reading in two 
> formats (%Y-%m-%d and %Y/%m/%d).
>
>
> This does not look like the format you have provided, which is why it doesn't 
> work. Try something like:
>
>
> x <- c("28/10/2016", "19/11/2016", "31/12/2016", "16/01/2016", "05/03/2017")
> as.Date(x, format = "%d/%m/%Y")
>
>
> which produces this output:
>
>
> > x <- c("28/10/2016", "19/11/2016", "31/12/2016", "16/01/2016", "05/03/2017")
> > as.Date(x, format = "%d/%m/%Y")
> [1] "2016-10-28" "2016-11-19" "2016-12-31" "2016-01-16" "2017-03-05"
> >
>
>
> much better than before! I hope this helps
>
> On Sat, Nov 20, 2021 at 12:49 PM Philip Monk  wrote:
>>
>> Thanks Eric & Jeff.
>>
>> I'll certainly read up on lubridate, and the posting guide (again)
>> (this should be in plain text).
>>
>> CSV extract below...
>>
>> Philip
>>
>> Buffer28/10/201619/11/201631/12/201616/01/201705/03/2017
>> 1002.437110889-8.696748953.2392998162.443183304
>> 2.346743827
>> 2002.524329899-7.6888620683.3868117342.680347706
>> 2.253885237
>> 3002.100784256-8.0598558353.1437865072.615152896
>> 2.015645973
>> 4001.985608385-10.67072062.8945727912.591925038
>> 2.057913137
>> 5001.824982163-9.1225197362.5603507272.372226799
>> 1.995863839
>>
>>
>> On Sat, 20 Nov 2021 at 17:08, Philip Monk  wrote:
>> >
>> > Hello,
>> >
>> > Simple but infuriating problem.
>> >
>> > Reading in CSV of data using :
>> >
>> > ```
>> > # CSV file has column headers with date of scene capture in format 
>> > dd/mm/
>> > # check.names = FALSE averts R incorrectly processing dates due to '/'
>> > data <- read.csv("C:/R_data/Bungala (b2000) julian.csv", check.names = 
>> > FALSE)
>> >
>> > # Converts data table from wide (many columns) to long (many rows) and 
>> > creates the new object 'data_long'
>> > # Column 1 is the 'Buffer' number (100-2000), Columns 2-25 contain monthly 
>> > data covering 2 years (the header row being the date, and rows 2-21 being 
>> > a value for each buffer).
>> > # Column headers for columns 2:25 are mutated into a column called 'Date', 
>> > values for each buffer and each date into the column 'LST'
>> > data_long <- data %>% pivot_longer(cols = 2:25, names_to = "Date", 
>> > values_to = "LST")
>> >
>> > # Instructs R to treat the 'Date' column data as a date
>> > data_long$Date <- as.Date(data_long$Date)
>> > ```
>> >
>> > Using str(data), I can see that R has correctly read the dates in the 
>> > format %d/%m/%y (e.g. 15/12/2015) though has the data type as chr.
>> >
>> > Once changing the type to 'Date', however, the date is reconfigured.  For 
>> > instance, 15/01/2010 (15 January 2010), becomes 0015-01-20.
>> >
>> > I've tried ```data_long$Date <- as.Date(data_long$Date, format = 
>> > "%d/%m.%y")```, and also ```tryformat c("%d/%m%y")```, but either the 
>> > error persists or I get ```NA```.
>> >
>> > How do I make R change Date from 'chr' to 'date' without it going wrong?
>> >
>> > Suggestions/hints/solutions would be most welcome.  :)
>> >
>> > Thanks for your time,
>> >
>> > Philip
>> >
>> > Part-time PhD Student (Environmental Science)
>> > Lancaster University, UK.
>> >
>> > ~
>> >
>> > I asked a question a few weeks ago and put together the answer I needed 
>> > from the responses but didn't know how to say thanks on this list.  So, 
>> > thanks Andrew Simmons, Bert Gunter, Jeff Newmiller and Daniel Nordlund!
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Date read correctly from CSV, then reformatted incorrectly by R

2021-11-20 Thread Jeff Newmiller
Beat me to it! But it is also worth noting that once converted to Date or 
POSIXct, timestamps should be treated as data without regard to how that data 
is displayed. When you choose to output that data you will have options as to 
the display format associated with the function you are using for output.

My take:

dta <- read.table( text=
"Buffer28/10/201619/11/2016  31/12/201616/01/201705/03/2017
1002.437110889-8.696748953.2392998162.4431833042.346743827
2002.524329899-7.6888620683.3868117342.6803477062.253885237
3002.100784256-8.0598558353.1437865072.6151528962.015645973
4001.985608385-10.67072062.8945727912.5919250382.057913137
5001.824982163-9.1225197362.5603507272.3722267991.995863839
", header=TRUE, check.names=FALSE, as.is=TRUE)

dta

library(dplyr)
library(tidyr)

dt_fmt <- "%d/%m/%Y"

dta_long <- (   dta
%>% pivot_longer( cols = -Buffer
, names_to = "dt_chr"
, values_to = "LST"
)
%>% mutate( dt_date = as.Date( dt_chr, format = dt_fmt )
  , dt_POSIXct = as.POSIXct( dt_chr, format = dt_fmt, tz = 
"Etc/GMT+8" )
  )
)

dta_long

On November 20, 2021 10:01:56 AM PST, Andrew Simmons  wrote:
>The as.Date function for a character class argument will try reading in two
>formats (%Y-%m-%d and %Y/%m/%d).
>
>
>This does not look like the format you have provided, which is why it
>doesn't work. Try something like:
>
>
>x <- c("28/10/2016", "19/11/2016", "31/12/2016", "16/01/2016", "05/03/2017")
>as.Date(x, format = "%d/%m/%Y")
>
>
>which produces this output:
>
>
>> x <- c("28/10/2016", "19/11/2016", "31/12/2016", "16/01/2016",
>"05/03/2017")
>> as.Date(x, format = "%d/%m/%Y")
>[1] "2016-10-28" "2016-11-19" "2016-12-31" "2016-01-16" "2017-03-05"
>>
>
>
>much better than before! I hope this helps
>
>On Sat, Nov 20, 2021 at 12:49 PM Philip Monk  wrote:
>
>> Thanks Eric & Jeff.
>>
>> I'll certainly read up on lubridate, and the posting guide (again)
>> (this should be in plain text).
>>
>> CSV extract below...
>>
>> Philip
>>
>> Buffer28/10/201619/11/201631/12/201616/01/2017
>> 05/03/2017
>> 1002.437110889-8.696748953.2392998162.443183304
>> 2.346743827
>> 2002.524329899-7.6888620683.3868117342.680347706
>> 2.253885237
>> 3002.100784256-8.0598558353.1437865072.615152896
>> 2.015645973
>> 4001.985608385-10.67072062.8945727912.591925038
>> 2.057913137
>> 5001.824982163-9.1225197362.5603507272.372226799
>> 1.995863839
>>
>>
>> On Sat, 20 Nov 2021 at 17:08, Philip Monk  wrote:
>> >
>> > Hello,
>> >
>> > Simple but infuriating problem.
>> >
>> > Reading in CSV of data using :
>> >
>> > ```
>> > # CSV file has column headers with date of scene capture in format
>> dd/mm/
>> > # check.names = FALSE averts R incorrectly processing dates due to '/'
>> > data <- read.csv("C:/R_data/Bungala (b2000) julian.csv", check.names =
>> FALSE)
>> >
>> > # Converts data table from wide (many columns) to long (many rows) and
>> creates the new object 'data_long'
>> > # Column 1 is the 'Buffer' number (100-2000), Columns 2-25 contain
>> monthly data covering 2 years (the header row being the date, and rows 2-21
>> being a value for each buffer).
>> > # Column headers for columns 2:25 are mutated into a column called
>> 'Date', values for each buffer and each date into the column 'LST'
>> > data_long <- data %>% pivot_longer(cols = 2:25, names_to = "Date",
>> values_to = "LST")
>> >
>> > # Instructs R to treat the 'Date' column data as a date
>> > data_long$Date <- as.Date(data_long$Date)
>> > ```
>> >
>> > Using str(data), I can see that R has correctly read the dates in the
>> format %d/%m/%y (e.g. 15/12/2015) though has the data type as chr.
>> >
>> > Once changing the type to 'Date', however, the date is reconfigured.
>> For instance, 15/01/2010 (15 January 2010), becomes 0015-01-20.
>> >
>> > I've tried ```data_long$Date <- as.Date(data_long$Date, format =
>> "%d/%m.%y")```, and also ```tryformat c("%d/%m%y")```, but either the error
>> persists or I get ```NA```.
>> >
>> > How do I make R change Date from 'chr' to 'date' without it going wrong?
>> >
>> > Suggestions/hints/solutions would be most welcome.  :)
>> >
>> > Thanks for your time,
>> >
>> > Philip
>> >
>> > Part-time PhD Student (Environmental Science)
>> > Lancaster University, UK.
>> >
>> > ~
>> >
>> > I asked a question a few weeks ago and put together the answer I needed
>> from the responses but didn't know how to say thanks on this list.  So,
>> thanks Andrew Simmons, Bert Gunter, Jeff Newmiller and Daniel Nordlund!
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> 

Re: [R] Date read correctly from CSV, then reformatted incorrectly by R

2021-11-20 Thread Andrew Simmons
The as.Date function for a character class argument will try reading in two
formats (%Y-%m-%d and %Y/%m/%d).


This does not look like the format you have provided, which is why it
doesn't work. Try something like:


x <- c("28/10/2016", "19/11/2016", "31/12/2016", "16/01/2016", "05/03/2017")
as.Date(x, format = "%d/%m/%Y")


which produces this output:


> x <- c("28/10/2016", "19/11/2016", "31/12/2016", "16/01/2016",
"05/03/2017")
> as.Date(x, format = "%d/%m/%Y")
[1] "2016-10-28" "2016-11-19" "2016-12-31" "2016-01-16" "2017-03-05"
>


much better than before! I hope this helps

On Sat, Nov 20, 2021 at 12:49 PM Philip Monk  wrote:

> Thanks Eric & Jeff.
>
> I'll certainly read up on lubridate, and the posting guide (again)
> (this should be in plain text).
>
> CSV extract below...
>
> Philip
>
> Buffer28/10/201619/11/201631/12/201616/01/2017
> 05/03/2017
> 1002.437110889-8.696748953.2392998162.443183304
> 2.346743827
> 2002.524329899-7.6888620683.3868117342.680347706
> 2.253885237
> 3002.100784256-8.0598558353.1437865072.615152896
> 2.015645973
> 4001.985608385-10.67072062.8945727912.591925038
> 2.057913137
> 5001.824982163-9.1225197362.5603507272.372226799
> 1.995863839
>
>
> On Sat, 20 Nov 2021 at 17:08, Philip Monk  wrote:
> >
> > Hello,
> >
> > Simple but infuriating problem.
> >
> > Reading in CSV of data using :
> >
> > ```
> > # CSV file has column headers with date of scene capture in format
> dd/mm/
> > # check.names = FALSE averts R incorrectly processing dates due to '/'
> > data <- read.csv("C:/R_data/Bungala (b2000) julian.csv", check.names =
> FALSE)
> >
> > # Converts data table from wide (many columns) to long (many rows) and
> creates the new object 'data_long'
> > # Column 1 is the 'Buffer' number (100-2000), Columns 2-25 contain
> monthly data covering 2 years (the header row being the date, and rows 2-21
> being a value for each buffer).
> > # Column headers for columns 2:25 are mutated into a column called
> 'Date', values for each buffer and each date into the column 'LST'
> > data_long <- data %>% pivot_longer(cols = 2:25, names_to = "Date",
> values_to = "LST")
> >
> > # Instructs R to treat the 'Date' column data as a date
> > data_long$Date <- as.Date(data_long$Date)
> > ```
> >
> > Using str(data), I can see that R has correctly read the dates in the
> format %d/%m/%y (e.g. 15/12/2015) though has the data type as chr.
> >
> > Once changing the type to 'Date', however, the date is reconfigured.
> For instance, 15/01/2010 (15 January 2010), becomes 0015-01-20.
> >
> > I've tried ```data_long$Date <- as.Date(data_long$Date, format =
> "%d/%m.%y")```, and also ```tryformat c("%d/%m%y")```, but either the error
> persists or I get ```NA```.
> >
> > How do I make R change Date from 'chr' to 'date' without it going wrong?
> >
> > Suggestions/hints/solutions would be most welcome.  :)
> >
> > Thanks for your time,
> >
> > Philip
> >
> > Part-time PhD Student (Environmental Science)
> > Lancaster University, UK.
> >
> > ~
> >
> > I asked a question a few weeks ago and put together the answer I needed
> from the responses but didn't know how to say thanks on this list.  So,
> thanks Andrew Simmons, Bert Gunter, Jeff Newmiller and Daniel Nordlund!
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Date read correctly from CSV, then reformatted incorrectly by R

2021-11-20 Thread Philip Monk
Thanks Eric & Jeff.

I'll certainly read up on lubridate, and the posting guide (again)
(this should be in plain text).

CSV extract below...

Philip

Buffer28/10/201619/11/201631/12/201616/01/201705/03/2017
1002.437110889-8.696748953.2392998162.4431833042.346743827
2002.524329899-7.6888620683.3868117342.6803477062.253885237
3002.100784256-8.0598558353.1437865072.6151528962.015645973
4001.985608385-10.67072062.8945727912.5919250382.057913137
5001.824982163-9.1225197362.5603507272.3722267991.995863839


On Sat, 20 Nov 2021 at 17:08, Philip Monk  wrote:
>
> Hello,
>
> Simple but infuriating problem.
>
> Reading in CSV of data using :
>
> ```
> # CSV file has column headers with date of scene capture in format dd/mm/
> # check.names = FALSE averts R incorrectly processing dates due to '/'
> data <- read.csv("C:/R_data/Bungala (b2000) julian.csv", check.names = FALSE)
>
> # Converts data table from wide (many columns) to long (many rows) and 
> creates the new object 'data_long'
> # Column 1 is the 'Buffer' number (100-2000), Columns 2-25 contain monthly 
> data covering 2 years (the header row being the date, and rows 2-21 being a 
> value for each buffer).
> # Column headers for columns 2:25 are mutated into a column called 'Date', 
> values for each buffer and each date into the column 'LST'
> data_long <- data %>% pivot_longer(cols = 2:25, names_to = "Date", values_to 
> = "LST")
>
> # Instructs R to treat the 'Date' column data as a date
> data_long$Date <- as.Date(data_long$Date)
> ```
>
> Using str(data), I can see that R has correctly read the dates in the format 
> %d/%m/%y (e.g. 15/12/2015) though has the data type as chr.
>
> Once changing the type to 'Date', however, the date is reconfigured.  For 
> instance, 15/01/2010 (15 January 2010), becomes 0015-01-20.
>
> I've tried ```data_long$Date <- as.Date(data_long$Date, format = 
> "%d/%m.%y")```, and also ```tryformat c("%d/%m%y")```, but either the error 
> persists or I get ```NA```.
>
> How do I make R change Date from 'chr' to 'date' without it going wrong?
>
> Suggestions/hints/solutions would be most welcome.  :)
>
> Thanks for your time,
>
> Philip
>
> Part-time PhD Student (Environmental Science)
> Lancaster University, UK.
>
> ~
>
> I asked a question a few weeks ago and put together the answer I needed from 
> the responses but didn't know how to say thanks on this list.  So, thanks 
> Andrew Simmons, Bert Gunter, Jeff Newmiller and Daniel Nordlund!

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Date read correctly from CSV, then reformatted incorrectly by R

2021-11-20 Thread Jeff Newmiller
a) R data frames are column oriented. Do not fight this.

b) Data frame header names are character type. Period. Do not fight this.

It sounds like you need to reshape your data after you read it in. Provide the 
first five lines of your CSV file (or a reasonable facsimile if your data are 
confidential) and someone (me if I get to it first) can help make it more 
adapted to R.

Also, make sure you configure your email software to send plain text... 
formatted email gets damaged to varying degrees by the automatic stripping of 
formatting performed by the mailing list. And periodically read the Posting 
Guide for other advice.

On November 20, 2021 9:08:39 AM PST, Philip Monk  wrote:
>Hello,
>
>Simple but infuriating problem.
>
>Reading in CSV of data using :
>
>```
># CSV file has column headers with date of scene capture in format
>dd/mm/
># check.names = FALSE averts R incorrectly processing dates due to '/'
>data <- read.csv("C:/R_data/Bungala (b2000) julian.csv", check.names =
>FALSE)
>
># Converts data table from wide (many columns) to long (many rows) and
>creates the new object 'data_long'
># Column 1 is the 'Buffer' number (100-2000), Columns 2-25 contain monthly
>data covering 2 years (the header row being the date, and rows 2-21 being a
>value for each buffer).
># Column headers for columns 2:25 are mutated into a column called 'Date',
>values for each buffer and each date into the column 'LST'
>data_long <- data %>% pivot_longer(cols = 2:25, names_to = "Date",
>values_to = "LST")
>
># Instructs R to treat the 'Date' column data as a date
>data_long$Date <- as.Date(data_long$Date)
>```
>
>Using str(data), I can see that R has correctly read the dates in the
>format %d/%m/%y (e.g. 15/12/2015) though has the data type as chr.
>
>Once changing the type to 'Date', however, the date is reconfigured.  For
>instance, 15/01/2010 (15 January 2010), becomes 0015-01-20.
>
>I've tried ```data_long$Date <- as.Date(data_long$Date, format =
>"%d/%m.%y")```, and also ```tryformat c("%d/%m%y")```, but either the error
>persists or I get ```NA```.
>
>How do I make R change Date from 'chr' to 'date' without it going wrong?
>
>Suggestions/hints/solutions would be most welcome.  :)
>
>Thanks for your time,
>
>Philip
>
>Part-time PhD Student (Environmental Science)
>Lancaster University, UK.
>
>~
>
>I asked a question a few weeks ago and put together the answer I needed
>from the responses but didn't know how to say thanks on this list.  So,
>thanks Andrew Simmons, Bert Gunter, Jeff Newmiller and Daniel Nordlund!
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Date read correctly from CSV, then reformatted incorrectly by R

2021-11-20 Thread Eric Berger
Hi Philip,
This is a recurring question and there are many ways to do this.
My preference is to use the lubridate package.

library(lubridate)
a <- "15/01/2010"
b <- dmy(a)
b
# "2010-01-15"
class(b)
# [1] "Date"

HTH,
Eric


On Sat, Nov 20, 2021 at 7:09 PM Philip Monk  wrote:

> Hello,
>
> Simple but infuriating problem.
>
> Reading in CSV of data using :
>
> ```
> # CSV file has column headers with date of scene capture in format
> dd/mm/
> # check.names = FALSE averts R incorrectly processing dates due to '/'
> data <- read.csv("C:/R_data/Bungala (b2000) julian.csv", check.names =
> FALSE)
>
> # Converts data table from wide (many columns) to long (many rows) and
> creates the new object 'data_long'
> # Column 1 is the 'Buffer' number (100-2000), Columns 2-25 contain monthly
> data covering 2 years (the header row being the date, and rows 2-21 being a
> value for each buffer).
> # Column headers for columns 2:25 are mutated into a column called 'Date',
> values for each buffer and each date into the column 'LST'
> data_long <- data %>% pivot_longer(cols = 2:25, names_to = "Date",
> values_to = "LST")
>
> # Instructs R to treat the 'Date' column data as a date
> data_long$Date <- as.Date(data_long$Date)
> ```
>
> Using str(data), I can see that R has correctly read the dates in the
> format %d/%m/%y (e.g. 15/12/2015) though has the data type as chr.
>
> Once changing the type to 'Date', however, the date is reconfigured.  For
> instance, 15/01/2010 (15 January 2010), becomes 0015-01-20.
>
> I've tried ```data_long$Date <- as.Date(data_long$Date, format =
> "%d/%m.%y")```, and also ```tryformat c("%d/%m%y")```, but either the error
> persists or I get ```NA```.
>
> How do I make R change Date from 'chr' to 'date' without it going wrong?
>
> Suggestions/hints/solutions would be most welcome.  :)
>
> Thanks for your time,
>
> Philip
>
> Part-time PhD Student (Environmental Science)
> Lancaster University, UK.
>
> ~
>
> I asked a question a few weeks ago and put together the answer I needed
> from the responses but didn't know how to say thanks on this list.  So,
> thanks Andrew Simmons, Bert Gunter, Jeff Newmiller and Daniel Nordlund!
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Date read correctly from CSV, then reformatted incorrectly by R

2021-11-20 Thread Philip Monk
Hello,

Simple but infuriating problem.

Reading in CSV of data using :

```
# CSV file has column headers with date of scene capture in format
dd/mm/
# check.names = FALSE averts R incorrectly processing dates due to '/'
data <- read.csv("C:/R_data/Bungala (b2000) julian.csv", check.names =
FALSE)

# Converts data table from wide (many columns) to long (many rows) and
creates the new object 'data_long'
# Column 1 is the 'Buffer' number (100-2000), Columns 2-25 contain monthly
data covering 2 years (the header row being the date, and rows 2-21 being a
value for each buffer).
# Column headers for columns 2:25 are mutated into a column called 'Date',
values for each buffer and each date into the column 'LST'
data_long <- data %>% pivot_longer(cols = 2:25, names_to = "Date",
values_to = "LST")

# Instructs R to treat the 'Date' column data as a date
data_long$Date <- as.Date(data_long$Date)
```

Using str(data), I can see that R has correctly read the dates in the
format %d/%m/%y (e.g. 15/12/2015) though has the data type as chr.

Once changing the type to 'Date', however, the date is reconfigured.  For
instance, 15/01/2010 (15 January 2010), becomes 0015-01-20.

I've tried ```data_long$Date <- as.Date(data_long$Date, format =
"%d/%m.%y")```, and also ```tryformat c("%d/%m%y")```, but either the error
persists or I get ```NA```.

How do I make R change Date from 'chr' to 'date' without it going wrong?

Suggestions/hints/solutions would be most welcome.  :)

Thanks for your time,

Philip

Part-time PhD Student (Environmental Science)
Lancaster University, UK.

~

I asked a question a few weeks ago and put together the answer I needed
from the responses but didn't know how to say thanks on this list.  So,
thanks Andrew Simmons, Bert Gunter, Jeff Newmiller and Daniel Nordlund!

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] tsmp::find_discord help

2021-11-20 Thread Bert Gunter
Please read and follow the posting guide linked below, which says:

"For questions about functions in standard packages distributed with R
(see the FAQ Add-on packages in R), ask questions on R-help.
If the question relates to a contributed package , e.g., one
downloaded from CRAN, try contacting the package maintainer first. You
can also use find("functionname") and
packageDescription("packagename") to find this information. Only send
such questions to R-help or R-devel if you get no reply or need
further assistance. This applies to both requests for help and to bug
reports."

You might check to see if the package has its own help resources. Some do.

Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Sat, Nov 20, 2021 at 4:11 AM David Katz via R-help
 wrote:
>
> windowSize <- 114L
>
> myData <- c(270.462263440434, 272.664102077857, 269.796430162527,
> 265.715722218109,
> 264.406853005756, 265.084587771026, 264.098291489715, 260.43527948116,
> 258.516029706132, 257.495599873085, 256.301471509598, 257.3508273663,
> 255.286756542046, 253.920890634228, 252.536181194196, 253.901498621143,
> 252.488770200592, 253.17373118042, 252.966600656463, 252.703126928303,
> 253.904283441231, 256.149065587949, 257.487833837001, 257.305445475504,
> 256.971778599266, 257.031127100531, 258.378144076467, 257.700536692981,
> 259.294733786397, 257.752154694684, 258.027081468422, 258.08672459079,
> 258.041715753358, 258.329487642599, 258.299665291887, 258.758197146375,
> 259.073160554189, 257.290848280257, 256.57958424734, 255.263597775251,
> 255.428375537274, 254.852562069893, 255.16275117402, 253.104822101118,
> 252.968454384943, 252.958341056947, 252.413550664159, 252.313035522727,
> 251.905248262594, 249.840876041166, 250.108495180914, 249.303993972763,
> 246.963484593993, 248.346250534011, 248.325232558372, 246.80674746288,
> 247.909455339378, 247.433042791532, 249.402794581885, 249.331976547884,
> 248.568579055881, 250.594387768302, 251.758252350008, 254.032460428914,
> 251.686880985135, 253.671777128056, 255.134789754357, 256.064375638822,
> 253.801672161138, 257.719489656389, 253.966827685572, 255.13559199986,
> 255.166921377648, 255.962630526721, 257.962603157666, 254.79940264686,
> 256.855849863449, 255.832325716596, 255.695450823382, 254.736885948759,
> 251.398771970114, 245.5259580418, 237.715336617082, 232.391882092226,
> 225.879365097452, 234.597402322106, 227.98504127278, 228.139076301549,
> 224.173886041436, 226.227280351566, 224.658020137018, 222.056649738085,
> 223.3202662481, 219.113969733892, 218.391448495584, 218.051289301226,
> 241.309807159239, 231.913033676054, 246.67008242067, 239.862456006277,
> 256.373582866136, 258.422042267257, 254.934707124019, 256.099923688313,
> 253.918253725441, 250.084642761294, 250.806687402073, 253.652116958844,
> 253.796670716768, 234.682091120398, 231.080911108106, 231.195135810459,
> 224.727161067631, 223.892852459149, 228.885059227748, 234.11580639,
> 238.62885521967, 242.106482479768, 243.921211695019, 244.846424317779,
> 248.432817418315, 252.583033349365, 255.085796192987, 256.980864458624,
> 258.223037317721, 257.445069981506, 260.982180904737, 262.487198309787,
> 264.418811357114, 262.814652461885, 260.130595969269, 261.116867189016,
> 260.834598457301, 261.334277956188, 260.53066947828, 259.745895410888,
> 261.29109349791, 261.493881158018, 263.980493014213, 262.876190291578,
> 264.16183147626, 264.804793464811, 262.390942223882, 261.544820740027,
> 260.380895000463, 261.926068113605, 260.928243354987, 258.966465326864,
> 260.547825717181, 259.675027847523, 259.435857442394, 256.966581859812,
> 255.822263459302, 257.62250959808, 255.608143508667, 255.460477147251,
> 257.430493221805, 256.616983212018, 256.396313681593, 254.89111013636,
> 253.111957965884, 253.820672287187, 252.568848789204, 250.287826519459,
> 250.850996744586, 249.534365097154, 249.722974164085, 249.325430105766,
> 248.004227338824, 248.422241862165, 248.9895549729, 248.515746102668,
> 247.411875064159, 247.836559468554, 245.499609602103, 242.627764024446,
> 243.192466861987, 242.535635591811, 240.80014768187, 241.012683392456,
> 242.48190025622, 240.923248882825, 240.708791351318, 241.933056565281,
> 240.334829440666, 240.178917738469, 239.426516135223, 236.317113267444,
> 234.733216062887, 234.35881561921, 235.381117907399, 235.615542733856,
> 234.548775568325, 233.18005217826, 233.175399168395, 230.830743898638,
> 232.722997839982, 232.178285000985, 232.223089888599, 228.928041632613,
> 230.542523134267, 230.870965189533, 231.808221318154, 231.05403482127,
> 230.320065171877, 230.50478036101, 235.610489258636, 234.426874698792,
> 235.079073675256, 233.668844676483, 235.209438616643, 234.347596336808,
> 235.274837701395, 235.032706411323, 231.35593627654, 230.304829580709,
> 230.18219645205, 231.520362936985, 230.291755953757, 227.520959882671,
> 

Re: [R] Renaming multiple objects

2021-11-20 Thread Jeff Newmiller
Agreed... This Is The Way.

To interactively sit at the R console and type in commands without keeping 
those commands in an editor and running them from scratch periodically to 
insure that they achieve your goals is a only a recipe for mystery, not for 
data analysis.

R is a tool for transforming raw data into i interpretable forms. If you are 
not keeping track of how you used it, how can you convince yourself or others 
that you did it right? And if you are keeping track, then you should feel 
comfortable editing that set of transformation steps so they do the right thing 
the first time.

On November 20, 2021 2:53:05 AM PST, Duncan Murdoch  
wrote:
>On 20/11/2021 5:27 a.m., Steven Yen wrote:
>> I have named NUMEROUS objects (each containing, e.g., 48 obs. of 5
>> variables), such as
>>     mec1.p.emb
>>     mec2.p.emb
>>     meb1.p.emb
>>     meb2.p.emb
>>     mej12.p.emb
>>     mej22.p.emb
>> 
>> How would I rename these objects removing the silly ".emb", into objects
>>     mec1.p
>>     mec2.p
>>     meb1.p
>>     meb2.p
>>     mej12.p
>>     mej22.p
>> 
>
>Use a global search and replace on your source code, and create them 
>with the correct names.
>
>Duncan Murdoch
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Renaming multiple objects

2021-11-20 Thread Rui Barradas

Hello,

You can get all objects to be changed into a list, change the list's 
names attribute and assign back to the globalenv. Something like the 
following.

First see if the objects exist in the global env.

ls()
#[1] "meb1.p.emb"  "meb2.p.emb"  "mec1.p.emb"  "mec2.p.emb"
#[5] "mej12.p.emb" "mej22.p.emb"


Now the code to change their names



# create a vector of names of the objects
# whose names are to be changed
obj_names <- ls(pattern = "\\.emb$")

# this is instruction is not strictly needed
# it's meant to check if the regex works (it does)
sub("\\.emb$", "", obj_names)
#[1] "meb1.p"  "meb2.p"  "mec1.p"  "mec2.p"  "mej12.p" "mej22.p"

# get the objects into a list
tmp_list <- mget(obj_names, envir = .GlobalEnv)
# change the list's names
names(tmp_list) <- sub("\\.emb$", "", obj_names)
# assign them to the global environment
list2env(tmp_list, envir = .GlobalEnv)

# clean up
rm(tmp_list)
rm(list = obj_names)

# check to see if it worked (it did)
ls()
#[1] "meb1.p"  "meb2.p"  "mec1.p"  "mec2.p"  "mej12.p" "mej22.p"


Hope this helps,

Rui Barradas

Às 10:27 de 20/11/21, Steven Yen escreveu:
I have named NUMEROUS objects (each containing, e.g., 48 obs. of 5 
variables), such as

   mec1.p.emb
   mec2.p.emb
   meb1.p.emb
   meb2.p.emb
   mej12.p.emb
   mej22.p.emb

How would I rename these objects removing the silly ".emb", into objects
   mec1.p
   mec2.p
   meb1.p
   meb2.p
   mej12.p
   mej22.p

Thank you!

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] tsmp::find_discord help

2021-11-20 Thread David Katz via R-help
windowSize <- 114L

myData <- c(270.462263440434, 272.664102077857, 269.796430162527,
265.715722218109,
264.406853005756, 265.084587771026, 264.098291489715, 260.43527948116,
258.516029706132, 257.495599873085, 256.301471509598, 257.3508273663,
255.286756542046, 253.920890634228, 252.536181194196, 253.901498621143,
252.488770200592, 253.17373118042, 252.966600656463, 252.703126928303,
253.904283441231, 256.149065587949, 257.487833837001, 257.305445475504,
256.971778599266, 257.031127100531, 258.378144076467, 257.700536692981,
259.294733786397, 257.752154694684, 258.027081468422, 258.08672459079,
258.041715753358, 258.329487642599, 258.299665291887, 258.758197146375,
259.073160554189, 257.290848280257, 256.57958424734, 255.263597775251,
255.428375537274, 254.852562069893, 255.16275117402, 253.104822101118,
252.968454384943, 252.958341056947, 252.413550664159, 252.313035522727,
251.905248262594, 249.840876041166, 250.108495180914, 249.303993972763,
246.963484593993, 248.346250534011, 248.325232558372, 246.80674746288,
247.909455339378, 247.433042791532, 249.402794581885, 249.331976547884,
248.568579055881, 250.594387768302, 251.758252350008, 254.032460428914,
251.686880985135, 253.671777128056, 255.134789754357, 256.064375638822,
253.801672161138, 257.719489656389, 253.966827685572, 255.13559199986,
255.166921377648, 255.962630526721, 257.962603157666, 254.79940264686,
256.855849863449, 255.832325716596, 255.695450823382, 254.736885948759,
251.398771970114, 245.5259580418, 237.715336617082, 232.391882092226,
225.879365097452, 234.597402322106, 227.98504127278, 228.139076301549,
224.173886041436, 226.227280351566, 224.658020137018, 222.056649738085,
223.3202662481, 219.113969733892, 218.391448495584, 218.051289301226,
241.309807159239, 231.913033676054, 246.67008242067, 239.862456006277,
256.373582866136, 258.422042267257, 254.934707124019, 256.099923688313,
253.918253725441, 250.084642761294, 250.806687402073, 253.652116958844,
253.796670716768, 234.682091120398, 231.080911108106, 231.195135810459,
224.727161067631, 223.892852459149, 228.885059227748, 234.11580639,
238.62885521967, 242.106482479768, 243.921211695019, 244.846424317779,
248.432817418315, 252.583033349365, 255.085796192987, 256.980864458624,
258.223037317721, 257.445069981506, 260.982180904737, 262.487198309787,
264.418811357114, 262.814652461885, 260.130595969269, 261.116867189016,
260.834598457301, 261.334277956188, 260.53066947828, 259.745895410888,
261.29109349791, 261.493881158018, 263.980493014213, 262.876190291578,
264.16183147626, 264.804793464811, 262.390942223882, 261.544820740027,
260.380895000463, 261.926068113605, 260.928243354987, 258.966465326864,
260.547825717181, 259.675027847523, 259.435857442394, 256.966581859812,
255.822263459302, 257.62250959808, 255.608143508667, 255.460477147251,
257.430493221805, 256.616983212018, 256.396313681593, 254.89111013636,
253.111957965884, 253.820672287187, 252.568848789204, 250.287826519459,
250.850996744586, 249.534365097154, 249.722974164085, 249.325430105766,
248.004227338824, 248.422241862165, 248.9895549729, 248.515746102668,
247.411875064159, 247.836559468554, 245.499609602103, 242.627764024446,
243.192466861987, 242.535635591811, 240.80014768187, 241.012683392456,
242.48190025622, 240.923248882825, 240.708791351318, 241.933056565281,
240.334829440666, 240.178917738469, 239.426516135223, 236.317113267444,
234.733216062887, 234.35881561921, 235.381117907399, 235.615542733856,
234.548775568325, 233.18005217826, 233.175399168395, 230.830743898638,
232.722997839982, 232.178285000985, 232.223089888599, 228.928041632613,
230.542523134267, 230.870965189533, 231.808221318154, 231.05403482127,
230.320065171877, 230.50478036101, 235.610489258636, 234.426874698792,
235.079073675256, 233.668844676483, 235.209438616643, 234.347596336808,
235.274837701395, 235.032706411323, 231.35593627654, 230.304829580709,
230.18219645205, 231.520362936985, 230.291755953757, 227.520959882671,
227.357653270895, 225.333449562034, 217.811542729707, 227.059990683896,
239.990208812803, 228.059115129057, 228.868406292098, 236.034196653264,
234.17751710834, 237.003069269005, 239.052892482514, 240.428051100904,
240.191306406911, 240.50419596592, 240.901681595389, 237.87181299557,
236.850762880128, 233.509818236437, 231.983081438765, 235.119339047512,
240.263921064651, 244.679595292406, 248.93951106756, 252.122590302397,
258.805282831052, 242.687846377119, 237.204158759257, 243.178667159705,
231.431086514657, 223.708970214007, 221.640786242951, 219.97023160113,
210.878755430737, 179.209233482601, 144.494342460437, 163.888149251789,
186.003606780246, 189.352081675269, 194.529081804026, 196.759613684891,
223.580900584348, 227.607943509612, 218.162016380718, 211.594753752323,
214.163046110841, 215.744377558026, 227.310642507114, 227.799354057526,
227.551336807385, 226.132788368966, 221.52987925848, 218.445829530153,
218.89121471229, 220.106824906403, 224.207053555921, 226.583060863288,
229.061297126161, 231.837136147171, 

[R] tsmp::find_discord failure

2021-11-20 Thread David Katz via R-help
I need help to understand why this fails:

windowSize <- 114L

myData <- c(270.462263440434, 272.664102077857, 269.796430162527,
265.715722218109,
264.406853005756, 265.084587771026, 264.098291489715, 260.43527948116,
258.516029706132, 257.495599873085, 256.301471509598, 257.3508273663,
255.286756542046, 253.920890634228, 252.536181194196, 253.901498621143,
252.488770200592, 253.17373118042, 252.966600656463, 252.703126928303,
253.904283441231, 256.149065587949, 257.487833837001, 257.305445475504,
256.971778599266, 257.031127100531, 258.378144076467, 257.700536692981,
259.294733786397, 257.752154694684, 258.027081468422, 258.08672459079,
258.041715753358, 258.329487642599, 258.299665291887, 258.758197146375,
259.073160554189, 257.290848280257, 256.57958424734, 255.263597775251,
255.428375537274, 254.852562069893, 255.16275117402, 253.104822101118,
252.968454384943, 252.958341056947, 252.413550664159, 252.313035522727,
251.905248262594, 249.840876041166, 250.108495180914, 249.303993972763,
246.963484593993, 248.346250534011, 248.325232558372, 246.80674746288,
247.909455339378, 247.433042791532, 249.402794581885, 249.331976547884,
248.568579055881, 250.594387768302, 251.758252350008, 254.032460428914,
251.686880985135, 253.671777128056, 255.134789754357, 256.064375638822,
253.801672161138, 257.719489656389, 253.966827685572, 255.13559199986,
255.166921377648, 255.962630526721, 257.962603157666, 254.79940264686,
256.855849863449, 255.832325716596, 255.695450823382, 254.736885948759,
251.398771970114, 245.5259580418, 237.715336617082, 232.391882092226,
225.879365097452, 234.597402322106, 227.98504127278, 228.139076301549,
224.173886041436, 226.227280351566, 224.658020137018, 222.056649738085,
223.3202662481, 219.113969733892, 218.391448495584, 218.051289301226,
241.309807159239, 231.913033676054, 246.67008242067, 239.862456006277,
256.373582866136, 258.422042267257, 254.934707124019, 256.099923688313,
253.918253725441, 250.084642761294, 250.806687402073, 253.652116958844,
253.796670716768, 234.682091120398, 231.080911108106, 231.195135810459,
224.727161067631, 223.892852459149, 228.885059227748, 234.11580639,
238.62885521967, 242.106482479768, 243.921211695019, 244.846424317779,
248.432817418315, 252.583033349365, 255.085796192987, 256.980864458624,
258.223037317721, 257.445069981506, 260.982180904737, 262.487198309787,
264.418811357114, 262.814652461885, 260.130595969269, 261.116867189016,
260.834598457301, 261.334277956188, 260.53066947828, 259.745895410888,
261.29109349791, 261.493881158018, 263.980493014213, 262.876190291578,
264.16183147626, 264.804793464811, 262.390942223882, 261.544820740027,
260.380895000463, 261.926068113605, 260.928243354987, 258.966465326864,
260.547825717181, 259.675027847523, 259.435857442394, 256.966581859812,
255.822263459302, 257.62250959808, 255.608143508667, 255.460477147251,
257.430493221805, 256.616983212018, 256.396313681593, 254.89111013636,
253.111957965884, 253.820672287187, 252.568848789204, 250.287826519459,
250.850996744586, 249.534365097154, 249.722974164085, 249.325430105766,
248.004227338824, 248.422241862165, 248.9895549729, 248.515746102668,
247.411875064159, 247.836559468554, 245.499609602103, 242.627764024446,
243.192466861987, 242.535635591811, 240.80014768187, 241.012683392456,
242.48190025622, 240.923248882825, 240.708791351318, 241.933056565281,
240.334829440666, 240.178917738469, 239.426516135223, 236.317113267444,
234.733216062887, 234.35881561921, 235.381117907399, 235.615542733856,
234.548775568325, 233.18005217826, 233.175399168395, 230.830743898638,
232.722997839982, 232.178285000985, 232.223089888599, 228.928041632613,
230.542523134267, 230.870965189533, 231.808221318154, 231.05403482127,
230.320065171877, 230.50478036101, 235.610489258636, 234.426874698792,
235.079073675256, 233.668844676483, 235.209438616643, 234.347596336808,
235.274837701395, 235.032706411323, 231.35593627654, 230.304829580709,
230.18219645205, 231.520362936985, 230.291755953757, 227.520959882671,
227.357653270895, 225.333449562034, 217.811542729707, 227.059990683896,
239.990208812803, 228.059115129057, 228.868406292098, 236.034196653264,
234.17751710834, 237.003069269005, 239.052892482514, 240.428051100904,
240.191306406911, 240.50419596592, 240.901681595389, 237.87181299557,
236.850762880128, 233.509818236437, 231.983081438765, 235.119339047512,
240.263921064651, 244.679595292406, 248.93951106756, 252.122590302397,
258.805282831052, 242.687846377119, 237.204158759257, 243.178667159705,
231.431086514657, 223.708970214007, 221.640786242951, 219.97023160113,
210.878755430737, 179.209233482601, 144.494342460437, 163.888149251789,
186.003606780246, 189.352081675269, 194.529081804026, 196.759613684891,
223.580900584348, 227.607943509612, 218.162016380718, 211.594753752323,
214.163046110841, 215.744377558026, 227.310642507114, 227.799354057526,
227.551336807385, 226.132788368966, 221.52987925848, 218.445829530153,
218.89121471229, 220.106824906403, 224.207053555921, 

[R] problem using tsmp::find_discord

2021-11-20 Thread David Katz via R-help
Error from this try: (data below)

library(tsmp)
mp.obj <- stomp(myData, window_size = windowSize) #ok

find_discord(mp.obj, data=input.dt$MeasurementValue)

## Warning in dist_profile(data, data, nn, window_size = .mp$w, index =
discord_idx) :
##   Warning: Result may be inconsistent if the size of the queries are
different.
## Error in fast_avg_sd(data, window_size) :
##   'window_size' must be at least 2.

Thanks.

Example:

library(tsmp)

myData<-
c(270.462263440434, 272.664102077857, 269.796430162527, 265.715722218109,
264.406853005756, 265.084587771026, 264.098291489715, 260.43527948116,
258.516029706132, 257.495599873085, 256.301471509598, 257.3508273663,
255.286756542046, 253.920890634228, 252.536181194196, 253.901498621143,
252.488770200592, 253.17373118042, 252.966600656463, 252.703126928303,
253.904283441231, 256.149065587949, 257.487833837001, 257.305445475504,
256.971778599266, 257.031127100531, 258.378144076467, 257.700536692981,
259.294733786397, 257.752154694684, 258.027081468422, 258.08672459079,
258.041715753358, 258.329487642599, 258.299665291887, 258.758197146375,
259.073160554189, 257.290848280257, 256.57958424734, 255.263597775251,
255.428375537274, 254.852562069893, 255.16275117402, 253.104822101118,
252.968454384943, 252.958341056947, 252.413550664159, 252.313035522727,
251.905248262594, 249.840876041166, 250.108495180914, 249.303993972763,
246.963484593993, 248.346250534011, 248.325232558372, 246.80674746288,
247.909455339378, 247.433042791532, 249.402794581885, 249.331976547884,
248.568579055881, 250.594387768302, 251.758252350008, 254.032460428914,
251.686880985135, 253.671777128056, 255.134789754357, 256.064375638822,
253.801672161138, 257.719489656389, 253.966827685572, 255.13559199986,
255.166921377648, 255.962630526721, 257.962603157666, 254.79940264686,
256.855849863449, 255.832325716596, 255.695450823382, 254.736885948759,
251.398771970114, 245.5259580418, 237.715336617082, 232.391882092226,
225.879365097452, 234.597402322106, 227.98504127278, 228.139076301549,
224.173886041436, 226.227280351566, 224.658020137018, 222.056649738085,
223.3202662481, 219.113969733892, 218.391448495584, 218.051289301226,
241.309807159239, 231.913033676054, 246.67008242067, 239.862456006277,
256.373582866136, 258.422042267257, 254.934707124019, 256.099923688313,
253.918253725441, 250.084642761294, 250.806687402073, 253.652116958844,
253.796670716768, 234.682091120398, 231.080911108106, 231.195135810459,
224.727161067631, 223.892852459149, 228.885059227748, 234.11580639,
238.62885521967, 242.106482479768, 243.921211695019, 244.846424317779,
248.432817418315, 252.583033349365, 255.085796192987, 256.980864458624,
258.223037317721, 257.445069981506, 260.982180904737, 262.487198309787,
264.418811357114, 262.814652461885, 260.130595969269, 261.116867189016,
260.834598457301, 261.334277956188, 260.53066947828, 259.745895410888,
261.29109349791, 261.493881158018, 263.980493014213, 262.876190291578,
264.16183147626, 264.804793464811, 262.390942223882, 261.544820740027,
260.380895000463, 261.926068113605, 260.928243354987, 258.966465326864,
260.547825717181, 259.675027847523, 259.435857442394, 256.966581859812,
255.822263459302, 257.62250959808, 255.608143508667, 255.460477147251,
257.430493221805, 256.616983212018, 256.396313681593, 254.89111013636,
253.111957965884, 253.820672287187, 252.568848789204, 250.287826519459,
250.850996744586, 249.534365097154, 249.722974164085, 249.325430105766,
248.004227338824, 248.422241862165, 248.9895549729, 248.515746102668,
247.411875064159, 247.836559468554, 245.499609602103, 242.627764024446,
243.192466861987, 242.535635591811, 240.80014768187, 241.012683392456,
242.48190025622, 240.923248882825, 240.708791351318, 241.933056565281,
240.334829440666, 240.178917738469, 239.426516135223, 236.317113267444,
234.733216062887, 234.35881561921, 235.381117907399, 235.615542733856,
234.548775568325, 233.18005217826, 233.175399168395, 230.830743898638,
232.722997839982, 232.178285000985, 232.223089888599, 228.928041632613,
230.542523134267, 230.870965189533, 231.808221318154, 231.05403482127,
230.320065171877, 230.50478036101, 235.610489258636, 234.426874698792,
235.079073675256, 233.668844676483, 235.209438616643, 234.347596336808,
235.274837701395, 235.032706411323, 231.35593627654, 230.304829580709,
230.18219645205, 231.520362936985, 230.291755953757, 227.520959882671,
227.357653270895, 225.333449562034, 217.811542729707, 227.059990683896,
239.990208812803, 228.059115129057, 228.868406292098, 236.034196653264,
234.17751710834, 237.003069269005, 239.052892482514, 240.428051100904,
240.191306406911, 240.50419596592, 240.901681595389, 237.87181299557,
236.850762880128, 233.509818236437, 231.983081438765, 235.119339047512,
240.263921064651, 244.679595292406, 248.93951106756, 252.122590302397,
258.805282831052, 242.687846377119, 237.204158759257, 243.178667159705,
231.431086514657, 223.708970214007, 

Re: [R] Renaming multiple objects

2021-11-20 Thread Duncan Murdoch

On 20/11/2021 5:27 a.m., Steven Yen wrote:

I have named NUMEROUS objects (each containing, e.g., 48 obs. of 5
variables), such as
    mec1.p.emb
    mec2.p.emb
    meb1.p.emb
    meb2.p.emb
    mej12.p.emb
    mej22.p.emb

How would I rename these objects removing the silly ".emb", into objects
    mec1.p
    mec2.p
    meb1.p
    meb2.p
    mej12.p
    mej22.p



Use a global search and replace on your source code, and create them 
with the correct names.


Duncan Murdoch

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Renaming multiple objects

2021-11-20 Thread Steven Yen
I have named NUMEROUS objects (each containing, e.g., 48 obs. of 5 
variables), such as

  mec1.p.emb
  mec2.p.emb
  meb1.p.emb
  meb2.p.emb
  mej12.p.emb
  mej22.p.emb

How would I rename these objects removing the silly ".emb", into objects
  mec1.p
  mec2.p
  meb1.p
  meb2.p
  mej12.p
  mej22.p

Thank you!

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.