[R] R related tools - GUI
For years I used Deducer (Package Deducer) developed by Ian Fellows. This is still available and partially remains mostly functional. He was working on a new GUI years ago but appears no longer to be in the pipeline I think replaced by R-Studio. Send R-help mailing list submissions to r-help@r-project.org To subscribe or unsubscribe via the World Wide Web, visit https://stat.ethz.ch/mailman/listinfo/r-help or, via email, send a message with subject or body 'help' to r-help-requ...@r-project.org You can reach the person managing the list at r-help-ow...@r-project.org When replying, please edit your Subject line so it is more specific than "Re: Contents of R-help digest..." Today's Topics: 1. Re: Positron as a tool (=?UTF-8?B?RMOpbmVzIFTDs3Ro?=) 2. Re: Positron as a tool (avi.e.gr...@gmail.com) 3. Re: Positron as a tool (Stephen H. Dawson, DSL) 4. Re: Converting .grib to excel file (javad bayat) 5. Referencing Sys.Date to a different time zone (Dennis Fisher) 6. Re: Referencing Sys.Date to a different time zone (Ivan Krylov) 7. Re: [Tagged] Re: Referencing Sys.Date to a different time zone (Jeff Newmiller) -- Message: 1 Date: Fri, 28 Jun 2024 13:03:17 +0200 From: =?UTF-8?B?RMOpbmVzIFTDs3Ro?= To: avi.e.gr...@gmail.com, r-help@r-project.org Subject: Re: [R] Positron as a tool Message-ID: Content-Type: text/plain; charset="utf-8"; Format="flowed" Hi Avi, I am not sure that the R-help mailing list is a suitable channel for advertising R-related tools... But given you mentioned Positron (https://github.com/posit-dev/positron), which is based on VSCode, it is worth calling out that a free, open-source, community-maintained, very feature rich R extension (https://code.visualstudio.com/docs/languages/r) already exists in VS Code for years. Regards, Denes On 6/28/24 07:10, avi.e.gr...@gmail.com wrote: This is just an FYI based on a news item I saw tonight. There have been discussions on what editors or environments people can use when working with R and I personally have mostly been using versions of RSTUDIO and lately for both R and python. As often noted, RSTUDIO is a product of a company, currently still largely free and they have some tweaks that can cause issues. The news article mentions a future project as described below, if anyone is interested, that may be a nice alternative similar (and based on) what some use for programming in multiple languages. Again, I am noty suggesting anyone use it, albeit I plan on trying it out when it is a bit further along. The current name seems to be Positron, to sort of go with the new name of the company behind RSTUDIO, which is now Posit. Nothing to do with Asimov's Positronic Brains, LOL! Here is a reference if anyone is interested. https://www.infoworld.com/article/3715702/maker-of-rstudio-launches-new-r-an d-python-ide.html [[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 the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Message: 2 Date: Fri, 28 Jun 2024 11:41:04 -0400 From: To: =?UTF-8?Q?'D=C3=A9nes_T=C3=B3th'?= , Subject: Re: [R] Positron as a tool Message-ID: <002c01dac971$95d6ca20$c1845e60$@gmail.com> Content-Type: text/plain; charset="utf-8" Just to be clear, Denis, I am not in any way associated with anybody or anything and just read about it on a news feed not from POSIT directly. I am aware it is based on existing functionality and have used possibly similar editors for other languages. I did try possibly one touted by Microsoft years ago (perhaps what you are referring to) but felt no need to keep using it at the time. What I am interested in is hearing from others who have opinions, perhaps after having tried it. And there is a trend I have noted where some development environments have been moving towards multiple language support including at times integration between languages. RSTUDI, itself, has been supporting a number of languages besides R and that is one reason it changed names for the company. What they are offering now, and I am not clear what they are adding or changing, looks like an attempt to evolve along such lines. Python versions typically have shipped with a fairly rudimentary IDLE program you can use as a sort of editor. Plenty of other add-ons are available independently. As noted, RSTUDIO now is such an add-on for python too. R, as far as I know, has not taken that route and you get just the language alone and the community is free to use anything else they want. RSTUDIO is one of many but arguably, quite a few here have used it. Man
[R] Package to generate moon phase - SR-SS
Hi all I have not found a package by Googling, but assume there must be at least one out there. I need to generate/write sun rise-sun set times (civil twilight) and moon phase/illumination. I would like to add a start date and end date along with location coordinates and have a table generated like below. This is from a legacy program acquired some 30 years ago and is no longer available. This can only generate 1 month at a time (subset below). But for a year at a time both historical and for future dates and locations. For this legacy program I enter the date and select a location I have in a simple TXT location file location with time-zone and X-Y coordinates and it will generate a month at a time. this can be dumped to the clipboard but not written as a TXT or delimited file. I am hoping there will be an elegant way to do this in R and have the results written to a file for import into an Access DB. Tnx for any suggestions on package(s). Sample below. Sun and Moon Data for March 2021 17.05°N 88.57°W 5hrW Standard Time Civil Twilight Sun Moon Date Twi. Rise Transit Set Twi. Rise Transit Set % 3/1/2021 06:50 07:12 13:07 19:01 19:23 21:36 02:52 09:04 92 3/2/2021 06:50 07:11 13:06 19:01 19:23 22:35 03:43 09:47 85 3/3/2021 06:49 07:11 13:06 19:02 19:23 23:35 04:35 10:31 76 3/4/2021 06:48 07:10 13:06 19:02 19:24 * 05:28 11:18 65 -- Bruce W. Miller, PhD. Neotropical bat risk and acoustic assessments Conservation Fellow - Wildlife Conservation Society Research Associate, American Museum of Natural History If we lose the bats, we may lose much of the tropical vegetation and the lungs of the planet Using acoustic sampling to identify and map species distributions and pioneering acoustic tools for ecology and conservation of bats for >25 years. Key projects include providing free interactive identification keys and call fact sheets for the vocal signatures of New World Bats __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Need guidance on summarizing time data
Hi all, I need to summarize temporal activity. However date\times in R seem to be not easily handled. Seems I may need to convert date\time values to a recognizable format? My "raw data" is tab (text) includes a location ID, date and time(24 hr format). Format is like this: Location Date Time 156 2/25/2008 18:31 156 2/25/2008 18:31 156 2/25/2008 18:32 156 2/25/2008 18:35 156 2/25/2008 18:38 156 2/25/2008 18:41 156 2/25/2008 18:42 156 2/25/2008 18:43 156 2/25/2008 18:43 156 2/25/2008 18:55 156 2/25/2008 18:56 156 2/25/2008 18:56 156 2/26/2008 18:35 156 2/26/2008 18:35 156 2/26/2008 18:35 156 2/26/2008 18:35 196 7/16/2006 4:47 250 4/9/2004 18:41 250 4/9/2004 18:44 253 3/5/2004 18:30 1268 2/11/2001 18:39 1268 2/11/2001 18:39 1344 4/17/2003 19:06 1409 2/28/2004 5:51 ...etc. for 10,390 rows of data. I am aiming for a summary by times for all of the data such that I have total number of "events" or count for each time period. So something like 18:31 41 18:32 38 and so on. So a "simple" count of the time occurrences. I tried to do a summary running frequencies descriptive.table(vars = d(Time) , + strata = d(Date),data= Active, + func.names =c("Valid N","Minimum","Maximum")) Warning message: In descriptive.table(vars = d(Time), strata = d(Date), data = Active, : Non-numeric variables dropped from descriptive table > Active[,3]<-as.POSIXct(Active[,3], format='%m-%d-%y %H:%M:%S') > Active[,2]<-as.Date(Active[,2], format= '%m/%d/%y') > frequencies(Active[c("Time")] , r.digits = 1) Error in names(x) <- value : 'names' attribute [4] must be the same length as the vector [3] Suggestions welcomed. Cheers all -- Bruce W. Miller, PhD. Neotropical bat risk and acoustic assessments Conservation Fellow - Wildlife Conservation Society Research Associate, American Museum of Natural History If we lose the bats, we may lose much of the tropical vegetation and the lungs of the planet Using acoustic sampling to identify and map species distributions and pioneering acoustic tools for ecology and conservation of bats for >25 years. Key projects include providing free interactive identification keys and call fact sheets for the vocal signatures of New World Bats __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Indian Red
FWIW, There is also Naples Yellow and other colors related to "place names" on artist palettes. "Indian Red" is not related to North American Native peoples. "/India Red/: Originally a natural, more purple iron oxide imported from /India/. First synthesized in the 18th century as a “Mars” color, contemporary ... Let it rest people. Bruce Miller -- Bruce W. Miller, PhD. Neotropical bat risk and acoustic assessments Conservation Fellow - Wildlife Conservation Society Research Associate, American Museum of Natural History If we lose the bats, we may lose much of the tropical vegetation and the lungs of the planet Using acoustic sampling to identify and map species distributions and pioneering acoustic tools for ecology and conservation of bats for >25 years. Key projects include providing free interactive identification keys and call fact sheets for the vocal signatures of New World Bats [[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 the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] did bot execute
Hi Abby, Tried this new version but did not execute... Clearly I am missing a step. Bruce > library (barsurf) > library (KernSmooth) > set.bs.theme ("heat") > > plot_ds <- function (dataset, main="", xlim, ylim, ..., + ncontours=3, labcex=0.8, ndec=3, + k1=1, k2=1, n=30) + { names <- names (dataset) + x <- dataset [,1] + y <- dataset [,2] + bw.x <- k1 * bw.nrd (x) + bw.y <- k2 * bw.nrd (y) + if (missing (xlim) ) + xlim <- range (x) + c(-1, 1) * bw.x + if (missing (ylim) ) + ylim <- range (y) + c(-1, 1) * bw.y + + ks <- bkde2D (dataset, c (bw.x, bw.y), + c (n, n), list (xlim, ylim), FALSE) + + fb <- seq (min (ks$fhat), max (ks$fhat), + length.out = ncontours + 2) + fb <- fb [2:(ncontours + 1)] + fb <- round (fb, ndec) + + plot_cfield (ks$x1, ks$x2, ks$fhat, + contours=FALSE, + main=main, xlab = names [1], ylab = names [2], + xyrel="m") + points (x, y, pch=16, col="#0040") + contour (ks$x1, ks$x2, ks$fhat, levels=fb, labcex=labcex, add=TRUE) + } > > plot_ds (bat_call, "plot 2", c (25, 28), c (-15, 10), k1=1.25, k2=1.25) *Error in plot_ds(bat_call, "plot 2", c(25, 28), c(-15, 10), k1 = 1.25, : ** ** object 'bat_call' not found* [[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 the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Query on contour plots
Tnx Jim, Yes if there is a way to first extract the ranges of each data files Fc range and Sc ranges and then link to the plot that would be stellar. I will look at this code and see how it is working so far. Thanks a million. Bruce Hi Bruce & Abby, Here is a start on merging the two plots. Abby - I had to cheat on the legend colors as I could not work out from the help pages how to specify the range of colors. Also I don't know the range of densities. Both should be easy to fix. While I specified xlab and ylab, they don't seem to make it to the plotting functions. More study needed. Bruce - The following code gives general idea of how to automate plotting from a single data set. let me know whether you want automated adjustment of axes, etc. Both - I suspect that the constraints forming the diagonal lines are due to characteristics of the bat larynx. bfs<-read.csv("Procen_sample.csv") # split out what you want to identify the plot species<-unlist(strsplit("Procen_sample.csv","_"))[1] library(bivariate) # define the plot sequence plot_ds <- function (dataset, main="", xlim, ylim, ..., k1=1, k2=1) { names <- names (dataset) fh <- kbvpdf (dataset [,1], dataset [,2], k1 * bw.nrd (dataset [,1]), k2 * bw.nrd (dataset [,2]) ) plot (fh, main=main, xlab = names [1], ylab = names [2], xlim=xlim, ylim=ylim, ncontours=2) } # open the device png(paste0(species,".png")) # leave space for the color legend par(mar=c(6,4,4,2)) plot_ds (bfs[,c("Fc","Sc")], main=paste(species,"characteristic bat call"), xlab="Frequency (kHz)",ylab="Characteristic slope (octaves/s)", ,k1=1.25, k2=1.25) library(plotrix) xylim<-par("usr") color.legend(xylim[1],xylim[3]-(xylim[4]-xylim[3])/7, xylim[1]+(xylim[2]-xylim[1])/4,xylim[3]-(xylim[4]-xylim[3])/10, legend=seq(0,10,length.out=5), rect.col=color.scale(0:4,extremes=c("#7be6bd","#bdb3df")),align="rb") text(xylim[1]+(xylim[2]-xylim[1])/8, xylim[3]-(xylim[4]-xylim[3])/5, "Density",xpd=TRUE) dev.off() Jim On Wed, Jun 3, 2020 at 6:22 AM Neotropical bat risk assessments wrote: Hi Abby, The contour lines are actually useful to see groupings. However w/o a legend for density it is not possible to see what is presented. Very nice Jim, thank you. However, the (deterministic, or near-deterministic) diagonal lines in the plot, make me question the suitability of this approach. In my plot, the contour lines could be removed, and brighter colors could be used. But perhaps, a better approach would be to model those lines... And it's not clear from the plot, if all the observations fall on a diagonal line... P.S. I'm not sure why there's a white line on the plot. Most of my testing was with PDF output, I will need to do some more testing with PNG output. -- Bruce W. Miller, PhD. Neotropical bat risk assessments Conservation Fellow - Wildlife Conservation Society If we lose the bats, we may lose much of the tropical vegetation and the lungs of the planet Using acoustic sampling to identify and map species distributions and pioneering acoustic tools for ecology and conservation of bats for >25 years. Key projects include providing free interactive identification keys and call fact sheets for the vocal signatures of New World Bats -- Bruce W. Miller, PhD. Neotropical bat risk assessments Conservation Fellow - Wildlife Conservation Society If we lose the bats, we may lose much of the tropical vegetation and the lungs of the planet Using acoustic sampling to identify and map species distributions and pioneering acoustic tools for ecology and conservation of bats for >25 years. Key projects include providing free interactive identification keys and call fact sheets for the vocal signatures of New World Bats __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Query on contour plots
Hi Abby, The contour lines are actually useful to see groupings. However w/o a legend for density it is not possible to see what is presented. Very nice Jim, thank you. However, the (deterministic, or near-deterministic) diagonal lines in the plot, make me question the suitability of this approach. In my plot, the contour lines could be removed, and brighter colors could be used. But perhaps, a better approach would be to model those lines... And it's not clear from the plot, if all the observations fall on a diagonal line... P.S. I'm not sure why there's a white line on the plot. Most of my testing was with PDF output, I will need to do some more testing with PNG output. -- Bruce W. Miller, PhD. Neotropical bat risk assessments Conservation Fellow - Wildlife Conservation Society If we lose the bats, we may lose much of the tropical vegetation and the lungs of the planet Using acoustic sampling to identify and map species distributions and pioneering acoustic tools for ecology and conservation of bats for >25 years. Key projects include providing free interactive identification keys and call fact sheets for the vocal signatures of New World Bats __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] Query on contour plots
Hi all, I spent some time this morning fiddling with the parameters in the plot code provided by Jim and Abby and by changing some important ones. Jim did note *# set the matrix limits a bit beyond the data ranges* fcsc_mat<-makeDensityMatrix(bfs$Fc,bfs$Sc,nx=100,ny=100, zfun="sum",xlim=c(*30,45*),ylim=c(*-55,110*)) and axis(1,at=seq(5,95,10),round(seq(*30.0,50.0*,length.out=10),1)) axis(2,at=seq(5,95,10),round(seq(*-55,110*,length.out=10),1)) So editing the lines above to match what the data includes the plots for various species are working! I now need to figure out how to add a legend for the density values in the bivariate package plots. I am assuming there can be a line or so of code that can extract the min-max values from the actual data files that will update the xlim, ylim and axis data? I think this should be a simple first step after reading in each new data set. I can not thank Jim and Abby enough. Super helpful Cheers, Bruce -- Bruce W. Miller, PhD. Neotropical bat risk assessments Conservation Fellow - Wildlife Conservation Society If we lose the bats, we may lose much of the tropical vegetation and the lungs of the planet Using acoustic sampling to identify and map species distributions and pioneering acoustic tools for ecology and conservation of bats for >25 years. Key projects include providing free interactive identification keys and call fact sheets for the vocal signatures of New World Bats [[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 the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Query on contour plots
Hi all, Many thanks for the efforts and suggestions. This is getting closer to what is needed. No legend showing the density values yet. I was able to replicate a similar plot with the original data set. However when I tried this with a different data set that has other Fc & Sc values the plot does not work... just a blank PNG Code from console below: >bfs<-Eptfur > dim(bfs) [1] 5638 17 > names(bfs) [1] "Filename" "st" "Dur" "TBC" "Fmax" "Fmin" "Fmean" [8] "Tk" "Fk" "Qk" "Tc" "Fc" "Dc" "S1" [15] "Sc" "Qual" "Pmc" > library(plotrix) > # set the matrix limits a bit beyond the data ranges > fcsc_mat<-makeDensityMatrix(bfs$Fc,bfs$Sc,nx=25,ny=25, + zfun="sum",xlim=c(24,29),ylim=c(-20,10)) Range of density (>0) - Inf -Inf Warning messages: *1: In min(x) : no non-missing arguments to min; returning Inf** **2: In max(x) : no non-missing arguments to max; returning -Inf* > png("bat_call_plot.png") > par(mar=c(6,4,4,2)) > color2D.matplot(fcsc_mat, + main="Freqency by slope of bat calls", + extremes=c("yellow","red"),xlab="Frequency (kHz)", + ylab="Characteristic slope (octaves/s)", + border=NA,axes=FALSE) Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In min(x) : no non-missing arguments to min; returning Inf 4: In max(x) : no non-missing arguments to max; returning -Inf > axis(1,at=seq(5,95,10),round(seq(24.5,28.5,length.out=10),1)) > axis(2,at=seq(5,95,10),round(seq(-20,10,length.out=10),1)) > color.legend(0,-14,25,-10,legend=seq(0,10,length.out=5), + rect.col=color.scale(0:4,extremes=c("yellow","red")),align="rb") > text(12.5,-20,"Density (cell count)",xpd=TRUE) > dev.off() null device 1 I will not need to add a function it iterate as I will not be running this as an iterative task at one time... I just need the code to be able to use different data sets that have the same fields. The Sc values over the 200+ data sets will range from potentially large negative numbers to positive numbers depending on the slope of the calls, i.e. increasing frequencies or decreasing frequencies. An example of these two parameters for a single species with descriptive stats. N is valid number of call pulses, then 10%-90% bins of where the call pulses fall into. Parameters N Min Max MeanSt.Dev 10% 25% 75% 90% Fc 32802 43.01 50.00 46.86 1.3145.07 45.98 47.76 48.63 Sc 32802 -309.78 13.76 -6.60 10.98 -10.31 -7.50 -3.91 -2.81 I am very appreciative and thank you both for guiding the efforts. Bruce > Very nice. I forgot that you didn't have the complete data set. > > png("as_bat_call.png") > plot_ds (bfs[,c("Fc","Sc")], "plot 1", xlim = c (25, 30), ylim = c (-15, 10), > k1=1.25, k2=1.25) > dev.off() > > Jim > > On Tue, Jun 2, 2020 at 6:24 PM Abby Spurdle wrote: >> I'm putting this back on the list. >> >>> So how would I set up the code to do this with the data type I have? >>> I will need to replicate the same task > 200 times with other data sets. >>> What I need to do is plot *Fc *against *Sc* with the third dimension being >>> the *density* of the data points. >> Using Jim's bat_call data: >> >> library (bivariate) >> >> plot_ds <- function (dataset, main="", xlim, ylim, ..., k1=1, k2=1) >> { names <- names (dataset) >> fh <- kbvpdf (dataset [,1], dataset [,2], k1 * bw.nrd (dataset >> [,1]), k2 * bw.nrd (dataset [,2]) ) >> plot (fh, main=main, xlab = names [1], ylab = names [2], >> xlim=xlim, ylim=ylim, >> ncontours=2) >> } >> >> plot_ds (bat_call, "plot 1", k1=1.25, k2=1.25) >> >> Note that I've used stats::bw.nrd. >> The k1 and k2 values, simply scale the default bandwidth. >> (In this case, I've increased the smoothness). >> >> If you want to do it 200+ times: >> (1) Create another function, to iterate over each data set. >> (2) If you want to save the plots, you will need to add in a call to >> pdf/png/etc and close the device, in each iteration. >> (3) It may be desirable to have constant xlim/ylim values, ideally >> based on the ranges of the combined data: >> >> plot_ds (bat_call, "
[R] Query on contour plots
Hi all, While exploring packages for 3D plots that several folks suggested (Tnx all!) It seems what I really need is a contour plot. This is not working int he Deducer GUI. This will be an aid to separating bats by their vocal signatures. What I need to do is plot *Fc *against *Sc* with the third dimension being the *density* of the data points in the Fc-Sc plot. Data format is like this abbreviated sample. Fc is a frequency in kHz and Sc is the characteristic slope (octaves per second) of each call pulse. Any suggestions, guidance greatly appreciated. Bruce Fc Sc 26.58 -5.95 27.03 -8.2 27.16 -2.07 26.19 -7.68 26.62 -3.99 26.85 -6.08 26.94 0 26.1-5.74 26.62 -5.96 26.85 -4.05 26.98 -4.09 26.02 -5.69 26.53 -7.89 26.62 -2 26.8-4.04 28.73 7 25.72 -2.97 26.14 -5.76 26.32 -3.89 26.40 26.32 5.88 [[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 the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Query on 3d plotting pacakges
Hi all, Fumbling around trying to find a plot package to do 3D plots. This will be an aid to separating bats by their vocal signatures. What I need to do is plot *Fc *against *Sc* with the third dimension being the *density* of the data points in the Fc-Sc plot. Data format is like this abbreviated sample. Fc is a frequency in kHz and Sc is the characteristic slope (octaves per second) of each call pulse. Any suggestions, guidance greatly appreciated. Bruce Fc Sc 26.58 -5.95 27.03 -8.2 27.16 -2.07 26.19 -7.68 26.62 -3.99 26.85 -6.08 26.94 0 26.1-5.74 26.62 -5.96 26.85 -4.05 26.98 -4.09 26.02 -5.69 26.53 -7.89 26.62 -2 26.8-4.04 28.73 7 25.72 -2.97 26.14 -5.76 26.32 -3.89 26.40 26.32 5.88 [[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 the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] What is best way to calculate % of time?
Tnx all for the helpful suggestions. Life is good. Happy holidays Bruce -- Bruce W. Miller, PhD. Neotropical bat risk assessments Conservation Fellow - Wildlife Conservation Society If we lose the bats, we may lose much of the tropical vegetation and the lungs of the planet Using acoustic sampling to identify and map species distributions and pioneering acoustic tools for ecology and conservation of bats for >25 years. Key projects include providing free interactive identification keys and call fact sheets for the vocal signatures of New World Bats __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] What is best way to calculate % of time?
Hi Bert, Tnx for taking time to reply. For clarification... the data do EXPLICITLY indicate when each species is active and when a feeding buzz is recorded. That is ALL it provides based on acoustic data recorded in the field. Only when a species is recorded is it identified as active. How this is accomplished is of no importance to the question I asked. Note this is Not "individuals" per se. but species as a group. I appreciate you taking time to reply. Clearly this is not a simple solution to what I assumed to be a simple question. Restated as... *How best to use R to calculate occurrence of event( (A) over time vs all events (b...n) over the same time period give the data frame work I have.* Cheers, Bruce > I will not get into your explanation of details that, like John, I > find opaque. Please DO read Hadley's manifesto, as it appears that you > need to organize your data more appropriately. > > AFAICS, however, strictly speaking your data cannot answer the > question you have posed. **Strictly speaking** to know the proportion > of active time bats spend feeding, **for each bat** you would need to > know when it is active and when it is feeding during that time. You > could then summarize this for all bats (e.g. take the average or > median proportion) in a species or whatever. As you cannot identify > individual bats in your data, you cannot do this -- i.e. you cannot > answer your question. > > So the question then becomes: precisely **how** exactly do you propose > using the data you have to determine when a *group* of bats are active > and when they are feeding? How are the groups explicitly identified > and how are their times active and feeding determined? In short, you > need to have information that is something like: > > Bat.Group date active.time.start active.time.end > feeding.time.start feeding.time.end > > ( for a given date and bat group, there may be many multiple entries; > perhaps for a given group, date, and active time start and end, > several feeding time start/stop entries ( I have no idea how bats > behave)). > > Until you can expicitly explain how your data can generate such > information, I think it will be difficult/impossible to help you. > > Cheers, > Bert > [[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 the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] What is best way to calculate % of time?
Tnx John, Yep failed to "reply all" my bad. Yes the mix of "information" on call type and species are in the same field. It will be a single mouse click to export only the "buzz" data from the master DB as a separate CSV file from the species data. So this could be a new DF/data set for R. This is due to the legacy issues of how the acoustic data are added to the metadata of the bat call recordings. Combining date and times does not provide for sampling nights that roll over after midnight. I may need to reread Hadley's Tidy Data manifesto re: data handling ;-). The location, date and time does provide unique variables. Duplicate times mentioned are the "duplicated" values you noted. This happens as the actual call files include seconds for a more precise time when the recordings were made. Rounding to nearest minute suffices for a summary of total minutes spent with "feeding attempts" vs total active time. The data being gathered is reviewed in a purpose build bat acoustic software program when reviewing bat call files. The metadata include the "Who", "Where" & "When" recorded. What is added to this as the acoustic files are reviewed are information on call types and species IDs. This metadata is exported as a TXT file and imported into a master Access DB I developed over the past 15 years to manage "BIG DATA" as they say. As a note I currently it have >1.9 million acoustic call records store in the relational DB. The data output/exported from the DB is sufficient to provide wonderful temporal activity plots using GGplot2. Original code for this was developed with huge assistance from Hadley eons ago and updated to more recent R releases and packages by a few others. The graphics are great to visualize temporal activity but do not provide a simple summary of amount of time spent "foraging AKA feeding buzz data" vs total activity time for each species. Perhaps this is /was not a simple question on how to summarize time data to derive a % of each category, be it "buzz" or species. Tnx again, Bruce > > Hi Bruce, > You replied just to me. I have taken the liberty of cc:ing R-help as > there lots of more knowledgeable people than me there who may be able > to help. > In the meantime I remain confused. > Here is my impression of the sample data that you supplied. I have > combined Date & Time into a single POSIXct variable, dtime. Just paste > it into R > ##===## > dat2 <- structure(list(Species = structure(c(1L, 1L, 1L, 1L, 1L, 1L, > 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, > 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, > 3L, 3L), .Label = c("Buzz", "Ptedav", "Ptemes"), class = "factor"), > Location = c(7716L, 7716L, 7716L, 7716L, 7716L, 7716L, 7716L, 7717L, > 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, > 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, > 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, 7717L, > 7717L, 7717L, 7717L, 7717L), dtime = structure(c(948758700, 948758700, > 948758700, 948761220, 948761220, 948761220, 948761220, 962655420, > 962655420, 962655420, 962655420, 962656200, 962656200, 962656200, > 962656200, 962655240, 962655300, 962655300, 962655300, 962655300, > 962655300, 962655420, 962655420, 962655420, 962655480, 962655480, > 962655480, 962655480, 962655480, 962666100, 962666460, 962666520, > 962666580, 962666700, 962666760, 962666820, 962666880, 962666940, > 962667180, 962667300, 962667360, 962667420), class = c("POSIXct", > "POSIXt"), tzone = "UTC")), class = "data.frame", row.names = c(NA, -42L)) > ##===## > The 6 letter species codes relate to individual bat species and the > Buzz = Feeding buzz that indicates a feeding attempt by a given bat. > So the "codes" are both species and information on the call type. > But, at the moment you have two variables in the one column, Species: > The type of bat and feeding behaviour. > The date/time is when the species was recorded and is linked to the > location. > Okay. Will this give us a unique key? > Therefore to run the summary stats I need I will need to remove the > duplicate times that are rounded to the minute > What duplicate times? Where are they? When are they rounded? > I have never used Access. Will it produce a data dictionary? Can it > export a small subset of the relevant data to another Access DB, some > other DB or in .csv format? At the moment I just cannot visualize what > your data la
[R] What is best way to calculate % of time?
Hi all, It seems R has gotten better/more packages in dealing with time data. I want to create "simple" summaries of time for bat activity. Data is all in an Access relational database and exported as a CSV file with 4 columns in this format: Species = a 6 letter code or "Buzz" to indicated when bats are feeding Location = a 4 digit number Date= MMDD Time=HH:MM (24 hr format) Species Location Date Time Buzz 7716 1/25/2000 0:05 Buzz 7716 1/25/2000 0:05 Buzz 7716 1/25/2000 0:05 Buzz 7716 1/25/2000 0:47 Buzz 7716 1/25/2000 0:47 Buzz 7716 1/25/2000 0:47 Buzz 7716 1/25/2000 0:47 Buzz 7717 7/3/2000 20:17 Buzz 7717 7/3/2000 20:17 Buzz 7717 7/3/2000 20:17 Buzz 7717 7/3/2000 20:17 Buzz 7717 7/3/2000 20:30 Buzz 7717 7/3/2000 20:30 Buzz 7717 7/3/2000 20:30 Buzz 7717 7/3/2000 20:30 Ptedav 7717 7/3/2000 20:14 Ptedav 7717 7/3/2000 20:15 Ptedav 7717 7/3/2000 20:15 Ptedav 7717 7/3/2000 20:15 Ptedav 7717 7/3/2000 20:15 Ptedav 7717 7/3/2000 20:15 Ptedav 7717 7/3/2000 20:17 Ptedav 7717 7/3/2000 20:17 Ptedav 7717 7/3/2000 20:17 Ptedav 7717 7/3/2000 20:18 Ptedav 7717 7/3/2000 20:18 Ptedav 7717 7/3/2000 20:18 Ptedav 7717 7/3/2000 20:18 Ptedav 7717 7/3/2000 20:18 Ptemes 7717 7/3/2000 23:15 Ptemes 7717 7/3/2000 23:21 Ptemes 7717 7/3/2000 23:22 Ptemes 7717 7/3/2000 23:23 Ptemes 7717 7/3/2000 23:25 Ptemes 7717 7/3/2000 23:26 Ptemes 7717 7/3/2000 23:27 Ptemes 7717 7/3/2000 23:28 Ptemes 7717 7/3/2000 23:29 Ptemes 7717 7/3/2000 23:33 Ptemes 7717 7/3/2000 23:35 Ptemes 7717 7/3/2000 23:36 Ptemes 7717 7/3/2000 23:37 The above is clearly not a complete DF but only a format sample. Data begins when the first bat was recorded and ends when the last bat was recorded. So all are times from sunset to sunrise. Dates roll over so for example one night of data would begin at 18:00 1/1/2000 and end 06:00 1/2/2000. What I need to do is have a summary of Buzz events (feeding) and calculate the percentage of total time bats were active and have a summary of time feeding buzz was recorded and total bat activity to determine what percentage of time was spent with feeding attempts over the active period. This by all bats by survey night and by single species by survey night. Any suggestions welcomed. Happy holidays all -- Bruce W. Miller, PhD. Neotropical bat risk assessments Conservation Fellow - Wildlife Conservation Society If we lose the bats, we may lose much of the tropical vegetation and the lungs of the planet Using acoustic sampling to identify and map species distributions and pioneering acoustic tools for ecology and conservation of bats for >25 years. Key projects include providing free interactive identification keys and call fact sheets for the vocal signatures of New World Bats __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Need help with an iteration
Hi all, I am having an issue with trying to run iterations for the same analysis with a list of data sets. I am assuming I am missing a basic step here. Code I am trying is below. Not certain if a NEXT call needs to be included somewhere or not. This is run under the Deducer GUI. I would also be content to simply run in a basic R console if that works. # First step, was to create a folder with the simple data files for the analysis # Set the WD for that directory setwd("C://Embalonurids") # Call all the names of the files in that folder file.names <- dir(pattern = "*.txt") #Make a LOOP for the analysis for(i in 1:length(file.names)){file <- read.table(file.names[i],header=TRUE) # read the text files one by one # Deducer code used file[c("TBC")] <- recode.variables(file[c("TBC")] , "0 -> NA;") # Create new BW variable and data set then change data file name for the analysis BW<-within(file,BW<-Fmax-Fmin) BW<-within(BW,FcH1<-Fc*.5) BW<-within(BW,FcH3<-FcH1*3) BatStats<-BW # In the Deducer GUI this is the code that runs manually if I run these one by one BatStats<-Deducer::descriptive.table (vars = d (Dur,TBC,Fmin,Fmax,BW,Fmean,Fk,FcH1,Fc,FcH3,Sc,Pmc),data= BatStats,func.names =c("Valid N","Minimum","Maximum","Mean","St. Deviation"),func.additional= list(p75=function(x) quantile(x, c(0.75), na.rm=TRUE),p85=function(x) quantile(x, c(0.85), na.rm=TRUE),p90=function(x) quantile(x, c(0.90),na.rm=TRUE),p99=function(x) quantile(x, c(0.99),na.rm=TRUE))) ## Then the results need to be written to an outputdirectory name <- as.character(paste(file.names[i], ".csv", sep="")) # this creates an element that will have the name of the file that is used in each run # I have tried both setting a new WD or simply defined where to writ the results setwd("C://Embalonurids/Results") write.csv(BatStats, name) #this should assign the names of the files as it iterates one by one }) #also tried directing where to write the outputas I do when manually running this #write.csv(BatStats,name,file="C:\\Emballonurids\Results")) I would like to run this as an iteration as I have > 200 data files to process and would love to have it run in background while I am working on other things. An assistance welcomed. Bruce -- Bruce W. Miller, PhD. Neotropical bat risk assessments Conservation Fellow - Wildlife Conservation Society If we lose the bats, we may lose much of the tropical vegetation and the lungs of the planet Using acoustic sampling to identify and map species distributions and pioneering acoustic tools for ecology and conservation of bats for >25 years. Key projects include providing free interactive identification keys and call fact sheets for the vocal signatures of New World Bats __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] rewrite code from Deducer to run on R-Studio
Hi all, Apparently Deducer (a GUI for R) is no longer supported or being updated. What is the easiest way to re-write code to run using R-Studio? An example: BatStats<- Deducer::descriptive.table (vars = d (Dur,Fmin,Fmax,Fmean,Fk,Fc,Sc,Pmc),data= BatStats,func.names =c("Valid N","Minimum","Maximum","Mean","St. Deviation","25th Percentile","75th Percentile"),func.additional= list(p10=function(x) quantile(x, c(0.10), na.rm=TRUE),p90=function(x) quantile(x, c(0.90), na.rm=TRUE))) So I will be on a new learning curve. Tnx for any suggestions Bruce -- Neotropical bat projects Making call Fact Sheets and interactive ID keys of the New World bat vocal signature freely available to all. Pioneering acoustic identifications of Neotropical bats since 1995 Bruce W. Miller, PhD. Conservation Fellow, Wildlife Conservation Society __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] Syntax for capturing and writing file names
Hi all, I am looking for syntax to read a list of *txt files, (loop through?) each with a different data content but same fields, then run lines of code to produce summary stats (I have working code for this) and add the matching data file name when writing the results of a line of R code. Suggestions on any package vignettes that may be useful welcomed. My manual code for this is below and need to understand how to have the "DataFile" name changed to match the name of each data file as it is read and processed. *write.csv(BatStats,file="C:\\=Bat data working\\Acoustic Parameters\\DataFile_Stats.csv")* -- Bruce W. Miller, PhD. Neotropical bat risk assessments Conservation Fellow - Wildlife Conservation Society If we lose the bats, we may lose much of the tropical vegetation and the lungs of the planet Using acoustic sampling to identify and map species distributions for >25 years. Providing free Interactive identification keys and call fact sheets for the vocal signatures of New World Bats [[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 the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Hacked
Hi all, Site has been hacked? Bad SPAM arriving __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] iterative read - write
Hi all, I would like to set up an iterative read & write sequence to avoid reading and writing each file one at a time. Hundreds of data sets to re-calculate. The code I have works well individually, but would like to set up an iterative read, calculate and write changing the input and output file names each iteration. I think I have read that there is an R feature using "Pipes" and % that may help but have not figured out how to do this. What I am seeking is a way to read a list of TXT files, calculate the values and write the results in an iterative manner to avoid manually reading each file individually Suggestions? Tnx, Bruce* * *# This works* *#read in a data file * *>Corbre_2 <- read.table("E:/Acoustic Parameters/~Emballonuridae/Data by genus/~Corbre/Corbre_2.txt",header=T,sep="\t",quote="")* *# create and calculate a new variable for time between call pusles * *Corbre_2 [c("TBC")] <- recode.variables(Corbre_2[c("TBC")] , "0 -> NA;")* *# Create new BW variable for band width then change data file name* *BW<-within(Corbre_2,BW<-Fmax-Fmin)* *# Create 2 new variables for fundamental H1 and third harmonic H3 frequencies * *#based on Fc that is generally loudest at the 2^nd harmonic.* *BW<-within(BW,FcH1<-Fc*.5)* *BW<-within(BW,FcH3<-FcH1*3)* *#rename to a DF to calculate the stats * *BatStats<-BW* *BatStats<-Deducer::descriptive.table (vars = d (Dur,TBC,Fmin,Fmax,BW,Fmean,Fk,FcH1,Fc,FcH3,Sc,Pmc),data= BatStats,func.names =c("Valid N","Minimum","Maximum","Mean","St. Deviation"),func.additional= list(p10=function(x) quantile(x, c(0.10), na.rm=TRUE),p25=function(x) quantile(x, c(0.25), na.rm=TRUE),p75=function(x) quantile(x, c(0.75),na.rm=TRUE),p90=function(x) quantile(x, c(0.90),na.rm=TRUE)))* *## Write the results and change output name and directory for the calculated stats.* *write.csv(BatStats,file="C:\\=Bat data working\\Acoustic Parameters\\Corbre_Stats.csv")* -- Bruce W. Miller, PhD. Neotropical bat risk assessments Conservation Fellow - Wildlife Conservation Society If we lose the bats, we may lose much of the tropical vegetation and the lungs of the planet Using acoustic sampling to identify and map species distributions for >25 years. Providing free Interactive identification keys and call fact sheets for the vocal signatures of New World Bats [[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 the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Need help with labeling a plot correctly
Hi all, Eons ago (~2007) Hadley Wickham extremely generously helped me developed a means for plotting temporal activity w/ ggplot. I need to revisit this and have it working again. I failed to copy the entire legacy code over to my traveling laptop from my workstation, but found a partial bit of the code in an old 2009 Gmail attachment. I am slated to do a graduate seminar at UF G'ville and needed to discuss temporal activity. I have been working my feeble brain again and revisiting the almost complete code and have it partially working by doing step by step sections of code and carefully making sure no typos that could screw up syntax. The partial code Hadley developed for me is below and is now working more or less with R 3.4.3 (2017-11-30). What I need to do is have the missing bit of code so that the Y- Axis of the plots has time of night rather than the "elapsed seconds." As a note this is for bat activity data so data points begin after sunset on a given night and end at sunrise the following day so date/times span 2 calender days with a midnight roll-over. The code below was provided by Hadley and works except for the Y axis labeling with correct times. I can email a sample of the raw data if anyone is able to help. Cheers, Bruce ++ library(zoo) library(cluster) library(lattice) library(vegan) library(chron) library(MASS) library(ggplot2) # activity plots that Hadley Wickham helped develop back in ~2007 #New from Hadley *s*etwd("C:/Bats/Temporal data") #C:\Bats\Temporal data source("date.r") All <- read.csv("C:/Bats/Temporal data/TECTemporal.CSV") Ptepar <-subset(All, Species == "Ptepar") str(Ptepar) # Notice that date and time are factors - you need to convert them # into dates. This doesn't happen automatically in R. Also, the syntax to # make dates isn't exactly intuitive. Ptepar$Date <- as.Date(Ptepar$Date, "%m/%d/%Y") Ptepar$Time <- as.POSIXct(strptime(as.character(Ptepar$Time), "%H:%M")) Ptepar$datetime <- as.POSIXct(strptime(paste(Ptepar$Date, format(Ptepar$Time, "%H:%M")), "%Y-%m-%d %H:%M")) # For a given time, give the time the evening started # (this will be the previous day if the time is in the morning) evening <- function(date) { update(date, yday = yday(date) - ifelse(am(date), 1, 0), hour = 18, minute = 0, second = 0) } # Now we calculate the number of seconds since the start of the evening Ptepar$elapsed <- as.double(Ptepar$datetime - evening(Ptepar$datetime), "secs") ggplot(Ptepar, aes(Date, elapsed, colour = Location)) + geom_jitter() + facet_wrap(~ Species) The resulting plot appears fine however I need to have the Y axis display time of night rather than the elapsed seconds. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] New reshape2 question answered
Hi all, Thanks all who replied. Arun, Jim and Jeff. Seems like there are always multiple ways to achieve the same goals with R! Jim Holtman suggested using the base functions. Not PLYR or RESHAPE x <- read.table(text = "Species Location Date Time... Myochi Chena 5/26/09 18:38 remaining data table, as.is = TRUE, header = TRUE) # convert time to 15 minute intervals z <- do.call(rbind, strsplit(x$Time, ":")) mode(z) <- 'numeric' # convert to numeric # create 15 minute intervals x$int15 <- floor(z %*% c(60/15, 1/15)) + 1 # make first interval 1 # create count by species count <- do.call(rbind, lapply(split(x, x$Species), function(a){ c(tabulate(a$int15), rep(0,96))[1:96] # pad out to 96 values if required } ) ) percent <- t(apply(count, 1, function(a) a / sum(a) * 100)) ++ Jeff Newmiller suggested I step through the problem one piece at a time interspersed with appropriate use of the str() function to clarify what the data looks like at each step. Also suggested I ought to read ?DateTimeClasses and follow links from there as well. So some homework there for me. He suggested a better means to handling dates with this: library(lubridate) library(reshape2) # set time zone to something that doesn't use daylight savings # this may not be how your data are actually recorded... look # up ?timezones ... the short answer is you may need to look # at the names of some files on your system or in your R install # directory to find out what labels correspond to your data's timezone. Sys.setenv( TZ="Etc/GMT+5" ) dta$Dtm <- mdy_hm( paste( dta$Date, dta$Time ) ) floor5 <- function( dtm ) { # break up the POSIXct (number of seconds since 1/1/1970 GMT) dtmlt <- as.POSIXlt( dtm ) # floor the minutes and seconds to the next lower 5 minutes dtmlt$sec <- 0 dtmlt$min <- 5 * ( dtmlt$min %/% 5 ) as.POSIXct( dtmlt ) } dta$Dtm5 <- floor5( dta$Dtm ) # can be done with table #table( dta$Dtm5, dta$Species ) # I prefer data frames, so reshape2 helps out dtat <- dcast( dta, Dtm5~Species, fun.aggregate = length, value.var="Dtm5" ) __ R-help@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.
[R] New reshape2 question
Hi all, Thanks go out to those who provided helpful suggestions last year with a similar issue. I am working with a new data set and trying what I assumed was a simple aggregation in reshape2 but is not working. I have a large number of similar data sets to run so getting the code correct is important. I have tried this code line in bold (both plyr and reshape2 are loaded): > ChenaPond <- read.table("C:/Bat papers in prep/Chile/Data & analyses/ChenaPond.txt",header=T,sep="\t",quote="") dat1<-ChenaPond >*res2<-ddply(dat1,.(Location,Species),summarize, Time=sum(Time))* *Error in Summary.factor(c(3L, 4L, 5L, 15L, 39L, 45L, 18L, 24L, 25L, 26L, : sum not meaningful for factors* Attached is the data. Not sure why it is all factors and when I tried changing to double precision the times were corrupted. I recall that R does not do well with time values. Do I need a line using chron as well beforehand? I even tried for several hours looking at the ReshapeGUI package to see what I may have been doing incorrectly to no avail. 1. What I need to do to analyze all the data in another program is to reformat it so that I have a Species by Time matrix summarized in 5 minute time blocks. The result needs to be Species as rows, and time intervals are arranged chronologically in columns. 2. Then I need the matrix converted such that each unique Species will have proportional abundances of time (0 to 100) so totals for each species should be the same (or 100%). What do folks suggest? Plyr, Reshape2 or try tables? Thanks, Bruce -- Bruce W. Miller, PhD. Neotropical bat risk assessments If we lose the bats, we may lose much of the tropical vegetation and the lungs of the planet Using acoustic sampling to map species distributions for >15 years. Providing Interactive identification keys to the vocal signatures of New World Bats For various project details see: https://sites.google.com/site/batsoundservices/ Species LocationDateTime Myochi Chena pond 5/26/09 18:38 Lascin Chena pond 5/26/09 18:51 Lascin Chena pond 5/26/09 19:38 Lascin Chena pond 5/26/09 19:39 Tadbra Chena pond 5/26/09 19:47 Lasvar Chena pond 5/26/09 20:12 Lasvar Chena pond 5/26/09 20:16 Lasvar Chena pond 5/26/09 20:56 Lascin Chena pond 5/26/09 21:19 Tadbra Chena pond 5/26/09 21:20 Lascin Chena pond 5/26/09 22:47 Lascin Chena pond 5/26/09 22:56 Lasvar Chena pond 10/15/0920:51 Lasvar Chena pond 10/15/0920:55 Lasvar Chena pond 10/15/0920:56 Lasvar Chena pond 10/15/0920:57 Lasvar Chena pond 10/15/0920:59 Myochi Chena pond 10/15/0921:00 Myochi Chena pond 10/15/0921:26 Lascin Chena pond 10/15/0921:29 Lasvar Chena pond 10/15/0921:33 Lasvar Chena pond 10/15/0921:34 Lasvar Chena pond 10/15/0921:35 Myochi Chena pond 10/15/0921:55 Lasvar Chena pond 10/15/0921:56 Lascin Chena pond 10/15/0921:59 Lascin Chena pond 10/15/0922:00 Lascin Chena pond 10/15/0922:01 Myochi Chena pond 10/15/0922:03 Myochi Chena pond 10/15/0922:08 Myochi Chena pond 10/15/0922:08 Myochi Chena pond 10/15/0922:09 Lascin Chena pond 10/15/0922:17 Lasvar Chena pond 10/15/0922:23 Lasvar Chena pond 10/15/0922:24 Myochi Chena pond 10/15/0922:26 Lasvar Chena pond 10/15/0922:30 Lasvar Chena pond 10/15/0922:31 Lascin Chena pond 10/15/0922:42 Lasvar Chena pond 10/15/0922:42 Lasvar Chena pond 10/15/0922:44 Lascin Chena pond 10/15/0922:46 Lascin Chena pond 10/15/0922:49 Tadbra Chena pond 10/15/0922:49 Lascin Chena pond 10/15/0922:50 Lascin Chena pond 10/15/0922:51 Lascin Chena pond 10/15/0922:53 Lascin Chena pond 10/15/0922:54 Lascin Chena pond 10/15/0922:57 Lasvar Chena pond 10/15/0923:01 Lasvar Chena pond 10/15/0923:06 Lascin Chena pond 10/15/0923:08 Lasvar Chena pond 10/15/0923:09 Tadbra Chena pond 10/15/0923:14 Myochi Chena pond 10/15/0923:30 Myochi Chena pond 10/15/0923:31 Lasvar Chena pond 10/15/0923:33 Myochi Chena pond 10/15/0923:35 Myochi Chena pond 10/15/0923:35 Myochi Chena pond 10/15/0923:38 Lasvar Chena pond 10/15/0923:39 Lasvar Chena pond 10/15/0923:44 Tadbra Chena pond 10/15/0923:45 Lasvar Chena pond 10/15/0923:47 Lasvar Chena pond 10/15/0923:52 Lasvar Chena pond 10/15/09
[R] Replacing NA values solved
Hi all, Tnx for all the replies: Mike Colvin provided a simple answer in one step. Bats.cast <- dcast(data = Bats.melt, formula = Species ~ Location, fill =0) tnx all for the reminder of potential issues of willy nilly replacing missing data with zeros. In this case the 0 [zero value] for NAs is correct in this application as the NAs do not represent "missing data" but actually no occurrence of a critter in a given habitat location so the values need to be a 0. Tnx again, Bruce -- Bruce W. Miller, PhD. Neotropical bat risk assessments If we lose the bats, we may lose much of the tropical vegetation and the lungs of the planet Using acoustic sampling to map species distributions for >15 years. Providing Interactive identification keys to the vocal signatures of New World Bats For various project details see: https://sites.google.com/site/batsoundservices/ [[alternative HTML version deleted]] __ R-help@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.
[R] How to replace NA values
Hi all, I am using reshape2 to reformat a data frame and all is great using: Bats.melt <- melt(data = Bats) Bats.cast <- dcast(data = Bats.melt, formula = Species ~ Location) dput(Bats.cast,'C:/=Bat data working/Nica_new/Bats_niche.robj') write.csv(Bat.cast,'C:/=Bat data working/Nica_new/test_Niche.csv') The resulting file from both dput and write are great, however in order to run another R analysis I need to replace all the NA values in the output with a zero - 0 value. I have just been opening this in Excel and using a simple find NA replace with 0 and saving then reopening in R. There must be a simple way to do this in R. Any suggestions welcomed. -- Bruce W. Miller, PhD. Neotropical bat risk assessments If we lose the bats, we may lose much of the tropical vegetation and the lungs of the planet Using acoustic sampling to map species distributions for >15 years. Providing Interactive identification keys to the vocal signatures of New World Bats For various project details see: https://sites.google.com/site/batsoundservices/ [[alternative HTML version deleted]] __ R-help@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.
[R] reshape2 issue solved Tnx!
Hi again all, As the original code lines I had dated back to 2007 that may have predated reshape2? In any case the use of *dcast *rather than /*cast*/ solved the issue. Then with 3 steps: Stop read Think I saw I just needed to change the line input.cast <- cast(input.melt, Species ~ *Date*, fun.aggregate = sum) to input.cast <- cast(input.melt, Species ~ *Time*, fun.aggregate = sum) ...and it all works as expected and needed. Thanks again all who replied. Bruce [[alternative HTML version deleted]] __ R-help@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.
[R] reshape2 issue continued
Hi again all, Several replied ASAP that I also needed reshape loaded and not just reshape2. Hmmm tried that and I had some output but not the correct format. What I need is to run simulations of time overlap between species as per the simulation program data input constraints: The basis for the simulations is a species by _time-use matrix in which species are arranged in rows, and time intervals are arranged chronologically in columns.___ TimeOverlap only uses text tab-delimited files with no headings for columns or rows.Empirical data must be specified in proportional abundances (0 to 100) and totals for each species should be the same (100%). With the existing code the result was rows were correct for species but dates were used for columns rather than the times. The input file read has long format 4 columns - species; location; date; time. It dawns on me I may need to have a sub sample of the main data set by Location ID first then have the code run but for time values and not dates. I need to tweak this a bit more to see if I can figure that out as well. I will have many repetitions of this dat reformatting so it is important I get the code correct one time so I can run this on the gazillion or so data sets accumulated. Rather than use reshape can I use _recast_ in place of cast and stick with reshape2? Bruce [[alternative HTML version deleted]] __ R-help@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.
[R] reshape2 issue
Hi all, I am revisiting using reshape2 to aggregate critter (bats) occurrences by time blocks and have the final output for each row sum a percentage such that the row sums total 1 (100%). Reshape2 library is loaded on start. The old code I had stored in NotePad++ seems to no longer work as I have the following error: > input.cast <- cast(input.melt, Species ~ Date, fun.aggregate = sum) *Error: could not find function "cast"* The code saved in NotePad++ is: require(reshape2) input.melt <- melt(input) input.cast <- cast(input.melt, Species ~ Date, fun.aggregate = sum) input.percent <- input.cast[, -1] / rowSums(input.cast[, -1]) * 100 rownames(input.percent) <- input.cast[,1] The data is read in OK: >Escameca_temporal <- read.table("C:/=Bat data working/=Nica_new/Escameca_temporal.CSV",header=T,sep=",",quote="") #then renamed : >input <-Escameca_temporal The variable view shows Species (6 letter text code) as Factor;Location code as integer; Date as Factor; Time as Factor. Data looks like this (sub sample only) Species LocationDateTime Cynmex 49375/3/201223:42 Cynmex 49375/3/201223:43 Cynmex 49375/3/201223:43 Eptfur 49375/2/20120:10 Eptfur 49375/2/20120:12 Eptfur 49375/2/20120:15 Eptfur 49375/2/20120:16 Eptfur 49375/2/20120:21 Eptfur 49375/2/20120:27 Eptfur 49375/2/20120:27 Eptfur 49375/2/20120:36 Eptfur 49375/2/20120:37 Eptfur 49375/2/20120:38 Eptfur 49375/2/20120:42 Eptfur 49375/2/20120:57 Eptfur 49375/2/20120:58 Eptfur 49375/2/20120:59 Eptfur 49375/2/20121:01 Eptfur 49375/2/20121:03 Eptfur 49375/2/20121:08 Eptfur 49375/4/20122:02 Eptfur 49375/4/20122:03 Eptfur 49375/4/20122:03 Eptfur 49375/4/20122:04 Eptfur 49375/4/20122:04 Eptfur 49375/4/20122:08 Eptfur 49241/8/20122:09 Eptfur 49375/4/20122:09 Eptfur 49241/8/20122:10 Eptfur 49241/8/20122:10 Eptfur 49241/8/20122:10 Eptfur 49241/8/20122:10 Eptfur 49241/8/20122:11 Eptfur 49241/8/20122:11 Eptfur 49241/8/20122:11 Eptfur 49241/8/20122:11 Eptfur 49241/8/20122:11 Eptfur 49241/8/20122:12 Eptfur 49241/8/20122:12 Eptfur 49241/8/20122:12 Eptfur 49241/8/20122:12 Eptfur 49241/8/20122:12 Eptfur 49241/8/20122:13 Eptfur 49241/8/20122:13 Eptfur 49375/4/20122:13 Eptfur 49241/8/20122:14 Eptfur 49241/8/20122:14 Eptfur 49241/8/20122:14 Eptfur 49241/8/20122:14 Eptfur 49375/4/20122:14 Eptfur 49241/8/20122:15 Eptfur 49241/8/20122:15 Eptfur 49241/8/20122:15 Eptfur 49241/8/20122:16 Eptfur 49241/8/20122:16 Eptfur 49241/8/20122:16 Eptfur 49241/8/20122:16 Eptfur 49241/8/20122:17 Any suggestions-help appreciated. Bruce -- Bruce W. Miller, PhD. Neotropical bat risk assessments If we lose the bats, we may lose much of the tropical vegetation and the lungs of the planet Using acoustic sampling to map species distributions for >15 years. Providing Interactive identification keys to the vocal signatures of New World Bats For various project details see: https://sites.google.com/site/batsoundservices/ [[alternative HTML version deleted]] __ R-help@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.
Re: [R] R-help Digest, Vol 123, Issue 30
Hi all are there any R packages that include "circular" stats similar to Oriana (http://www.kovcomp.co.uk/oriana/newver4.html)? I am interested in looking at annual patterns of bat activity where data will have date/times and relative abundance values for each Date. I would like to have a circular plot with the "circumference" axis the 12 months of the year and then a value of relative abundance and likely with ggplot2 this can be set to color= species. Tnx Bruce __ R-help@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.
[R] How does one set up logical functions?
Hi all, I am trying to set up logical function(s) to deal with two adjustments to a blood glucose value. I have been dinking around in Excel and assume this will be much easier in R. DF is date-time, BG value in mg/dL,test strip 4/3/13 19:20105 Aviva-491350 4/4/13 21:0374 Aviva-491350 4/6/13 17:4081 Aviva-491640 4/6/13 17:4082 Aviva-491350 4/6/13 22:48106 Aviva-491640 4/6/13 22:48102 Aviva-491350 4/7/13 5:32 87 Aviva-491350 4/7/13 5:32 103 Aviva-491640 What I need are the high and low ranges based on "acceptable" standards of the measured values. The logical expressions need to be IF BG =>100 then "High limit" would = (BG+(BG*.15)) IF BG =>100 then "Low limit" would = (BG-(BG*.15)) and IF BG <100 then "High limit" would = (BG+15) IF BG <100 then "Low limit" would = (BG-15) The standards are written as: 95% of the individual glucose results shall fall within ±15 mg/dL of the reference results at glucose concentrations less than 100 mg/dL and within ±15% at glucose concentrations greater than or equal to 100 mg/dL. Then I need to plot the measured value and also show the high & low "acceptable" values. Thanks for any who respond. Bruce -- Bruce W. Miller, PhD. Neotropical bat risk assessments If we lose the bats, we may lose much of the tropical vegetation and the lungs of the planet Using acoustic sampling to map species distributions for >15 years. Providing Interactive identification keys to the vocal signatures of New World Bats For various project details see: https://sites.google.com/site/batsoundservices/ [[alternative HTML version deleted]] __ R-help@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.
[R] Merging data tables
Hi all, I am trying to merge several data sets and end up with a long data format by date & time so I can run correlations and plots. I am using Deducer as an R GUI but can just use the R console if easier. The data sets are weather with wind speed, relative humidity and temperatures by date and minute and bat activity with date, time, label, and an activity index number. The bat activity is only during the nocturnal time frames while the weather data was recorded for 24 hours. Therefore a lot of weather data with no related activity for bats. I have failed so far to achieve what I need and tried plyr and reshape2. There are many Null data rows with no data or 0 (zero) for wind speed.. What other tools steps would be more appropriate short of manually in Excel cutting and pasting for a day or more? Data formats are: bat activity DateTimeLabel Number 6/3/201110:01 Tadbra 2 6/3/201110:02 Tadbra 4 6/3/201110:08 Tadbra 1 6/3/201110:13 Tadbra 2 6/3/201110:49 Tadbra 2 6/3/201110:51 Tadbra 2 6/3/201110:52 Tadbra 4 Weather: datetimeTemp_I Temp_E RH mph_a mph_x 6/3/20110:0015 15.730.44.4 15.5 6/3/20110:3015 15.231.65.7 11.2 6/3/20111:0015 15.131.310.317.5 6/3/20111:3014 13.644.54.7 12.1 6/3/20112:0012.513.237.92.1 6.5 6/3/20112:3012.513.535.36.3 10.1 6/3/20113:0012 12.137.73 7.4 6/3/20113:3011.511.538.73.4 6 6/3/20114:0010 9.9 52.71.4 4.2 6/3/20114:309.5 9.1 43.21.3 3.8 6/3/20115:008 8.7 59.21.2 3.1 6/3/20115:307 8 62.51.1 4.2 6/3/20116:006 7.8 47.80.5 2.2 6/3/20116:307.5 11.537.51.7 3.8 6/3/20117:0010.514 33.10.6 2.2 6/3/20117:3014 17.332.11.6 3.6 6/3/20118:0017.520.323.90.4 2 6/3/20118:3021.522.820.70.4 1.8 6/3/20119:0024.524.914.10.3 2.2 6/3/20119:3026 26.920.31.7 5.6 6/3/201110:00 27.527.420.72.5 6.5 6/3/201110:30 28.529.810 1.6 4.2 6/3/201111:00 29.529.49.8 1.8 4 6/3/201111:30 30 29.99.2 2.7 7.8 Tnx for any suggestions, Bruce [[alternative HTML version deleted]] __ R-help@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.
[R] Removing duplicated values
Hi all, I have been away from R for far too many months and have two questions. One is likely simple, but not found under help or in many of the available R ref., books. 1. How does one save the results of an analysis from the main console to a file without the need to copy and paste? 2. What tools (possibly Plyr or reshape) can be used to remove duplicated entries in a data matrix? I have some 650,000 records in a table (text values for most fields) that were imported form a number of sources and now I find that table is inflated by anywhere from 2-20 duplicated entries. I need to remove all dupes and only retain unique values. Excel is choking on this so I thought R would be a better and more efficient option. Tnx, Bruce __ R-help@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.
[R] Suggestions for RAM for new box
Hi all, My main Dell melted down a month ago and I need to buy a new workstation. It will be Win7 64 bit and fast graphics card with large RAM. For GIS (ArcGis) I am opting for 6 GB RAM. Is there any advantage for R to boost this to 8 GB or will 6 GB be sufficient for R applications? There have been a lot of discussion about "Big Memory" issues with R. __ R-help@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.
[R] How to open files that contain "0"
Hi all, How can I set open files that contain values of Zero =0? These are valid values for the parameters I need to evaluate. I have tried CSV and tab formats. Trying XL Connect and/or XLConnectJars dies not seem to work to open Excel files so I am at a loss on how to get the data into a DF. Sample of data with 0 values: FilenameDur TBC FmaxFminFmean Fc S1 Sc Pmc g8221843.13#5.060 38.93 36.237.96 36.45 -34.08 192.69 6.8 g8221843.13#0.415.2938.83 36.04 38.83 38.83 -261.93 -513.05 0 g8221843.13#0.660.6835.71 33.436.42 35.63 -238.04 -392.06 0.2 g8221843.13#0.5854.84 42.78 40.341.140.3410 0 6.2 This message is displayed in the console: > BASCTWS <- read.table("C:/=Bat data working/R/BASCTWS.txt",header=T,sep="\t",quote="") Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 1 did not have 10 elements > Obviously I am missing something basic, seems I was able to do this in the past. Bruce -- Bruce W. Miller, Ph.D. Conservation Ecologist Neotropical Bat Project office details Gallon Jug, Belize Mailing address P.O. Box 37, Belize City Belize, Central America Phone +501-220-9002 -- Bruce W. Miller, PhD. Neotropical bat risk assessments If we lose the bats, we may lose much of the tropical vegetation and the lungs of the planet Using acoustic sampling to map species distributions for>15 years. Providing Interactive identification keys to the vocal signatures of New World Bats For various project details see: https://sites.google.com/site/batsoundservices/ [[alternative HTML version deleted]] __ R-help@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.
[R] issue using package sos
Issue with sos package I am now using R 2.14 and the sos package did work with 2.13 > library(sos) Loading required package: brew Attaching package: 'sos' The following object(s) are masked from 'package:JGR': installPackages The following object(s) are masked from 'package:utils': > library("sos"); findFn("random forest") found 253 matches; retrieving 13 pages 2 3 4 5 6 7 8 9 10 11 12 13 ++ the first part looks as it used to int he past...but now I have the follow errors? URL Error no protocol: null/doc/html/packages.html Click OK then another box pops up URL Error unkonwn protocl: c Clicked OK Then the help window opens Top line isted is C:\Documents~\temp\RtmpE3Letk\fileaa2 When I select the other tab packages .. it is blank. As always clueless in Belize, Bruce __ R-help@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.
[R] New PLYR issue
Issue with PLYR. Now using R 2.14 and this data and plyr command line worked with 2.13 I am also loading the same saved data that worked previously, but now some issue. > library(plyr) > UNESCO <- dget('C:/Carbon-GJ/BZE_ecosys.robj') > df2 <- ddply(df, "UNESCO", summarise, total_ha = sum(Ha)) *Error in if (empty(.data)) return(.data) : missing value where TRUE/FALSE needed* Clueless Ideas suggestions? Some change in PLYR? Bruce [[alternative HTML version deleted]] __ R-help@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.
[R] How to update an old unsupported package
Hi all, I have a package that is specific to a task I was repetitively using a few years ago. I now needed to run it again with new data. However I am told it was built with an older version or R and will not work. How can I tweak the package so it will run on 11.1? It was a one-off product and has not been maintained. Is there a way to "unpackage" it and repackage it to work? I tried just changing the date and R version in the DESCRIPTION file but that did not help. Tnx Bruce __ R-help@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.
Re: [R] R-help Digest, Vol 77, Issue 13
Hi all, Where can I find detail of use of seewave? Seems no help included in the package using ??seewave does not provide anything. Tnx __ R-help@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.
[R] Out of memory issue
Hi again all, I can read all of the data is in CSV format with a header row and with 1,200,240 rows. I can do all the plots and ggplot2 has no problems. Seems to be a problem with the MASS package??? It seems that the contour plots are the problem with the memory error. Error: cannot allocate vector of size 228.9 Mb I can run smaller data sets and do the contour plots w/o problems. The data can not really be summarized as I need to plot the actual values to get the insight into the large data sets. I am using latest R version 2.9.0 (2009-04-17) My alternative is to bump up the memory of my one Dell workstation to 16 GB as it runs with Ubuntu and can access that amount if I figure out how to install R on a Linux box. It may not truly be a memory issue but a limit to how MASS does the contour plots? This works 100% with the large data sets. Bodega <- read.csv ("C:/R-Stats/Bat calls/Bodega.csv") attach(Bodega) library(ggplot2) f=jpeg(file="Bodega Sc_Fc plot.jpg") print(qplot(Sc, Fc)) dev.off() f=jpeg(file="Bodega Fc Dens plot.jpg") print(qplot(Fc,geom="density")) dev.off() This does not.and I get the vector size error. library(MASS) library(batcalls) BRC<-kde2d(Sc,Fc) f=jpeg(file="Rainey contour plot.jpg") filled.contour(BRC) dev.off() Thanks again for in sight as I trundle up the learn curve for R. Bruce __ R-help@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.
[R] Install packages not working in latest version?
Seems that the latest version R version 2.9.0 (2009-04-17) has a glitch and will not install packages. Issue with unzipping? Works fine with R version 2.8.1 (2008-12-22) > install.packages("ff") --- Please select a CRAN mirror for use in this session --- trying URL 'http://cran.fhcrc.org/bin/windows/contrib/2.9/ff_2.0.1.zip' Content type 'application/zip' length 779664 bytes (761 Kb) opened URL downloaded 761 Kb Error in .Internal(int.unzip(zipname, NULL, dest)) : no internal function "int.unzip" > Bruce __ R-help@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.
[R] Memory issues in R
How do people deal with R and memory issues? I have tried using gc() to see how much memory is used at each step. Scanned Crawley R-Book and all other R books I have available and the FAQ on-line but no help really found. Running WinXP Pro (32 bit) with 4 GB RAM. One SATA drive pair is in RAID 0 configuration with 1 MB allocated as virtual memory. I do have another machine set up with Ubuntu but it only has 2 GB RAM and have not been able to get R installed on that system. I can run smaller sample data sets w/o problems and everything plots as needed. However I need to review large data sets. Using latest R version 2.9.0 (2009-04-17) My data is in CSV format with a header row and is a big data set with 1,200,240 rows! E.g. below: Dur,TBC,Fmax,Fmin,Fmean,Fc,S1,Sc, 9.81,0,28.78,24.54,26.49,25.81,48.84,14.78, 4.79,1838.47,37.21,29.41,31.76,29.52,241.77,62.83, 4.21,5.42,28.99,26.23,27.53,27.4,76.03,11.44, 10.69,193.48,30.53,25.4,27.69,25.4,-208.19,26.05, 15.5,248.18,30.77,24.32,26.57,24.92,-202.76,18.64, 14.85,217.47,31.25,24.62,26.93,25.56,-88.4,10.32, 11.86,158.01,33.61,25.24,27.66,25.32,83.32,17.62, 14.05,229.74,30.65,24.24,26.76,25.24,61.87,14.06, 8.71,264.02,31.01,25.72,27.56,25.72,253.18,19.2, 3.91,10.3,25.32,24.02,24.55,24.02,-71.67,16.83, 16.11,242.21,29.85,24.02,26.07,24.62,79.45,19.11, 16.81,246.48,28.57,23.05,25.46,23.81,-179.82,15.95, 16.93,255.09,28.78,23.19,25.75,24.1,-112.21,16.38, 5.12,107.16,32,29.41,30.46,29.41,134.45,20.88, 16.7,150.49,27.97,22.92,24.91,23.95,42.96,16.81 etc I am getting the following warning/error message: Error: cannot allocate vector of size 228.9 Mb Complete listing from R console below: > library(batcalls) Loading required package: ggplot2 Loading required package: proto Loading required package: grid Loading required package: reshape Loading required package: plyr Attaching package: 'ggplot2' The following object(s) are masked from package:grid : nullGrob > gc() used (Mb) gc trigger (Mb) max used (Mb) Ncells 186251 5.0 407500 10.9 35 9.4 Vcells 98245 0.8 786432 6.0 358194 2.8 > BR <- read.csv ("C:/R-Stats/Bat calls/Reduced bats.csv") > gc() used (Mb) gc trigger (Mb) max used (Mb) Ncells 188034 5.1 667722 17.9 378266 10.2 Vcells 9733249 74.3 20547202 156.8 20535538 156.7 > attach(BR) > library(ggplot2) > library(MASS) > library(batcalls) > BRC<-kde2d(Sc,Fc) Error: cannot allocate vector of size 228.9 Mb > gc() used (Mb) gc trigger (Mb) max used (Mb) Ncells 198547 5.4 667722 17.9378266 10.2 Vcells 19339695 147.6 106768803 814.6 124960863 953.4 > Tnx for any insight, Bruce __ R-help@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.
[R] Out of memory issue
Hi all, Julian just reminded me I need to include the lines of code so here it is below. I am trying to run some plots on data, but when loading the CSV data file it doss that but in ggplot R is stopping and I am getting an out of memory error. > > d <- read.csv batcalls.rda Error: unexpected symbol in "d <- read.csv batcalls.rda" > attach(d) Error in attach(d) : object "d" not found > library(ggplot2) > print(qplot(Sc, Fc)) Error in eval(expr, envir, enclos) : object "Sc" not found > data(batcalls) > attach(batcalls) > print(qplot(Fc,geom="density")) > b<-kmeans(Fc,c(10,15,18,30)) >print(qplot(Sc,Fc,colour=as.factor(b$cluster))) > > print(qplot(Dur,geom="density")) > b<-kmeans(Dur,c(10,15,18,30)) >print(qplot(Dur,Fc,colour=as.factor(b$cluster))) > d <- read.csv ("C:/Rainey/RainyAllbats.csv") > attach(d) The following object(s) are masked from batcalls : Dc Dur Fc Fk Fmax Fmean Fmin Qk Qual S1 Sc st TBC Tc Tk > library(ggplot2) > print(qplot(Sc, Fc)) Warning messages: 1: In data.frame(..., check.names = FALSE) : Reached total allocation of 1535Mb: see help(memory.size) 2: In data.frame(..., check.names = FALSE) : Reached total allocation of 1535Mb: see help(memory.size) 3: Removed 1200249 rows containing missing values (geom_point). > data(d) Warning message: In data(d) : data set 'd' not found > attach(d) The following object(s) are masked from d ( position 3 ) : Dc Dur Fc Filename Fk Fmax Fmean Fmin Qk Qual S1 Sc st TBC Tc Tk The following object(s) are masked from batcalls : Dc Dur Fc Fk Fmax Fmean Fmin Qk Qual S1 Sc st TBC Tc Tk > print(qplot(Fc,geom="density")) There were 15 warnings (use warnings() to see them) > b<-kmeans(Fc,c(10,15,18,30)) Error in switch(nmeth, { : NA/NaN/Inf in foreign function call (arg 1) > f=jpeg(file="Sc x Fc.jpg") >print(qplot(Sc,Fc,colour=as.factor(b$cluster))) Error in data.frame(colour = c(3L, 4L, 4L, 4L, 4L, 1L, 4L, 2L, 1L, 1L, : arguments imply differing number of rows: 9404, 2400489 > dev.off() Anyway to tweak this somehow to get it to run? Using WinXP with 4 GB RAM Tnx Bruce __ R-help@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.
[R] Out of memory issue
Hi all, I am trying to run some plots on data, but when loading he CSV data file R is stopping and I am getting an out of memory error. Anyway to tweak this somehow to get it to run? Using WinXP with 4 GB RAM Tnx Bruce __ R-help@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.
[R] Converting time from HH:MM:SS to only HH:MM
Hi all, I need to compare between times and put all similar times in specific 1 minute bins. Unfortunately the original data include seconds as well. My data is in HH:MM:SS format but I need it rounded to only HH:MM and trying in Excel to display "unique" records only does not work since the seconds are not unique. Is there an easy way using perhaps CHRON to change all from the HH:MM:SS data to a new HH:MM only data set and save as a TXT or CSV file? Tnx __ R-help@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.
[R] Time Zone query
I am working with time-date data to plot temporal activity. I would like to create a "template" to repeat the date and time for all potential data sets that may have differing time zone origins. Reading the > ?strptime help section I note that time zone is a variable to add. Looking at the output of a sample data set Species LocationDate Time 1 SppaaaOne 1/13/2009 17:00 2 SppaaaOne 1/13/2009 18:00 3 SppaaaOne 1/13/2009 19:00 4 SppaaaOne 1/13/2009 20:00 5 SppaaaOne 1/13/2009 21:00... in order to understand how R is handling this and using: > All$Time <- as.POSIXct(strptime(as.character(d$Time), "%H:%M")) > All$Time [1] "2009-03-14 17:00:00 CST" "2009-03-14 18:00:00 CST" [3] "2009-03-14 19:00:00 CST" "2009-03-14 20:00:00 CST" [5] "2009-03-14 21:00:00 CST" "2009-03-14 22:00:00 CST" It appears that the default is using CST and this is I assume based on my system setting for my PC time. Is there a way to NOT have it do this as the data I am processing are from a different time zone. Tnx Bruce __ R-help@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.
[R] User manual or tutorial for GAM package
Hi all, Tnx for the number of suggestion to buy one of the books. Unfortunately being a non profit conservation project now w/o funding since all Central American projects were shut down 2 years ago due to lack of donor funding I have nothing now at all for books or even my support, to cover expenses. I am trying to wrap up several risk assessments w/o funding. Tnx again everyone is very helpful on the list as are those on the ggplot list. Cheers from the jungles of Belize, Bruce __ R-help@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.
[R] User manual or tutorial for GAM package
Hi all, I would like to run the gam package, but can not quite seem to get the syntax correct for my data format as simple as it is. The gamlss package has a user manual but other than the help with gam package I can not find a user manual per se. I did install the gamair that has loads of sample data so perhaps trail and error with my data I can get something to work. Anyone who can point me to a link for a download tutorial? Climbing the steep learning curve and spending a hour or so per day is beginning to pay off with most areas of R Tnx __ R-help@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.
[R] Problems with labeling a set X axis in chron plots
I am having difficulties getting the X-axis labels (dates) to be as needed when plotting from chron The help syntax from chron lists this example: x <- chron(dates = c("02/27/92", "02/27/92", "01/14/92", "02/28/92"), I have activity plots by time on the y-axis and the dates on the x-axis. What I need/want is that the dates remain the same for a give set of data i.e. 10/25/2006 to 03/30/2007 as with some data sets within this time frame there is no activity for all of the dates so each plot has a different set of dates. Below works great but when I try to constrain the dates it crashes... DF <- read.table(textConnection(Lines), header = TRUE, as.is = TRUE) DF$Date <- chron(DF$Date) DF$Time <- times(paste(DF$Time, 0, sep = ":")) at <- c(0, 1, 2, 3, 4, 5, 6, 17, 18, 19, 20, 21, 22, 23, 24) plot(Time ~ Date, DF, ylim = 0:1, yaxt = "n",main= "Centronycteris centralis") axis(2, at/24, lab = paste(at, "00", sep = ":"), las = 1, cex.axis = .7) Thanks to all here on the group, Bruce Miller __ R-help@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.
[R] meaning of warning messages
Hi all, Read a string of data and had this message during a plot run. Warning message: closing unused connection 3 (Lines) Not sure what this means or if it should be of concern. Tnx. __ R-help@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.
[R] Suggestions on which package to use
Hi all, I have been working with the chron package thanks to some guidance from Gabor Grothendieck so I could plot activity by times. What it the best or "recommended" package to compare such activity between sites? I want to compare the acetify time (multiple bat species) between sites and species to see if there is any significantly difference so I can infer some habitat preference or resource availability. Tnx. __ R-help@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.
[R] plotting time and dates revisited
__ R-help@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.
[R] Zoo for plotting time and dates
Hi all, For some reason the messages keep getting rejected. trying again... As I understand the zoo package will aggregate dates and times, but unclear how to tackle this problem. I need to accomplish the following: 1. Generate a scatter plot of bat activity with dates on the X-axis and time on the Y-axis. include sunset and sunrise curves as an added part of graphic. In Excel I have a kludged way to do this, but it is not exactly what I need and the times on the Y axis do not display correctly due to the 24:00 roll over to next date and would prefer to understand how to do this using R so I can repeat it with multiple data sets for multiple locations. I removed the Graphic display as apparently the server refused the massage with it. I can email directly if anyone is able to assist or wished to see it. A sample of the data format is below. Any suggestion welcome. Tnx. The bat activity data is in the format below with the species name, date and time the species was active. Spec_code DateTime Eptfus 6/4/03 22:44 Eptfus 6/4/03 22:44 Eptfus 6/9/03 21:59 Eptfus 6/10/03 3:24 Eptfus 6/13/03 0:22 Eptfus 6/13/03 3:24 Eptfus 6/17/03 0:03 Eptfus 6/17/03 2:43 Eptfus 6/17/03 21:59 The sunset-Sunrise data seen below is also straight forward: Date RiseSet 6/1/20034:1219:50 6/2/20034:1119:51 6/3/20034:1019:52 6/4/20034:1019:53 6/5/20034:0919:54 6/6/20034:0919:54 6/7/20034:0919:55 6/8/20034:0819:56 6/9/20034:0819:57 6/10/2003 4:0819:57 6/11/2003 4:0719:58 6/12/2003 4:0719:58 6/13/2003 4:0719:59 6/14/2003 4:0719:59 6/15/2003 4:0720:00 6/16/2003 4:0720:00 6/17/2003 4:0720:01 6/18/2003 4:0720:01 __ R-help@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.
[R] Plotting activity by time and dates
Hi all, As I understand the zoo package will aggregate dates and times, but unclear how to tackle this problem. I need to accomplish the following: 1. Generate a scatter plot of bat activity with dates on the X-axis and time on the Y-axis. include sunset and sunrise curves as an added part of graphic. In Excel I have a kludged way to do this, but it is not exactly what I need and the times on the Y axis do not display correctly due to the 24:00 roll over to next date and would prefer to understand how to do this using R so I can repeat it with multiple data sets for multiple locations. I removed the Graphic display as apparently the server refused the massage with it. I can email directly if anyone is able to assist or wished to see it. A sample of the data format is below. Any suggestion welcome. Tnx. The bat activity data is in the format below with the species name, date and time the species was active. Spec_code DateTime Eptfus 6/4/03 22:44 Eptfus 6/4/03 22:44 Eptfus 6/9/03 21:59 Eptfus 6/10/03 3:24 Eptfus 6/13/03 0:22 Eptfus 6/13/03 3:24 Eptfus 6/17/03 0:03 Eptfus 6/17/03 2:43 Eptfus 6/17/03 21:59 The sunset-Sunrise data seen below is also straight forward: Date RiseSet 6/1/20034:1219:50 6/2/20034:1119:51 6/3/20034:1019:52 6/4/20034:1019:53 6/5/20034:0919:54 6/6/20034:0919:54 6/7/20034:0919:55 6/8/20034:0819:56 6/9/20034:0819:57 6/10/2003 4:0819:57 6/11/2003 4:0719:58 6/12/2003 4:0719:58 6/13/2003 4:0719:59 6/14/2003 4:0719:59 6/15/2003 4:0720:00 6/16/2003 4:0720:00 6/17/2003 4:0720:01 6/18/2003 4:0720:01 __ R-help@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.