Re: [R] strptime, date and conversion of week number into POSIX

2021-02-22 Thread PIKAL Petr
Hallo Patrick I found quite usefull for working with weeks package ISOweek https://cran.r-project.org/web/packages/ISOweek/index.html Cheers. Petr > -Original Message- > From: R-help On Behalf Of Patrick > Giraudoux > Sent: Monday, February 22, 2021 5:24 PM > To: Uwe Ligges ; R mailing

Re: [R] Read

2021-02-22 Thread jim holtman
This gives the desired output: > library(tidyverse) > text <- "x1 x2 x3 x4\n1 B12 \n2 C23 \n322 B32 D34 \n4 > D44 \n51 D53\n60 D62 " > > # read in the data as characters and split to a list > input <- str_split(str_trim(read_lines(text)), ' +') > > max_cols

Re: [R] Read

2021-02-22 Thread Avi Gross via R-help
This discussion is a bit weird so can we step back. Someone wants help on how to read in a file that apparently was not written following one of several consistent sets of rules. If it was fixed width, R has functions that can read that. If it was separated by commas, tabs, single spaces,

Re: [R] Read

2021-02-22 Thread jim holtman
It looks like we can look at the last digit of the data and that would be the column number; is that correct? Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. Jim Holtman Data Munger Guru What is the problem

Re: [R] Read

