[R] a function more appropriate than 'sapply'?

2013-01-26 Thread emorway
I'm wondering if I need to use a function other than sapply as the following line of code runs indefinitely (or > 30 min so far) and uses up all 16Gb of memory on my machine for what seems like a very small dataset (data attached in a txt file wells.txt

Re: [R] resizing data

2013-01-25 Thread emorway
I played around with your example on the smaller dataset, and it seemed like it was doing what I wanted. However, applying it to the larger problem, I didn't get a resized 2D dataset that preserved the order I was hoping for. Hopefully the following illustrates the larger problem: x<-matrix(0,nr

[R] resizing data

2013-01-25 Thread emorway
Undoubtedly this question has been asked before, I just can't seem to find the combination of search terms to produce it. I'm trying to resize a dataset that is pulled into R using read.table. However, I think the same problem can be produced using matrix: x<-matrix(1:64,8) x # [,1] [,2] [,3

Re: [R] setting off-diagonals to zero

2013-01-23 Thread emorway
I'm not following. Printing SEQ to the screen at the intermediate steps using the following modified R code suggests that 'i' is fine and is not getting reset to 1 as you suggest? My understanding, or rather my desired output if someone else is able to weight-in, is that the values in the second

[R] setting off-diagonals to zero

2013-01-23 Thread emorway
The following 1460 x 1460 matrix can be throught of as 16 distinct 365 x 365 matrices. I'm trying to set off-diaganol terms in the 16 sub-matrices with indices more than +/- 5 (days) from each other to zero using some for loops. This works well for some, but not all, of the for loops. The R code

Re: [R] Filling a covariance matrix

2012-10-31 Thread emorway
Hi Joshua, The code you put together is very helpful. I have run into a small issue, however, and I am surprised you weren't getting similar error message when you tried running the nested for loops? As an example, I've pared down the for loop a bit to highlight the error message I'm getting (no

[R] Filling a covariance matrix

2012-10-23 Thread emorway
useRs – I’m working with the attached data that contains one year’s worth of sub-daily observations of flow (“Q”) and specific conductance (“SC”, a surrogate for concentration) at a point in a stream. The R code posted below shows the extent of data processing thus far. My goal is to create a co

Re: [R] calculate within-day correlations

2012-09-14 Thread emorway
Hi Joshua, I was attempting to work with your code on the larger datasets, which I have to read in with 'read.table', but I've apparently missed something. When I attempt to massage the data.frame a bit in the code below, as.POSIXct drops the time component which then precludes use of xts. I t

[R] calculate within-day correlations

