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

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 > >

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 Gun

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

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:

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

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.Da

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.34

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 confide

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 b

[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 = FA

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 t

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 transformin

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" "me

[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,

[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.2867565

[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 o

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

[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