How to extract information from the following dataset?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to extract information from the following dataset?

Xin Zhang-2
Hi all,

I have never worked with this kind of data before, so Please help me out
with it.
I have the following data set, in a csv file, looks like the following:

Jan 27, 2010  16:01:24,000 125 - - -
Jan 27, 2010  16:06:24,000 125 - - -
Jan 27, 2010  16:11:24,000 176 - - -
Jan 27, 2010  16:16:25,000 159 - - -
Jan 27, 2010  16:21:25,000 142 - - -
Jan 27, 2010  16:26:24,000 142 - - -
Jan 27, 2010  16:31:24,000 125 - - -
Jan 27, 2010  16:36:24,000 125 - - -
Jan 27, 2010  16:41:24,000 125 - - -
Jan 27, 2010  16:46:24,000 125 - - -
Jan 27, 2010  16:51:24,000 125 - - -
Jan 27, 2010  16:56:24,000 125 - - -
Jan 27, 2010  17:01:24,000 157 - - -
Jan 27, 2010  17:06:24,000 172 - - -
Jan 27, 2010  17:11:25,000 142 - - -
Jan 27, 2010  17:16:24,000 125 - - -
Jan 27, 2010  17:21:24,000 125 - - -
Jan 27, 2010  17:26:24,000 125 - - -
Jan 27, 2010  17:31:24,000 125 - - -
Jan 27, 2010  17:36:24,000 125 - - -
Jan 27, 2010  17:41:24,000 125 - - -
Jan 27, 2010  17:46:24,000 125 - - -
Jan 27, 2010  17:51:24,000 125 - - -
......

The first few columns are month, day, year, time with OS3 accuracy. And the
last number is the measurement I need to extract.
I wonder if there is a easy way to just take out the measurements only from
a specific day and hour, i.e. if I want measurements from Jan 27 2010
16:--:--
then I get 125,125,176,159,142,142,125,125,125,125,125,125.
Many thanks!!

--
Xin Zhang
Ph.D Candidate
Department of Statistics
University of California, Riverside

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
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.
Reply | Threaded
Open this post in threaded view
|

Re: How to extract information from the following dataset?

Jose-Marcio Martins da Cruz
Xin Zhang wrote:

> Hi all,
>
> I have never worked with this kind of data before, so Please help me out
> with it.
> I have the following data set, in a csv file, looks like the following:
>
> Jan 27, 2010  16:01:24,000 125 - - -
> Jan 27, 2010  16:06:24,000 125 - - -
> Jan 27, 2010  16:11:24,000 176 - - -
> Jan 27, 2010  16:16:25,000 159 - - -
> Jan 27, 2010  16:21:25,000 142 - - -
> Jan 27, 2010  16:26:24,000 142 - - -
> Jan 27, 2010  16:31:24,000 125 - - -
> Jan 27, 2010  16:36:24,000 125 - - -
> Jan 27, 2010  16:41:24,000 125 - - -
> Jan 27, 2010  16:46:24,000 125 - - -
> Jan 27, 2010  16:51:24,000 125 - - -
> Jan 27, 2010  16:56:24,000 125 - - -
> Jan 27, 2010  17:01:24,000 157 - - -
> Jan 27, 2010  17:06:24,000 172 - - -
> Jan 27, 2010  17:11:25,000 142 - - -
> Jan 27, 2010  17:16:24,000 125 - - -
> Jan 27, 2010  17:21:24,000 125 - - -
> Jan 27, 2010  17:26:24,000 125 - - -
> Jan 27, 2010  17:31:24,000 125 - - -
> Jan 27, 2010  17:36:24,000 125 - - -
> Jan 27, 2010  17:41:24,000 125 - - -
> Jan 27, 2010  17:46:24,000 125 - - -
> Jan 27, 2010  17:51:24,000 125 - - -
> ......
>
> The first few columns are month, day, year, time with OS3 accuracy. And the
> last number is the measurement I need to extract.
> I wonder if there is a easy way to just take out the measurements only from
> a specific day and hour, i.e. if I want measurements from Jan 27 2010
> 16:--:--
> then I get 125,125,176,159,142,142,125,125,125,125,125,125.
> Many thanks!!

The easiest is in the shell, if you're using some flavour of unix :

grep "Jan 27, 2010  16" filein.txt | awk '{print $5}' > fileout.txt

and use fileout which will contain only the column of data you want.

>

--

______________________________________________
[hidden email] mailing list
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.
Reply | Threaded
Open this post in threaded view
|

Re: How to extract information from the following dataset?

Mike Marchywka












----------------------------------------