2012-09-13 Thread emorway
useRs, Here is some R-ready data for my question to follow. Of course this data is small snippet from a much larger dataset that is about a decade long. Q<-read.table(textConnection("2002 3 28 15 77.38815 2002 3 28 30 77.09505 2002 3 28 45 76.80196 2002 3 28 60 7

Re: [R] Problem with converting character vector to time

2012-06-23 Thread emorway
It's not entirely clear where your trying to go with your problem, but one 'solution' depending on your destination could be: time_obj<-format(as.POSIXct(test,format="%H:%M:%S"),format="%H:%M:%S") > time_obj [1] "00:49:19" > class(time_obj) [1] "character" But this is a fairly unsatisfactory sol

Re: [R] extracting values from txt file that follow user-supplied quote

2012-06-08 Thread emorway
I'll summarize the results in terms of total run time for the suggestions that have been made as well as post the code for those that come across this post in the future. First the results (the code for which is provided second): What I tried to do using suggestions from Bert and Dan: t1 # user

Re: [R] extracting values from txt with regular expression

2012-06-07 Thread emorway
Hi Dan and Rui, Thank you for the suggestions, both were very helpful. Rui's code was quite fast...there is one more thing I want to explore for my own edification, but first I need some help fixing the code below, which is a slight modification to Dan's suggestion. It'll no doubt be tough to be

[R] extracting values from txt with regular expression

2012-06-07 Thread emorway
Thanks for your suggestions. Bert, in your response you raised my awareness to "regular expressions". Are regular expressions the same across various languages? Consider the following line of text: txt_line<-" PERCENT DISCREPANCY = 0.01 PERCENT DISCREPANCY = -0.05" It s

[R] extracting values from txt file that follow user-supplied quote

2012-06-06 Thread emorway
useRs- I'm attempting to scan a more than 1Gb text file and read and store the values that follow a specific key-phrase that is repeated multiple time throughout the file. A snippet of the text file I'm trying to read is attached. The text file is a dumping ground for various aspects of the per

[R] obtaining a true/false vector with combination of strsplit, length, unlist,

2012-02-11 Thread emorway
Hi, A pared down version of the dataset I'm working with: edm<-read.table(textConnection("WELLIDX_GRID Y_GRID LAYER ROW COLUMN SPECIES CALCULATED OBSERVED w301_3 4428. 1389 2 6 18 1 3558 6490. w304_12 4836. 6627 2 27 20

[R] legend, "lheight", and alignment

2011-12-01 Thread emorway
Hello, A bit of fairly simple code, yet I don't seem to be able to manipulate it quite as much as I would like: 1) It would be nice if the objects appearing in the legend were aligned, and by aligned I mean the boxes are centered over the lines. Do I need to adjust the use of "NA" in the code b

Re: [R] subplot strange behavoir

2011-10-21 Thread emorway
Hello Dr. Snow, With regard to your response from earlier this month: When I copy and paste your code I get what is expected, the 2 subplots line up on the same y-value. What version of R are you using, which version of subplot? What platform? I'm still troubled by the fact that layout and sub

Re: [R] contouring x y scatter data

2011-10-17 Thread emorway
Thank you David, I'm moving forward again. I was not aware of that website, I was recently at http://www.r-project.org/ and clicked on the 'mailing list' link and didn't see it there...with 8k+ posts, maybe its worth adding? -- View this message in context: http://r.789695.n4.nabble.com/conto

Re: [R] contouring x y scatter data

2011-10-17 Thread emorway
Hi Carlos, Thanks for the response. The plot you suggested was not in line with what I'm trying to produce in R. The last plot found at: http://www.advsofteng.com/gallery_contour.html is more along the lines of what I'm looking for. Notice the scatter points (shown by "x") are not laid o

[R] contouring x y scatter data

2011-10-17 Thread emorway
Hello, I'm almost positive R can do the following, I just haven't hit upon the right package or search terms, however. Here's what I'm after: I've got concentration output from two different models that I want to qualitatively compare in a contour plot (or some variant of a contour plot). The p

[R] Irregular 3d objects with rgl

2011-10-14 Thread emorway
Hello, While exploring if rgl is along the lines of what I need, I checked out demo("rgl") and didn't find quite what I'm looking for, and am therefore seeking additional help/suggestions. The application is geared towards displaying a 3D rendering of a contaminant plume in the subsurface wi

Re: [R] subplot strange behavoir

2011-10-05 Thread emorway
I tried this trick, and clearly things are not going in the right direction. It seems 'layout' is at the root of my frustration, so I can make two plots and marge them in adobe illustrator (or something similar). png("c:/temp/lookat.png",res=120,height=600,width=1200) layout(matrix(c(1,2),2,2,byr

Re: [R] subplot strange behavoir

2011-10-05 Thread emorway
Hello Greg, Session info is below. Running Win7 64-bit. I just upgraded my version of R and tried rerunning the code and got the same odd result. I, too, get an expected result when I create the plot in the R GUI. The problem crops up only when I try and create the plot in png() or tiff(). Pe

[R] subplot strange behavoir

2011-10-05 Thread emorway
Hello, Below is some example code that should reproduce an error I'm encountering while trying to create a tiff plot with two subplots. If I run just the following bit of code through the R GUI the result is what I'd like to have appear in the saved tiff image: x<-seq(0:20) y<-c(1,1,2,2,3,4,5,4

[R] animation error

2011-06-14 Thread emorway
ts,sep="")) ani.pause() #dev.off() } } saveMovie(plot.ani(),movie.name="concSlug.gif",img.name="ConcProfile",interval=0.15,outdir=getwd()) #Executing: #"C:/Program Files/ImageMagick-6.7.0-Q16/convert.exe" -loop 0 #-delay 15 #C:/Users

Re: [R] Help with filled.contour()

2011-04-02 Thread emorway
Michael, Although this is a rather old post I'm responding to, I recently came across it and have a suggestions for getting rid of the legend. Simply modify the code associated with the function and stuff it into a new function, edm<-function (x = seq(0, 1, length.out = nrow(z)), y = seq(0, 1,

[R] Plotting Finite Element and Finite Difference Results together

2011-03-18 Thread emorway
As a simplification of a much larger problem, I'm using the following simple example to explore ways of getting the finite difference results to plot over the same extents as the finite element solution (see figure). I haven't discovered (if it exist) a way of getting the finite difference data to

[R] Using 'contour' to compare concentration profiles on the same plot

2011-01-29 Thread emorway
Hello, Using the data and code below I've been using R to compare output from two different solute transport codes, the red contours are from verified code while the blue contours come from some modified code I've been working on. The goal is for the contours to match, and although there is curr

Re: [R] Fitting an Inverse Gamma Distribution

2011-01-14 Thread emorway
Hello David, Thank you for pointing me to the GeneralizedHyperbolic package. I've been playing around with hyperbFit with my data, but get: Warning Messages: In besselK(zeta, nu = 1) : value out of range in 'bessel_k' 10 Next, just to see if I could get something to plot I tried the

[R] Fitting an Inverse Gamma Distribution

2011-01-13 Thread emorway
http://r.789695.n4.nabble.com/file/n3216865/Inverse_Gamma.png Hello, I am seeking help in estimating the parameters of an inverse gamma distribution (from the 'actuar' package) using a function like 'fitdistr'. Unfortunately I haven't found such a package using findFn('fit Inverse Gamma') from

[R] Grid drawing over the filled.contour's legend

2011-01-13 Thread emorway
Hello, For a reason I can't seem to figure out (have searched posts on this forum for "filled.contour grid"), the grid (in the code below) is plotting over the legend that accompanies the filled.contour. The dataset has 40 columns and 20 rows. Where have I gone wrong? How can I draw a grid wi

Re: [R] Strange behavior when trying to piggyback off of "fitdistr"

2011-01-11 Thread emorway
Avi, Its been nearly a year since you made this post, but I'm curious if you were able to find a solution to your problem? Your inquiry is closely related to a problem I'm having. Thanks, Eric -- View this message in context: http://r.789695.n4.nabble.com/Strange-behavior-when-trying-to-pig

[R] Fitting an Inverse Gamma Distribution to Survey Data

2011-01-07 Thread emorway
Hello, I've been attempting to fit the data below with an inverse gamma distribution. The reason for this is outside proprietary software (@Risk) kicked back a Pearson5 (inverse gamma) as the best fitting distribution with a Chi-Sqr goodness-of-fit roughly 40% better than with a log-normal fit.

Re: [R] optim and singularity

2010-12-31 Thread emorway
Thanks Berend, setting lower=c(0,0.01) seems to have solved the problem. I have a dataset with 200+ cropped fields with associated data and wanted to generate each plot in a way that minimized the visual residuals between the green squares and blue circles. I have inserted a resulting plot so yo

Re: [R] optim and singularity

2010-12-30 Thread emorway
Hi Tom, I followed you suggestion and found the following: class(temp.dat$WTD) #[1] "numeric" temp.dat$WTD<-na.approx(temp.dat$WTD,as.numeric(as.Date(temp.dat$Meas_Date,"%m/%d/%Y"))) class(temp.dat$WTD) #[1] "numeric" Have I misunderstood you? If not, then my original confusion still stands..

[R] optim and singularity

2010-12-30 Thread emorway
Hello, I was unable to find clues to my problem in ?optim. Using the data and code below, I get an error ("system is exactly singular") when a particular line of code is left in, but have found that 'optim' works when I comment it out. The line of code in question is after the closeAllConnectio

[R] adjust secondary y-axis bounds to minimize visual residuals

2010-12-22 Thread emorway
Hello, I'm plotting two sets of data referenced to either the left or right y-axes. The first, water table depth (blue circles), is plotted on the left y-axis in reverse order (0 at the top) as this is more intuitive when thinking in terms of depth. The second is electrical conductance (a surro

[R] Formatting 'names.arg' in barplot

2010-12-08 Thread emorway
Hello, I've been looking through ?phantom and ?expression and this forum for examples of how I might be able to manipulate some of the names that appear on the y-axis of the barplot below. For example, the "gw" in "ECgw" would appear as a subscript...or "qr" would be the theta symbol followed by

[R] boxplot: reverse y-axis order

2010-11-21 Thread emorway
Hello, Searching this forum has enabled me to get pretty far in what I'm trying to do. However, there is one more manipulation I would like to make and I haven't found a solution. Using the data and code below, I generate the plot produced by the last command. If possible I would like to reve

[R] barplot3d cutting off labels

2010-11-13 Thread emorway
Hello, Using the function that is available at: http://addictedtor.free.fr/graphiques/sources/source_161.R The following command leads to a plot with labels that are cut off: barplot3d(c(4.01,4.71,2.03,1.28,1.42,1.76,0, 6.58,3.25,3.11,2.10,2.05,1.19,1.28, 6.44,5.50,3.6

[R] histograms resulting from call to soil.texture

2010-10-20 Thread emorway
Hello, Using the dataset below I produce a soil.texture plot (R code for this included at the end). One will notice I have plotted the points based on whether or not they are in a region called 'upstream' or 'downstream'. I'm curious if there is a way to somehow extract counts of the number of

[R] hdiffplot

2010-10-18 Thread emorway
Hello, I'm trying to track down more information on hdiffplot than what is supplied in ?hdiffplot. More specifically, the example code found at the bottom ?hdiffplot ("##Compare *three* of them:") is something I'm very interested in using for my own analysis. However, I don't see how to add a

[R] spplot cuts

2010-09-27 Thread emorway
Hello- After looking through ?spplot, I would expect that I could specify the values of the cuts: "...‘cuts’ number of cuts or the actual cuts to use..." So in the following command, spplot(lzm.krige.dir["var1.pred"], scales=list(draw=TRUE), xlab="Easting",ylab="Northing", cuts=seq(0.0,0.4,

[R] R's Data Dredging Philosophy for Distribution Fitting

2010-07-14 Thread emorway
Forum, I'm a grad student in Civil Eng, took some Stats classes that required students learn R, and I have since taken to R and use it for as much as I can. Back in my lab/office, many of my fellow grad students still use proprietary software at the behest of advisers who are familiar with the

[R] Average 2 Columns when possible, or return available value

2010-06-25 Thread emorway
Forum, Using the following data: DF<-read.table(textConnection("A B 22.60 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA 102.00 NA 19.20 NA 19.20 NA NA NA NA NA NA NA 11.80 NA 7.62 NA NA NA NA NA NA NA NA NA NA NA 75.00 NA NA NA 18.30 18.2 NA NA NA NA 8.44 NA 18.00 NA N

Re: [R] barplot: invalid 'xlim' value

2010-05-15 Thread emorway
Josh, Thanks for looking into this further. Picking up on your hint I tried to coerce the xlim values as well: barplot(coldat,horiz=TRUE,axes=FALSE,xlim=c(as.numeric(strptime(well.80.2$date[1],"%m/%d/%Y %H:%M")),as.numeric(strptime(well.80.2$date[length(well.80.2$date)],"%m/%d/%Y %H:%M"))),yli

Re: [R] barplot: invalid 'xlim' value

2010-05-15 Thread emorway
Josh, I wonder if you try pulling the data from the post directly it will work better for you: http://r.789695.n4.nabble.com/barplot-invalid-xlim-value-td2217919.html#a2217919 As for your response to the other code I was asking about...that code works perfectly well as it is written, so there i

[R] barplot: invalid 'xlim' value

2010-05-15 Thread emorway
Forum, I am attempting to plot weekly horizontal histograms, something very similar to: http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=109 The part of the code used to create this graphic that interest me: # Draw the histograms for (i in 1:length(ages)){ p

[R] insert values based on common ID

2010-05-14 Thread emorway
Forum, with the datasets a and b below, I'm trying to establish a relationship based on the common column "week" and insert the value from the column weekAvg in b to the column weekAvg in a. The dataset a is several thousand lines long. I've tried looking at 'match', writing functions, 'rbind.f

Re: [R] Add 1 week to date with hours included for subset

2010-05-14 Thread emorway
For those whose search lands on this post, here is the solution I found that worked well.80.2<-data.frame(well.80.2,week=floor(as.numeric(difftime(strptime(well.80.2$date,"%m/%d/%Y %H:%M",tz=""),strptime(well.80.2$date[1],"%m/%d/%Y %H:%M",tz=""),tz="",units="hours"))/168)) -- View this message

[R] Add 1 week to date with hours included for subset

2010-05-13 Thread emorway
Forum, I've got hourly data for roughly 5 months of time that I want to subset into successive weeks. The first two elements of the dataset are well.80.2$date[1] >[1] 6/12/2000 2:00 >9256 Levels: 10/1/2001... well.80.2$date[2] >[1] 6/12/2000 3:00 >9256 Levels: 10/1/2001 and so on until m

Re: [R] Polygon Shading Based on Relative Line Position

2010-05-06 Thread emorway
The last sentence should read: Due to the 20 or so times the lines cross each other I wasn't sure how to modify the last example in ?polygon -- View this message in context: http://r.789695.n4.nabble.com/Polygon-Shading-Based-on-Relative-Line-Position-tp2132718p2132720.html Sent from the R help

[R] Polygon Shading Based on Relative Line Position

2010-05-06 Thread emorway
Forum, I have two time series that I plot up using the data/code below. The x-axis shows weekly time step starting on 6/3/1999 (SP=10) and ending on 10/25/2007 (SP=448). I'm trying to shade between the two lines in a similar fashion as the graph found here: http://addictedtor.free.fr/graphiq

[R] melt, remove rows with common id if NA encountered in value

2010-05-05 Thread emorway
forum, After melting a data.frame I get some 18,000+ rows (some rows below). I want to filter/remove all rows that have an "SP" & "variable" value in common with a row containing "NA" in the value column. So in the example rows below, all rows with SP=425 & variable=CoolidgeLoad would be remove

[R] different forms of nls recommendations

2010-03-20 Thread emorway
Hello, Using this data: http://n4.nabble.com/file/n1676330/US_Final_Values.txt US_Final_Values.txt and the following code i got the image at the end of this message: US.final.values<-read.table("c:/tmp/US_Final_Values.txt",header=T,sep=" ") US.nls.1<-nls(US.final.values$ECe~a*US.final.values$

Re: [R] adding infrequent date labels to x-axis

2010-02-23 Thread emorway
Hi Hrishi, With regard to the post you helped me out with, I've got my graph almost dialed in the way I would like it. There was one more small thing my searches have been unable to turn up. I've tried searching with "stagger labels" "offset Labels" "alternate labels" to no avail. the perti

Re: [R] adding infrequent date labels to x-axis

2010-02-22 Thread emorway
Hello Hrishi, That worked great, and in the process I learned some new ways of going about writing R code. Thank you very much for helping me out! Eric -- View this message in context: http://n4.nabble.com/adding-infrequent-date-labels-to-x-axis-tp1564804p1564943.html Sent from the R help mai

Re: [R] adding infrequent date labels to x-axis

2010-02-22 Thread emorway
Hello Hrishi, The command you suggested plotted the years on the x-axis only. It was the same exact plot as the one I included in the original post. Respectfully, Eric -- View this message in context: http://n4.nabble.com/adding-infrequent-date-labels-to-x-axis-tp1564804p1564875.html Sent fr

[R] adding infrequent date labels to x-axis

2010-02-22 Thread emorway
I'm sure there is a clever way to do the following, but I've been unable to find it on this forum or by writing my own functions. I have 8 years worth of weekly data but would like to restrict the labels on the x-axis to months only. I've included the first year's worth of data below. My line

[R] formatting do.call output

2010-02-11 Thread emorway
Hello, With a dataset that is about 1.4e6 rows long my.dat[seq(1:20),] date Cell_ID Classification WT_Depth Frac_ET_Satsfd 1999-04-08 974 3 3.5850830.244561400 1999-04-081188 3 3.5260010.123484700 1999-04-081189 3 3.187012

[R] boxplot label cleanup

2010-02-10 Thread emorway
The boxplot below is close to what I would like, but needs some clean up. I've been unable to address the following: 1) How can I use the full extent of the plot space (there is white space on either side of the data)? 2) How can I reduce the # of month labels (e.g. every 3rd month Jan Mar Jun...

[R] object 'xxx' not found

2010-02-08 Thread emorway
The following line of code seems fairly straight forward, yet it is kicking back an error message: for (i in 1:length(mean.natveg.frac)){month.observed[i]=as.numeric(names(mean.natveg.frac[i]))%%12} Error message: Error in month.observed[i] = as numeric(names(mean.natveg.frac[i]))%%12 : object '

[R] log-normal overlay

2010-01-04 Thread emorway
Hello, Using the following lines of code, I created the following graph: d.resid<-c(-5.63,4.25,4.38,3.05,-1.85,1.40,1.80,-0.80,4.20,3.20,-2.70,-7.20,-0.10,-2.50,0.60,1.20,1.30,1.20,1.30,1.27,6.91,8.55,7.18,8.73,1.82,-1.45,5.91,5.45,-0.82,-4.55,0.82,82.91,1.73,3.09,5.64,-1.73,-9.55,4.27,17.45,9.6

[R] sppolot: fill below minimum legend value

2009-09-10 Thread emorway
In the plot below, there are some grid cells that have values below 10, which is the lowest "cut" value I have specified. Is there a way, without adjusting the number of cuts, to tell R to fill in those cells with the lowest possible color (in this case greeen)? There is a white "hole" in the im

[R] spplot modifications

2009-09-07 Thread emorway
http://www.nabble.com/file/p25336596/Conductivity1.jpeg I need a little help making modifications to the image included with this post. First, rather than using a linear color legend to display the output I would like to use a log-scale legend. Thus, the legend on the right would go from 1 to

[R] assign point values as labels in spplot

2009-01-29 Thread emorway
In the code to follow, I'm trying to label points with their corresponding values but have been unsuccessful after many variations to the following code. The code below creates the plot I want, I simply cannot get the black points ("+") to display the actual value. I'm guessing the problem is so