2021-02-22 Thread Jeff Newmiller
This gets it into a data frame. If you know which columns should be numeric you can convert them. s <- "x1 x2 x3 x4 1 B22 2 C33 322 B22 D34 4 D44 51 D53 60 D62 " tc <- textConnection( s ) lns <- readLines(tc) close(tc) if ( "" == lns[ length(

Re: [R] Read

2021-02-22 Thread Val
Let us take the max space is two and the output should not be fixed filed but preferable a csv file. On Mon, Feb 22, 2021 at 8:05 PM jim holtman wrote: > > Messed up did not see your 'desired' output which will be hard since there is > not a consistent number of spaces that would represent the

Re: [R] Read

2021-02-22 Thread jim holtman
Messed up did not see your 'desired' output which will be hard since there is not a consistent number of spaces that would represent the desired column number. Do you have any hit as to how to interpret the spacing especially you have several hundred more lines? Is the output supposed to the

Re: [R] Read

2021-02-22 Thread jim holtman
Try this: > library(tidyverse) > text <- "x1 x2 x3 x4\n1 B12 \n2 C23 \n322 B32 D34 \n4 D44 \n51 D53\n60 D62 " > # read in the data as characters and replace multiple blanks with single blank > input <- read_lines(text) > input <- str_replace_all(input, ' +', ' ')

Re: [R] Read

2021-02-22 Thread Val
That is my problem. The spacing between columns is not consistent. It may be single space or multiple spaces (two or three). On Mon, Feb 22, 2021 at 6:14 PM Bill Dunlap wrote: > > You said the column values were separated by space characters. > Copying the text from gmail shows that some

Re: [R] Read

2021-02-22 Thread Bill Dunlap
You said the column values were separated by space characters. Copying the text from gmail shows that some column names and column values are separated by single spaces (e.g., between x1 and x2) and some by multiple spaces (e.g., between x3 and x4. Did the mail mess up the spacing or is there

Re: [R] Read

2021-02-22 Thread Val
I Tried that one and it did not work. Please see the error message Error in read.table(text = "x1 x2 x3 x4\n1 B12 \n2 C23 \n322 B32 D34 \n4D44 \n51 D53\n60 D62 ", : more columns than column names On Mon, Feb 22, 2021 at 5:39 PM Bill Dunlap wrote: > > Since

Re: [R] Read

2021-02-22 Thread Bill Dunlap
Since the columns in the file are separated by a space character, " ", add the read.table argument sep=" ". -Bill On Mon, Feb 22, 2021 at 2:21 PM Val wrote: > > Hi all, I am trying to read a messy data but facing difficulty. The > data has several columns separated by blank space(s). Each

Re: [R] Is it Possible to Create S4 Function Objects?

2021-02-22 Thread /əˈbi/
Oh wow. Post of the year! Where's the like button? Note, I was able to rewrite it without the deprecated args. (Don't want one of those CRAN emails, in 12 months from now, saying please change ). I'll have to come back to this later, to see if I can get the body of f() to access the slot

[R] Read

2021-02-22 Thread Val
Hi all, I am trying to read a messy data but facing difficulty. The data has several columns separated by blank space(s). Each column value may have different lengths across the rows. The first row(header) has four columns. However, each row may not have the four column values. For

Re: [R] xyplot.zoo trouble with the index when I use microseconds (type POSIXct)

2021-02-22 Thread Laurent Rhelp
yes, good idea, eventually here's what I will do: time(DF.w) <- as.POSIXlt(time(DF.w))$sec myticks <- round(pretty(time(DF.w)),6) mylabels <- as.character(formatC(myticks,format = "f",digits=6,width=9,flag=" ")) xyplot(  DF.w  , xlab = paste0("Seconds from ",format(mystart,"%Y-%m-%d

Re: [ESS] Difficulty installing ESS from MELPA

2021-02-22 Thread Woody Setzer via ESS-help
Try changing your repository from Melpa to Melpa-stable: (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/;) t) I had a similar problem after a recent update of ESS in MELPA, but after I deleted ESS and reinstalled from melpa-stable, everything

Re: [R] xyplot.zoo trouble with the index when I use microseconds (type POSIXct)

2021-02-22 Thread Gabor Grothendieck
Also, it might be better to simply use seconds as the time. In that case both plot and xyplot run without error. time(DF.w) <- as.POSIXlt(time(DF.w))$sec # now run plot or xyplot as before On Mon, Feb 22, 2021 at 11:56 AM Gabor Grothendieck wrote: > > I assume that this is a lattice problem.

Re: [R] xyplot.zoo trouble with the index when I use microseconds (type POSIXct)

2021-02-22 Thread Laurent Rhelp
Le 22/02/2021 à 18:32, Gabor Grothendieck a écrit : P.S. screen= is recycled so screen=1 would be sufficient. ok thank you. I will write my axis command. Best Regards On Mon, Feb 22, 2021 at 12:31 PM Gabor Grothendieck wrote: You can use the xaxt = "n" argument to plot.zoo to suppress

Re: [R] xyplot.zoo trouble with the index when I use microseconds (type POSIXct)

2021-02-22 Thread Laurent Rhelp
Le 22/02/2021 à 18:01, Deepayan Sarkar a écrit : On Mon, Feb 22, 2021 at 9:56 PM Laurent Rhelp wrote: Dear R-Help-List, I have to process time series with a sampling frequency of 1 MHz. I use the POSIXct format for the date-times with microsecond in a zoo object and the xyplot.zoo

Re: [R] xyplot.zoo trouble with the index when I use microseconds (type POSIXct)

2021-02-22 Thread Deepayan Sarkar
On Mon, Feb 22, 2021 at 9:56 PM Laurent Rhelp wrote: > > Dear R-Help-List, > > I have to process time series with a sampling frequency of 1 MHz. > I use the POSIXct format for the date-times with microsecond in a zoo > object and the xyplot.zoo function to do the graphs. > As I show in the

Re: [R] xyplot.zoo trouble with the index when I use microseconds (type POSIXct)

2021-02-22 Thread Gabor Grothendieck
I assume that this is a lattice problem. Replacing xyplot with plot and using all the same arguments there is no error. On Mon, Feb 22, 2021 at 11:26 AM Laurent Rhelp wrote: > > Dear R-Help-List, > > I have to process time series with a sampling frequency of 1 MHz. > I use the POSIXct

Re: [R] strptime, date and conversion of week number into POSIX

2021-02-22 Thread Uwe Ligges
That monday does not exist. FOr the week before: strptime(paste0("2020-52","-1"),format="%Y-%W-%u") [1] "2020-12-28" One week later is no longer in 2020, so there is no 53th week. Best, Uwe Ligges On 22.02.2021 16:15, Patrick Giraudoux wrote: Sorry to answer to myself, but the format was

Re: [R] strptime, date and conversion of week number into POSIX

2021-02-22 Thread Patrick Giraudoux
Thanks Uwe and  Bert, I got the essential now, and can manage. Date handling stays quite a challenge with a variable number of weeks in a year, but I can understand why. Means eye-control (or NA detection) of strptime conversion stays necessary... Best, Patrick Le 22/02/2021 à 17:09, Uwe

[R] xyplot.zoo trouble with the index when I use microseconds (type POSIXct)

2021-02-22 Thread Laurent Rhelp
Dear R-Help-List,    I have to process time series with a sampling frequency of 1 MHz. I use the POSIXct format for the date-times with microsecond in a zoo object and the xyplot.zoo function to do the graphs. As I show in the below example I had a trouble to plot the labels on the x-axis with

Re: [R] strptime, date and conversion of week number into POSIX

2021-02-22 Thread Bert Gunter
I think the relevant info from ?strptime is: "For strptime the input string need not specify the date completely: it is assumed that unspecified seconds, minutes or hours are zero, and an unspecified year, month or day is the current one. (However, if a month is specified, the day of that month

Re: [R] error in Rstudio

2021-02-22 Thread Duncan Murdoch
On 22/02/2021 10:01 a.m., Κυριάκος Γιαλλουράκης wrote: Greetings, I tried to open R-studio(windows 10 pro) but instead of running the app, my screen opens a window saying 'loadlibrary failed with error 1114: some preparation routine of a DLL failed' I deleted both R and R-studio, but when I

[R] error in Rstudio

2021-02-22 Thread Κυριάκος Γιαλλουράκης
Greetings, I tried to open R-studio(windows 10 pro) but instead of running the app, my screen opens a window saying 'loadlibrary failed with error 1114: some preparation routine of a DLL failed' I deleted both R and R-studio, but when I downloaded them again(both in latest edition), the same thing

Re: [R] strptime, date and conversion of week number into POSIX

2021-02-22 Thread Patrick Giraudoux
Sorry to answer to myself, but the format was clearly incorrect in the previous post. It should read, refering to the 1th day of the week: strptime(paste0(mydate,"-1"),format="%Y-%W-%u") It converts better, but with a NA on week 53 > strptime(paste0(pays$year_week,"-1"),format="%Y-%W-%u")

[R] strptime, date and conversion of week number into POSIX

2021-02-22 Thread Patrick Giraudoux
Dear all, I have a trouble trying to convert dates  given in character to POSIX. The date is expressed as a year then the week number e.g. "2020-01" (first week of 2020). I thought is can be converted as following: strptime(mydate,format="%Y-%W") %W refering to the week of the year as decimal