Re: [R] Read excel specific column

2022-08-23 Thread Rui Barradas
Hello, The examples below use packages readxl and cellranger. # to read the 1st column of a xlsx file named filename: library(readxl) read_xlsx(filename, range = cellranger::cell_cols("A")) # to read 1st column of all files in filenames_vec # result is a list of data.frames each of them with

Re: [R] Read excel specific column

2022-08-23 Thread Andrew Simmons
I like package openxlsx, with the function openxlsx::read.xlsx() Another common package that people use readxl On Tue., Aug. 23, 2022, 7:51 p.m. Anas Jamshed, wrote: > I have .xlsx files with gene names in first column.How can read and load in > R? > > [[alternative HTML version deleted

[R] Read excel specific column

2022-08-23 Thread Anas Jamshed
I have .xlsx files with gene names in first column.How can read and load in R? [[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

Re: [R] Read fst files

2021-06-09 Thread Jeff Reichman
Wednesday, June 9, 2021 12:56 PM To: r-help@r-project.org <mailto:r-help@r-project.org> Subject: Re: [R] Read fst files read_fst is from the package fst. The fileformat fst uses is a binary format designed to be fast readable. It is a column oriented format and compressed. So, to be

Re: [R] Read fst files

2021-06-09 Thread Duncan Murdoch
On 09/06/2021 1:55 p.m., Jan van der Laan wrote: read_fst is from the package fst. The fileformat fst uses is a binary format designed to be fast readable. It is a column oriented format and compressed. So, to be able to work fst needs access to the file itself and wont accept a file connectio

Re: [R] Read fst files

2021-06-09 Thread Bill Dunlap
wrote: > Jan > > Makes sense. Its just that I often receive large zip files that contain a > variety of file types. > > Jef > > -Original Message- > From: R-help On Behalf Of Jan van der Laan > Sent: Wednesday, June 9, 2021 12:56 PM > To: r-help@r-project.o

Re: [R] Read fst files

2021-06-09 Thread Jeff Newmiller
Reichman wrote: >Jan > >Makes sense. Its just that I often receive large zip files that >contain a variety of file types. > >Jef > >-Original Message- >From: R-help On Behalf Of Jan van der >Laan >Sent: Wednesday, June 9, 2021 12:56 PM >To: r-help@r-pr

Re: [R] Read fst files

2021-06-09 Thread Jeff Reichman
Jan Makes sense. Its just that I often receive large zip files that contain a variety of file types. Jef -Original Message- From: R-help On Behalf Of Jan van der Laan Sent: Wednesday, June 9, 2021 12:56 PM To: r-help@r-project.org Subject: Re: [R] Read fst files read_fst is from

Re: [R] Read fst files

2021-06-09 Thread Jan van der Laan
read_fst is from the package fst. The fileformat fst uses is a binary format designed to be fast readable. It is a column oriented format and compressed. So, to be able to work fst needs access to the file itself and wont accept a file connection as functions like read.table an variants ac

Re: [R] Read fst files

2021-06-09 Thread Duncan Murdoch
On 09/06/2021 9:12 a.m., Jeff Reichman wrote: Duncan Yea that will work. It appears to be related to setting my working dir, for what ever reason neither seem to work (1) knitr::opts_knit$set(root.dir ="~/My_Reference_Library/Regression") # from R Notebook or (2) setwd("C:/Users/reichmaj/Docum

Re: [R] Read fst files

2021-06-09 Thread Jeff Reichman
gression/Datasest.zip", filename = "myFile.fst")) Thank you. I guess just one of those R things Jeff -Original Message- From: Duncan Murdoch Sent: Wednesday, June 9, 2021 7:27 AM To: reichm...@sbcglobal.net; 'Eric Berger' Cc: 'R mailing list' Subject:

Re: [R] Read fst files

2021-06-09 Thread Duncan Murdoch
dealing with fst files ?? From: Eric Berger Sent: Wednesday, June 9, 2021 3:50 AM To: reichm...@sbcglobal.net Cc: R mailing list Subject: Re: [R] Read fst files You are missing the second closing parenthesis. This is what the error message is telling you. On Wed, Jun 9, 2021

Re: [R] Read fst files

2021-06-09 Thread Eric Berger
; > myObject <- read.csv(unz("C:/Users/reichmaj/Documents/My_Reference_Library > /Regression /Dataset.zip", filename = "myFile.csv")) > > > > My only though is I can’t use the two function s together when dealing > with fst files ?? > > > > *From:* Eric B

Re: [R] Read fst files

2021-06-09 Thread Jeff Reichman
myObject <- read.csv(unz("C:/Users/reichmaj/Documents/My_Reference_Library /Regression /Dataset.zip", filename = "myFile.csv")) My only though is I can’t use the two function s together when dealing with fst files ?? From: Eric Berger Sent: Wednesday, June 9, 2021 3:50 AM

Re: [R] Read fst files

2021-06-09 Thread Eric Berger
You are missing the second closing parenthesis. This is what the error message is telling you. On Wed, Jun 9, 2021 at 2:44 AM Jeff Reichman wrote: > R-Help Forum > > > > Anyone know why the following line of code would error out: myObject <- > read_fst(unz("Dataset.zip", filename = "filename.f

[R] Read fst files

2021-06-08 Thread Jeff Reichman
R-Help Forum Anyone know why the following line of code would error out: myObject <- read_fst(unz("Dataset.zip", filename = "filename.fst")) Error: Incomplete expression: filename <- read_fst(unz("Dataset.zip", filename = "filename.fst") I often use similar code with *.csv files in a

Re: [R] Read

2021-02-22 Thread jim holtman
ily be imported > the usual way, including NA values as needed. > > If the person really wants 4 independent vectors of different lengths to > read in, there are plenty of ways to do that and no need to lump them in > this odd format. > > > > -Original Message- >

Re: [R] Read

2021-02-22 Thread Avi Gross via R-help
holtman Sent: Monday, February 22, 2021 9:01 PM To: Jeff Newmiller Cc: r-help@R-project.org (r-help@r-project.org) Subject: Re: [R] Read 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

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

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 d

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

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 col

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 some

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 t

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 co

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

Re: [R] Read shp file

2019-11-21 Thread Michael Hannon
I can't help you locate the .shx file, but the gist of it is that a "shapefile" actually requires a minimum of three files: https://knowledge.autodesk.com/support/autocad-map-3d/learn-explore/caas/sfdcarticles/sfdcarticles/Required-files-that-make-up-a-shapefile.html The .shx file is an index of

[R] Read shp file

2019-11-21 Thread Medic
Help me. pls, to read .shp file. `library("tmaptools") geo <- read_shape("Rom.shp", as.sf = TRUE) This function is deprecated and has been migrated to github.com/mtennekes/oldtmaptools` I have to turn to another function, but I get an unclear message `library(raster) geo <- shapefile ("Rus.shp")

Re: [R] read

2019-08-09 Thread Val
Thank you Jeff! That was so easy command. On Thu, Aug 8, 2019 at 11:06 PM Bert Gunter wrote: > > I stand corrected! > > 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" co

Re: [R] read

2019-08-08 Thread Bert Gunter
I stand corrected! 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 Thu, Aug 8, 2019 at 7:11 PM Jeff Newmiller wrote: > Val 1 > Bert 0 > > On August 8, 2019 5:

Re: [R] read

2019-08-08 Thread Jeff Newmiller
Assuming your actual case is a file containing those characters, your example R string has to quote them. However, it seems like you want to disable interpreting quotes while you read this file. vld<-read.table(text= "name prof A '4.5 B \"3.2 C 5.5 " ,header=TRUE,quote="")

Re: [R] read

2019-08-08 Thread Jeff Newmiller
Val 1 Bert 0 On August 8, 2019 5:22:13 PM PDT, Bert Gunter wrote: >read.table() does not have a "text" argument, so maybe you need to go >back >and go through a tutorial or two to learn R basics (e.g. about function >calls and function arguments ?) >See ?read.table (of course) > >Cheers, > >Bert

Re: [R] read

2019-08-08 Thread Peter Langfelder
I would remove the quotes using sub, something like # Read the file as text lines text = readLines(con = file(yourFileName)) # Remove the offending quotes text = gsub("'|\"", "", text) # Concatenate and turn into a data frame concat = paste(text, collapse = "\n") df = read.table(text = concat, ...

Re: [R] read

2019-08-08 Thread Val
Thank you all, I can read the text file but the problem was there is a single quote embedded in the first row of second column. This quote causes the problem vld<-read.table(text="name prof A '4.5 B "3.2 C 5.5 ",header=TRUE) On Thu, Aug 8, 2019 at 7:24 PM Anaanthan Pilla

Re: [R] read

2019-08-08 Thread Bert Gunter
read.table() does not have a "text" argument, so maybe you need to go back and go through a tutorial or two to learn R basics (e.g. about function calls and function arguments ?) See ?read.table (of course) Cheers, Bert Gunter "The trouble with having an open mind is that people keep coming alo

Re: [R] read

2019-08-08 Thread Anaanthan Pillai
data <- read.table(header=TRUE, text=' name prof A 4.5 B 3.2 C 5.5 ') > On 9 Aug 2019, at 8:11 AM, Val wrote: > > Hi all, > > I am trying to red data where single and double quotes are embedded > in some of the fields and prevented to read the data. As an example > please see be

Re: [R] read

2019-08-08 Thread Thevaraja, Mayooran
g (r-help@r-project.org) Subject: [R] read Hi all, I am trying to red data where single and double quotes are embedded in some of the fields and prevented to read the data. As an example please see below. vld<-read.table(text="name prof A '4.5 B "3.2 C 5.5

[R] read

2019-08-08 Thread Val
Hi all, I am trying to red data where single and double quotes are embedded in some of the fields and prevented to read the data. As an example please see below. vld<-read.table(text="name prof A '4.5 B "3.2 C 5.5 ",header=TRUE) Error in read.table(text = "name prof \n

Re: [R] Read Unicode text (*.txt)

2019-07-02 Thread William Dunlap via R-help
Try changing encoding="UTF-16" to fileEncoding="UTF-16". Bill Dunlap TIBCO Software wdunlap tibco.com On Mon, Jul 1, 2019 at 9:30 PM javad bayat wrote: > Dear all; > I use your suggestion but I gave the same warning messages. I changed the > file name (Data.csv). > " > d4<-read.csv("./Data.csv

Re: [R] Read Unicode text (*.txt)

2019-07-02 Thread Olivier Crouzet
Hi Javad, I could not make sense of the data structure associated with the csv file as it is copied in your previous message. Would you mind sending a link so one can download your csv file directly (or at least the first few lines) so people can check the exact properties of your file? Yours. Ol

Re: [R] Read Unicode text (*.txt)

2019-07-01 Thread javad bayat
Dear all; I use your suggestion but I gave the same warning messages. I changed the file name (Data.csv). " d4<-read.csv("./Data.csv",sep=";",header=TRUE,encoding="UTF-16") Warning messages: 1: In read.table(file = file, header = header, sep = sep, quote = quote, : line 1

Re: [R] Read Unicode text (*.txt)

2019-07-01 Thread William Dunlap via R-help
If I recall correctly, Excel's 'Unicode' used to mean "UTF-16", which R's scan() did not recognize without a hint. The relevant argument is fileEncoding, not encoding. UTF-16 files generally have lots of null bytes and UTF-8 files have no null bytes and if you try to read UTF-16 as UTF-8 you get

Re: [R] Read Unicode text (*.txt)

2019-07-01 Thread Abby Spurdle
> Don't be so US-centric, Abby... how do you know that javad's version of Excel doesn't default to using semicolons? I don't. However, Comma-Separated Values (CSV) are, comma separated, by definition. So, if the files use semicolons, then... Also, the use of the wrong sep="my.delim" argument is

Re: [R] Read Unicode text (*.txt)

2019-07-01 Thread Jeff Newmiller
Don't be so US-centric, Abby... how do you know that javad's version of Excel doesn't default to using semicolons? ?read.csv2 On July 1, 2019 6:06:32 PM PDT, Abby Spurdle wrote: >> I am trying to read an excel CSV file (1.csv). When I read it as csv >file >> in R, the R shows me the exact numbe

Re: [R] Read Unicode text (*.txt)

2019-07-01 Thread Abby Spurdle
> I am trying to read an excel CSV file (1.csv). When I read it as csv file > in R, the R shows me the exact number of row. But it puts all columns in > one column, while I have 3 or 4 columns in the data frame. > d4 = read.table("./4.csv",sep=";",header=TRUE) Firstly, I recommend against naming y

Re: [R] Read Unicode text (*.txt)

2019-07-01 Thread Jim Lemon
Yep, you're right. Jim On Tue, Jul 2, 2019 at 7:52 AM William Dunlap wrote: > > Should that encoding="UTF-8" be encoding="UTF-16"? > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > > On Mon, Jul 1, 2019 at 2:45 PM Jim Lemon wrote: >> >> Hi Javad, >> Unicode characters do have embedded

Re: [R] Read Unicode text (*.txt)

2019-07-01 Thread William Dunlap via R-help
Should that encoding="UTF-8" be encoding="UTF-16"? Bill Dunlap TIBCO Software wdunlap tibco.com On Mon, Jul 1, 2019 at 2:45 PM Jim Lemon wrote: > Hi Javad, > Unicode characters do have embedded nulls. Try this: > > d4<-read.table("./4.csv",sep=";",header=TRUE,encoding="UTF-8") > > Jim > > O

Re: [R] Read Unicode text (*.txt)

2019-07-01 Thread Jim Lemon
Hi Javad, Unicode characters do have embedded nulls. Try this: d4<-read.table("./4.csv",sep=";",header=TRUE,encoding="UTF-8") Jim On Tue, Jul 2, 2019 at 3:47 AM javad bayat wrote: > > Dear R users; > I am trying to read an excel CSV file (1.csv). When I read it as csv file > in R, the R shows m

[R] Read Unicode text (*.txt)

2019-07-01 Thread javad bayat
Dear R users; I am trying to read an excel CSV file (1.csv). When I read it as csv file in R, the R shows me the exact number of row. But it puts all columns in one column, while I have 3 or 4 columns in the data frame. " d4 = read.table("./4.csv",sep=";",header=TRUE) Warning messages: 1:

[R] Read text files with Chinese characters

2018-12-15 Thread Patrick Giraudoux
Dear listers, There is number of requests about reading Chinese characters from Excel or text files. I had to cope with the issue and wrote a small manual about it. It might not be an optimal solution, but at least it works :-) One can download the pdf at: https://chrono-environnement.univ-fco

Re: [R] Read

2018-11-10 Thread Val
Thank you Jeff and all. My data is very messy and it is nice trick suggested by Jeff to handle it On Fri, Nov 9, 2018 at 8:42 PM Jeff Newmiller wrote: > > Your file has 5 commas in the first data row, but only 4 in the header. R > interprets this to mean your first column is intended to be row n

Re: [R] Read

2018-11-10 Thread Ista Zahn
readr::read_csv produces the desired result by default: readr::read_csv("x1,x2,x3,x4,x5 12,13,,14,, 22,23,24,25,26 ,33,34,34,") Best, Ista On Fri, Nov 9, 2018 at 8:40 PM Val wrote: > > HI all, > I am trying to read a csv file, but have a problem in the row names. > After reading, the name of th

Re: [R] Read

2018-11-09 Thread Rui Barradas
Hello, I've just tested Jeff's solution, it works but the second code line should be dsh <- sh[ , -length( sh ) ] (dsh doesn't exist yet.) Hope this helps, Rui Barradas Às 02:46 de 10/11/2018, Jeff Newmiller escreveu: Your file has 5 commas in the first data row, but only 4 in the header.

Re: [R] Read

2018-11-09 Thread Jeff Newmiller
Your file has 5 commas in the first data row, but only 4 in the header. R interprets this to mean your first column is intended to be row names (has no corresponding column label) rather than data. (Row names are "outside" the data frame... use str(dsh) to get a better picture.) Basically, you

[R] Read

2018-11-09 Thread Val
HI all, I am trying to read a csv file, but have a problem in the row names. After reading, the name of the first column is now "row.names" and all other column names are shifted to the right. The value of the last column become all NAs( as an extra column). My sample data looks like as follow, f

Re: [R] read txt file - date - no space

2018-08-02 Thread PIKAL Petr
2, 2018 10:53 AM To: PIKAL Petr ; r-help mailing list Subject: Re: [R] read txt file - date - no space Dear Petr, I have read the file: MyData <- read.csv(file="obs_prec.csv",header=TRUE, sep=",") I have used POSIXct to convert properly the date MyData$date2<-as.P

Re: [R] read txt file - date - no space

2018-08-02 Thread Diego Avesani
not only taught me R but also how to dealwith learning. Can I ask you anover question about aggregate? Again thanks Diego On 2 August 2018 at 10:10, PIKAL Petr wrote: > Hi > > > > *From:* Diego Avesani > *Sent:* Thursday, August 2, 2018 10:03 AM > *To:* PIKAL Pe

Re: [R] read txt file - date - no space

2018-08-02 Thread Diego Avesani
nd please do not post HTML formated messages, it could be > scrammbled) > > > > *From:* Diego Avesani > *Sent:* Thursday, August 2, 2018 8:56 AM > *To:* jim holtman ; PIKAL Petr > > *Cc:* R mailing list > *Subject:* Re: [R] read txt file - date - no space > > >

Re: [R] read txt file - date - no space

2018-08-02 Thread PIKAL Petr
d to POSIX correctly, are some of them NA? Aggregate your values (not by lubridate function day) and store them in another object Cheers Petr From: Diego Avesani Sent: Thursday, August 2, 2018 9:31 AM To: jim holtman ; PIKAL Petr Cc: R mailing list Subject: Re: [R] read txt file - date - no s

Re: [R] read txt file - date - no space

2018-08-02 Thread Diego Avesani
Dear all, I have found and error in the date conversion. Now it looks like: MyData <- read.csv(file="obs_prec.csv",header=TRUE, sep=",") # change date to real MyData$date<-as.POSIXct(MyData$date, format="%*m*/%*d*/%Y %H:%M") After that I apply the PIKAL's suggestions: aggregate(MyData[,-1], lis

Re: [R] read txt file - date - no space

2018-08-02 Thread PIKAL Petr
Hi see in line (and please do not post HTML formated messages, it could be scrammbled) From: Diego Avesani Sent: Thursday, August 2, 2018 8:56 AM To: jim holtman ; PIKAL Petr Cc: R mailing list Subject: Re: [R] read txt file - date - no space Dear I have check the one of the line that

Re: [R] read txt file - date - no space

2018-08-01 Thread Diego Avesani
Dear I have check the one of the line that gives me problem. I mean, which give NA after R processing. I think that is similar to the others: 10/12/1998 10:00,0,0,0 10/12/1998 11:00,0,0,0 10/12/1998 12:00,0,0,0 10/12/1998 13:00,0,0,0 10/12/1998 14:00,0,0,0 10/12/1998 15:00,0,0,0 10/12/1998 16:00,

Re: [R] read txt file - date - no space

2018-08-01 Thread jim holtman
Try this: > library(lubridate) > library(tidyverse) > input <- read.csv(text = "date,str1,str2,str3 + 10/1/1998 0:00,0.6,0,0 + 10/1/1998 1:00,0.2,0.2,0.2 + 10/1/1998 2:00,0.6,0.2,0.4 + 10/1/1998 3:00,0,0,0.6 + 10/1/1998 4:00,0

Re: [R] read txt file - date - no space

2018-08-01 Thread PIKAL Petr
Hi see in line From: Diego Avesani Sent: Wednesday, August 1, 2018 2:30 PM To: PIKAL Petr Cc: r-help mailing list Subject: Re: [R] read txt file - date - no space Dear Pikal, Deal all, again really thank. it seems not working. Some specifications: My non data are -999, but I could change

Re: [R] read txt file - date - no space

2018-08-01 Thread Diego Avesani
attach lubridate >> > library(lubridate) >> >> # aggregate your object(s) and use lubridate function >> >> > aggregate(test[,-1], list(day(test$date)), mean) >> Group.1 str1 str2 str3 >> 1 10 0.2 0.05 0.15 >> >> # or format function >&

Re: [R] read txt file - date - no space

2018-08-01 Thread Diego Avesani
hould post at least result of > > str(yourdata) > > or preferably > > dput(yourdata[1:20,]) > > Cheers > Petr > > > > -Original Message- > > From: R-help On Behalf Of Diego Avesani > > Sent: Wednesday, August 1, 2018 8:55 AM > > To: Jef

Re: [R] read txt file - date - no space

2018-08-01 Thread PIKAL Petr
f Of Diego Avesani > Sent: Wednesday, August 1, 2018 8:55 AM > To: Jeff Newmiller > Cc: r-help mailing list > Subject: Re: [R] read txt file - date - no space > > Dear all, > I am sorry, I did a lot of confusion. I am sorry, I have to relax and stat > all again > i

Re: [R] read txt file - date - no space

2018-07-31 Thread Diego Avesani
Dear all, I am sorry, I did a lot of confusion. I am sorry, I have to relax and stat all again in order to understand. If I could I would like to start again, without mixing strategy and waiting for your advice. I am really appreciate you help, really really. Here my new file, a *.csv file (buy th

Re: [R] read txt file - date - no space

2018-07-31 Thread Jeff Newmiller
... and the most common source of NA values in time data is wrong timezones. You really need to make sure the timezone that is assumed when the character data are converted to POSIXt agrees with the data. In most cases the easiest way to insure this is to use Sys.setenv(TZ="US/Pacific") or wha

Re: [R] read txt file - date - no space

2018-07-31 Thread Jim Lemon
Hi Diego, I think the error is due to NA values in your data file. If I extend your example and run it, I get no errors: MyData<-read.table(text="103001930 103001580 103001530 1998-10-01 00:00:00 0.6 0 0 1998-10-01 01:00:00 0.2 0.2 0.2 1998-10-01 02:00:00 0.6 0.2 0.4 1998-10-01 03:00:00 0 0 0.6 19

Re: [R] read txt file - date - no space

2018-07-31 Thread Diego Avesani
Dear all, I have still problem with date. Could you please tel me how to use POSIXct. Indeed I have found this command: timeAverage, but I am not able to convert MyDate to properly date. Thank a lot I hope to no bother you, at least too much Diego On 31 July 2018 at 11:12, Diego Avesani wrot

Re: [R] read txt file - date - no space

2018-07-31 Thread Diego Avesani
Dear Jim, Dear all, thanks a lot. Unfortunately, I get the following error: st1_daily<-by(MyData$st1,MyData$date,mean)Error in tapply(seq_len(0L), list(`MyData$date` = c(913L, 914L, 925L, : arguments must have same length This is particularly strange. indeed, if I apply mean(MyData$str1

Re: [R] read txt file - date - no space

2018-07-31 Thread Diego Avesani
Dear all, I have found the error, my fault. Sorry. There was an extra come in the headers line. Thanks again. If I can I would like to ask you another questions about the imported data. I would like to compute the daily average of the different date. Basically I have hourly data, I would like to a

Re: [R] read txt file - date - no space

2018-07-31 Thread Diego Avesani
Dear all, I move to csv file because originally the date where in csv file. In addition, due to the fact that, as you told me, read.csv is a special case of read.table, I prefer start to learn from the simplest one. After that, I will try also the *.txt format. with read.csv, something strange hap

Re: [R] read txt file - date - no space

2018-07-31 Thread Jim Lemon
Hi Diego, One way you can get daily means is: st1_daily<-by(MyData$st1,MyData$date,mean) st2_daily<-by(MyData$st2,MyData$date,mean) st3_daily<-by(MyData$st3,MyData$date,mean) Jim On Tue, Jul 31, 2018 at 6:51 PM, Diego Avesani wrote: > Dear all, > I have found the error, my fault. Sorry. > There

Re: [R] read txt file - date - no space

2018-07-30 Thread MacQueen, Don via R-help
Or, without removing the first line dadf <- read.table("xxx.txt", stringsAsFactors=FALSE, skip=1) Another alternative, dadf$datetime <- as.POSIXct(paste(dadf$V1,dadf$V2)) since the dates appear to be in the default format. (I generally prefer to work with datetimes in POSIXct class rather tha

Re: [R] read txt file - date - no space

2018-07-30 Thread Jim Lemon
Hi Diego, You may have to do some conversion as you have three fields in the first line using the default space separator and five fields in subsequent lines. If the first line doesn't contain any important data you can just delete it or replace it with a meaningful header line with five fields and

Re: [R] read txt file - date - no space

2018-07-30 Thread Jeff Newmiller
1) No. 2) The read.csv function is a s special case use of the more general read.table function that can handle any simple field separator. 3) Read the data in as character (I recommend using the stringsAsFactors=FALSE argument to read.table) and convert to an appropriate type from that form.

[R] read txt file - date - no space

2018-07-30 Thread Diego Avesani
Dear all, I am dealing with the reading of a *.txt file. The txt file the following shape: 103001930 103001580 103001530 1998-10-01 00:00:00 0.6 0 0 1998-10-01 01:00:00 0.2 0.2 0.2 1998-10-01 02:00:00 0.6 0.2 0.4 1998-10-01 03:00:00 0 0 0.6 1998-10-01 04:00:00 0 0 0 1998-10-01 05:00:00 0 0 0 1998

Re: [R] Read in data table, change columns from factors [RESOLVED]

2018-07-19 Thread Rich Shepard
On Thu, 19 Jul 2018, David Winsemius wrote: You can use format to only display the time portion of a datetime object. format( Sys.time(), "%H:%M") [1] "13:57" You can append the current date to a "time-only" character value and as.POSIXct will do that for you: as.POSIXct("00:00", format="%H:%M"

Re: [R] Read in data table, change columns from factors [RESOLVED]

2018-07-19 Thread David Winsemius
> On Jul 19, 2018, at 1:21 PM, Rich Shepard wrote: > > On Thu, 19 Jul 2018, David Winsemius wrote: > >> I took the code that I offered earlier and replaced allyears with wy2018: > >> date timeelev myDate myTime >> 1 2017-10-01 00:00 290.298 2017-10-01 2017-10-01 00

Re: [R] Read in data table, change columns from factors [RESOLVED]

2018-07-19 Thread Rich Shepard
On Thu, 19 Jul 2018, David Winsemius wrote: I took the code that I offered earlier and replaced allyears with wy2018: date timeelev myDate myTime 1 2017-10-01 00:00 290.298 2017-10-01 2017-10-01 00:00:00 2 2017-10-01 00:30 290.301 2017-10-01 2017-10-01 00:30:00 3

Re: [R] Read in data table, change columns from factors

2018-07-19 Thread David Winsemius
> On Jul 19, 2018, at 12:33 PM, Rich Shepard wrote: > > On Thu, 19 Jul 2018, Rich Shepard wrote: > >> I have the date and elev columns converted from factors to date and >> numeric, respectively, but still have not learned how to convert the time. > > With this dataframe structure, > > str(

Re: [R] Read in data table, change columns from factors

2018-07-19 Thread David Winsemius
> On Jul 19, 2018, at 10:02 AM, Rich Shepard wrote: > > On Thu, 19 Jul 2018, Rich Shepard wrote: > >> Since then I reformatted the file to two fields: date-time and elevation. >> If anyone wants a copy send me a message off the list and I'll respond with >> the modified file attached. > > Th

Re: [R] Read in data table, change columns from factors

2018-07-19 Thread Rich Shepard
On Thu, 19 Jul 2018, Rich Shepard wrote: I have the date and elev columns converted from factors to date and numeric, respectively, but still have not learned how to convert the time. With this dataframe structure, str(wy2018) 'data.frame': 12592 obs. of 3 variables: $ date: Date, forma

Re: [R] Read in data table, change columns from factors

2018-07-19 Thread Rich Shepard
On Thu, 19 Jul 2018, Rich Shepard wrote: Since then I reformatted the file to two fields: date-time and elevation. If anyone wants a copy send me a message off the list and I'll respond with the modified file attached. This is a mistake. The file needs commas separating each field. I have

Re: [R] Read in data table, change columns from factors

2018-07-19 Thread Rich Shepard
On Thu, 19 Jul 2018, Rich Shepard wrote: I put a zipped data file at this URL: Since then I reformatted the file to two fields: date-time and elevation. If anyone wants a copy send me a message off the list a

Re: [R] Read in data table, change columns from factors

2018-07-19 Thread Rich Shepard
On Wed, 18 Jul 2018, Rich Shepard wrote: If you would suggest how many would be an acceptably large number I'll be happy to put that on a 'cloud' sharing site and provide the URL to it. I put a zipped data file at this URL:

Re: [R] Read in data table, change columns from factors

2018-07-18 Thread Rich Shepard
On Wed, 18 Jul 2018, David Winsemius wrote: It's not so much as factors but rather in a form that paste() will coerce to character so you cna get the automatic format David, Now I understand. Maybe you need to add a format string. It might force some of your pasted date+time values to NA

Re: [R] Read in data table, change columns from factors

2018-07-18 Thread David Winsemius
> On Jul 18, 2018, at 4:07 PM, Rich Shepard wrote: > > On Wed, 18 Jul 2018, David Winsemius wrote: > >> I would not destroy the possibility of using the original values: > > David, > > What are the benefits of keeping date and time as factors? > >>> allyears$myDate <- as.Date(as.character(

Re: [R] Read in data table, change columns from factors

2018-07-18 Thread Rich Shepard
On Wed, 18 Jul 2018, David Winsemius wrote: I would not destroy the possibility of using the original values: David, What are the benefits of keeping date and time as factors? allyears$myDate <- as.Date(as.character(allyears$date)) allyears$myTime <- as.POSIXct(paste(allyears$date, allyea

Re: [R] Read in data table, change columns from factors

2018-07-18 Thread David Winsemius
> On Jul 18, 2018, at 2:50 PM, Rich Shepard wrote: > > A set of data files have this format: > > date,time,elev > 1988-10-01,00:30,87.6849 > 1988-10-01,01:00,87.6849 > 1988-10-01,01:30,87.6849 > 1988-10-01,02:00,87.6879 > 1988-10-01,02:30,87.6879 > 1988-10-01,03:00,87.691 > 1988-10-01,03:30,8

[R] Read in data table, change columns from factors

2018-07-18 Thread Rich Shepard
A set of data files have this format: date,time,elev 1988-10-01,00:30,87.6849 1988-10-01,01:00,87.6849 1988-10-01,01:30,87.6849 1988-10-01,02:00,87.6879 1988-10-01,02:30,87.6879 1988-10-01,03:00,87.691 1988-10-01,03:30,87.694 Importing it with this command: allyears <- read.table('allyears.da

Re: [R] read .asc from web into R

2018-06-03 Thread David Winsemius
> On Jun 3, 2018, at 6:52 AM, Qian Yiting wrote: > > Hi All, > > I am new to R. To import data with .asc ending from the web into R, I have > tried many functions for importing data but it came out not well. The > problem may seem to be very basic but unfortunately I haven’t found any >

Re: [R] read .asc from web into R

2018-06-03 Thread Jeff Newmiller
Have you tried that url in a web browser? I encountered an access permission error. If you also encountered an error, then so would R. You need to download the file using appropriate access credentials (typ. through a web browser) and read it from disk. FWIW the ".asc" extension is very nearly

[R] read .asc from web into R

2018-06-03 Thread Qian Yiting
Hi All, I am new to R. To import data with .asc ending from the web into R, I have tried many functions for importing data but it came out not well. The problem may seem to be very basic but unfortunately I haven’t found any useful information somehow. Which command should I use for that pur

Re: [R] read list of binary files and explore them

2017-04-29 Thread Boris Steipe
emails > > Ragia > > > > > > From: Bert Gunter > Sent: Saturday, April 29, 2017 4:45 PM > To: Ragia .; R-help > Subject: Re: [R] read list of binary files and explore them > > 1. Unless your comment is OT or personal, always reply to the list. > > 2

Re: [R] read list of binary files and explore them

2017-04-29 Thread Bert Gunter
numbers, is there a way to be sure that I am reading > it correctly? what I know is not more than its float content . > > > Ribrahim > > > > > -- > *From:* Bert Gunter > *Sent:* Saturday, April 29, 2017 6:31 AM > *To:* Ragia . >

  1   2   3   4   5   6   7   >