[R] Data Parameter extract

Joshua Wiley jwiley.psych at gmail.com
Fri Oct 15 06:07:21 CEST 2010


Hi Joe,

Just to follow up David's advice a bit (and it is excellent
advice...there was an instance where a poster only got a response
because he or she used dput()).  One sticky point for you might be how
to apply a function that finds the minimum to each day individually.
David showed you a nice way to do this, but you might be stuck because
Time includes hours (which you don't want).  Here is an option to
strip off the hours, convert time to a factor (one level for each
day), and find the min (a la David).

# Your data
x <- data.frame(Time = c(1.04, 1.08), Temp = c(8, 10))

# the second argument is the factored results of
# stripping everything after the period off your Time data
tapply(x[,"Temp"], factor(gsub("\\..*", '', x[,"Time"])), min)

Cheers,

Josh

Side rant, our system of measuring time (like the English system) is
incredibly inconvenient and illogical.

On Thu, Oct 14, 2010 at 5:56 PM, joeman3285 <joemaron at hotmail.com> wrote:
>
> Hi,
> So I have a set of data, hourly temperature, where each temperature is set
> up like this:
>
> Time     Temp
> 1.04        8
> 1.08        10
>
> etc.  Where "1" corresponds to a day (say monday is "1", tuesday is "2") and
> the decimal value corresponds to an the hour of the day.
>
> I have several thousand of these readings over several months.  What I would
> like to do is extract daily minimum temperatures from this data set.  Is
> this possible to do with R?
>
> I'm pretty new to the use of R and have only a basic understanding of how it
> all works.
>
> I appreciate any help.
>
> -joe
> --
> View this message in context: http://r.789695.n4.nabble.com/Data-Parameter-extract-tp2996369p2996369.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org 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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/



More information about the R-help mailing list