> Date: Thu, 12 May 2011 10:43:59 +0200
> From: [hidden email]
> To: [hidden email]
> CC: [hidden email]
> Subject: Re: [R] How to extract information from the following dataset?
>
> Xin Zhang wrote:
> > Hi all,
> >
> > I have never worked with this kind of data before, so Please help me out
> > with it.
> > I have the following data set, in a csv file, looks like the following:
> >
> > Jan 27, 2010 16:01:24,000 125 - - -
> > Jan 27, 2010 16:06:24,000 125 - - -
> > Jan 27, 2010 16:11:24,000 176 - - -
> > Jan 27, 2010 16:16:25,000 159 - - -
> > Jan 27, 2010 16:21:25,000 142 - - -
> > Jan 27, 2010 16:26:24,000 142 - - -
> > Jan 27, 2010 16:31:24,000 125 - - -
> > Jan 27, 2010 16:36:24,000 125 - - -
> > Jan 27, 2010 16:41:24,000 125 - - -
> > Jan 27, 2010 16:46:24,000 125 - - -
> > Jan 27, 2010 16:51:24,000 125 - - -
> > Jan 27, 2010 16:56:24,000 125 - - -
> > Jan 27, 2010 17:01:24,000 157 - - -
> > Jan 27, 2010 17:06:24,000 172 - - -
> > Jan 27, 2010 17:11:25,000 142 - - -
> > Jan 27, 2010 17:16:24,000 125 - - -
> > Jan 27, 2010 17:21:24,000 125 - - -
> > Jan 27, 2010 17:26:24,000 125 - - -
> > Jan 27, 2010 17:31:24,000 125 - - -
> > Jan 27, 2010 17:36:24,000 125 - - -
> > Jan 27, 2010 17:41:24,000 125 - - -
> > Jan 27, 2010 17:46:24,000 125 - - -
> > Jan 27, 2010 17:51:24,000 125 - - -
> > ......
> >
> > The first few columns are month, day, year, time with OS3 accuracy. And the
> > last number is the measurement I need to extract.
> > I wonder if there is a easy way to just take out the measurements only from
> > a specific day and hour, i.e. if I want measurements from Jan 27 2010
> > 16:--:--
> > then I get 125,125,176,159,142,142,125,125,125,125,125,125.
> > Many thanks!!
>
> The easiest is in the shell, if you're using some flavour of unix :
>
> grep "Jan 27, 2010 16" filein.txt | awk '{print $5}' > fileout.txt
>
> and use fileout which will contain only the column of data you want.
>
Nomrally that is what I do but the R POSIXct features work pretty easily.
I guess I'd use bash text processing commands to put the data into a
form you like, perhaps "y-mo-day time " and then read it in in as data frame.
Usually I convert everything to "time since epoch began" because I like integers
but there are some facilities here like "round" that work well with date-times.

> dx<-as.POSIXct("2011-04-03 13:14:15")
> dx
[1] "2011-04-03 13:14:15 CDT"
> round(dx,"hour")
[1] "2011-04-03 13:00:00 CDT"
> as.integer(dx)
[1] 1301854455
>

     
______________________________________________
[hidden email] mailing list
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.
Reply | Threaded
Open this post in threaded view
|

Re: How to extract information from the following dataset?

hwright
In reply to this post by Xin Zhang-2
<quote author="Xin Zhang-2">
I have the following data set, in a csv file, looks like the following:

Jan 27, 2010  16:01:24,000 125 - - -
Jan 27, 2010  16:06:24,000 125 - - -
......
The first few columns are month, day, year, time with OS3 accuracy. And the
last number is the measurement I need to extract.
I wonder if there is a easy way to just take out the measurements only from
a specific day and hour
--
Xin Zhang
Ph.D Candidate
Department of Statistics
University of California, Riverside
-------------------------------------------------------------------

I use strptime to configure the date format in my times series dataset.
First check to see how the dates are read.
For example:
# check the structure
str(your_file)
'data.frame' ...etc
This tells me that my original date is a factor but not in POSIXlt format.

#check your column dates
head(your_file)
[1] "1984-01-26" "1984-02-09" "1984-03-01" "1984-03-15" "1984-03-29" "1984-04-12"
These are discrete column dates.

#convert your date format
your_file$date<- strptime(your_file$date,"%m/%d/%Y")
call ?strptime for options

Example:
For a specific day or hour, strptime would utilize:
strptime(your_file$date,"%d/%I") for day and hour.

Once you extract the type of date format you want, run str(your_file) again to confirm the format change.
Does this answer your question?
Best,

-----------------------------
Heather A. Wright
heather.wright@maine.edu
@hawright14
Reply | Threaded
Open this post in threaded view
|

Re: How to extract information from the following dataset?

John Kane-2
? subset  day = x time > y | time < z

--- On Thu, 5/12/11, hwright <[hidden email]> wrote:

> From: hwright <[hidden email]>
> Subject: Re: [R] How to extract information from the following dataset?
> To: [hidden email]
> Received: Thursday, May 12, 2011, 6:18 AM
>
> I have the following data set, in a csv file, looks like
> the following:
>
> Jan 27, 2010  16:01:24,000 125 - - -
> Jan 27, 2010  16:06:24,000 125 - - -
> ......
> The first few columns are month, day, year, time with OS3
> accuracy. And the
> last number is the measurement I need to extract.
> I wonder if there is a easy way to just take out the
> measurements only from
> a specific day and hour
> --
> Xin Zhang
> Ph.D Candidate
> Department of Statistics
> University of California, Riverside
> -------------------------------------------------------------------
>
> I use strptime to configure the date format in my times
> series dataset.
> First check to see how the dates are read.
> For example:
> # check the structure
> str(your_file)
> 'data.frame' ...etc
> This tells me that my original date is a factor but not in
> POSIXlt format.
>
> #check your column dates
> head(your_file)
> [1] "1984-01-26" "1984-02-09" "1984-03-01" "1984-03-15"
> "1984-03-29"
> "1984-04-12"
> These are discrete column dates.
>
> #convert your date format
> your_file$date<- strptime(your_file$date,"%m/%d/%Y")
> call ?strptime for options
>
> Example:
> For a specific day or hour, strptime would utilize:
> strptime(your_file$date,"%d/%I") for day and hour.
>
> Once you extract the type of date format you want, run
> str(your_file) again
> to confirm the format change.
> Does this answer your question?
> Best,
>
>
>
> -----
> -------------------------------
> Heather A. Wright, PhD candidate
> Ecology and Evolution of Plankton
> Stazione Zoologica Anton Dohrn
> Villa Comunale
> 80121 - Napoli, Italy
> --
> View this message in context: http://r.789695.n4.nabble.com/How-to-extract-information-from-the-following-dataset-tp3516752p3516952.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email]
> mailing list
> 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.
>

______________________________________________
[hidden email] mailing list
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.