[R] How to finding a given length of runs in a series of data?

2015-05-06 Thread jcrosbie
I'm trying to study times in which flow was operating at a given level or greater. To do so I have created a way to see how long the series has operated at a high level. But for some reason the data is calculating the runs one hour to long. Any ideas on why? Code:

[R] Custom function causing an error with returning a ggplot object and Error in eval(expr, envir, enclos) : object '...' not found

2015-02-19 Thread jcrosbie
I'm trying to create a custom function to return a chart object. This function seems to be having an error with calculating min/max/etc in the ggplot object. If I run the code for the ggplot not inside a custom function it works. To reproduce this error after I need to clear the memory with

[R] R and GML data from the Canadian Goverment

2014-05-01 Thread jcrosbie
I'm trying to create a map of transmission lines in Alberta. In addition, I'm very new to creating maps. The data can be found at: http://geogratis.gc.ca/site/eng/download http://ftp2.cits.rncan.gc.ca/pub/canvec/doc/CanVec_distribution_formats_en.pdf Would someone be able to point me in the

[R] How two have two legends on a chart with different groups?

2014-04-12 Thread jcrosbie
I'm trying to have two legends on a chart, with two sets of data with subgroups. Currently ggplot is are merging the to sets of data together. I would like to have the vertical lines in there own legend and not affect the colour shading or show up in the type legend. How would I go about doing

[R] Subset error on atomic vectors why?

2014-04-02 Thread jcrosbie
I'm getting this error: Error in MOPrice$Date : $ operator is invalid for atomic vectors The cost is: subset(MOPrice, as.Date(MOPrice$Date,%Y-%m-%d)==as.Date(2013-11-28,%Y-%m-%d)) The date column looks like: 2013-12-31 2013-12-31 2013-12-31 2013-12-31 2013-12-31 -- View this message in

Re: [R] How to get a subset with a date such as Date=11/03/2013 HE=02*?

2014-03-25 Thread jcrosbie
, Col3SomeMadeupnumbers) Also, Nov. 2, 2008 02 is when there was a time change. David Winsemius wrote On Mar 24, 2014, at 3:35 PM, jcrosbie wrote: I'm having a problem working with daylight savings dates in R. I'm downloading data in two formats. Format One Col 1: a date such as 11/03

[R] How to get a subset with a date such as Date=11/03/2013 HE=02*?

2014-03-24 Thread jcrosbie
I'm having a problem working with daylight savings dates in R. I'm downloading data in two formats. Format One Col 1: a date such as 11/03/2013 col 2: Hour ending = 02* Col1-c(11/02/2008*, 11/02/2008, 11/02/2008, 11/02/2008) Col1-c(02*, 02, 03, 04) Another data set is something like this:

[R] How to importing a CVS file with multiple tables?

2014-03-20 Thread jcrosbie
I'm trying to figure out how to import data into a dataframe in R. The table I'm trying to import is: HistoricalTradingReportServlet.csv http://r.789695.n4.nabble.com/file/n4687246/HistoricalTradingReportServlet.csv I would like to add two more column for each block of data to have the

[R] How to fix the warning message the condition has length 1 and only the first element will be used?

2014-03-19 Thread jcrosbie
I'm trying to create a function to return the date x months in the past. With the code below I'm getting the warning message: Warning message: In if (MonthsBack = CurrentMonth) { : the condition has length 1 and only the first element will be used ## DateBack -

[R] why is as.date function not working for me? (dd/mm/yyyy h:mm)

2014-02-06 Thread jcrosbie
Why am I know getting hours after I convert the date? dates - c('31/12/2013 0:00', '31/12/2013 1:00', '31/12/2013 2:00', '31/12/2013 3:00', '31/12/2013 4:00', '31/12/2013 5:00', '31/12/2013 6:00', '31/12/2013 7:00', '31/12/2013 8:00', '31/12/2013 9:00', '31/12/2013 10:00', '31/12/2013

Re: [R] why is as.date function not working for me? (dd/mm/yyyy h:mm)

2014-02-06 Thread jcrosbie
This function returns date/times without timezone strptime(dates,format=%d/%m/%Y %H:%M) -- View this message in context: http://r.789695.n4.nabble.com/why-is-as-date-function-not-working-for-me-dd-mm--h-mm-tp4684874p4684895.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] why is as.date function not working for me? (dd/mm/yyyy h:mm)

2014-02-06 Thread jcrosbie
Thanks. as.POSIXct works for the most part. The only problem is part of data I'm working has it's own time zone. Is there a way to not have a time zone displayed? My times do not change with Daylight saving. -- View this message in context:

Re: [R] Download data

2013-09-19 Thread jcrosbie
Thank you for all your help. I'm still not able to figure out how automate downloads from online websites. This is a daily function to download the needed data. I would also like to be able to do this on other websites such as:

[R] Downloading CSV file - RCurl help

2013-06-15 Thread jcrosbie
There are some CSV file from the link below. I'm having trouble installing the package. Is this the package I have to use or is there another one I need to use? If so how do I get this one loaded. https://www.enmax.com/Power/Energy+Retailers/Settlement+Reports/Profile+settlement+report.htm

[R] Download data

2013-05-28 Thread jcrosbie
Hi, I'm trying to download data from: http://www.ngx.com/settlehistory.html Is it possible to fetch the data with R? Thank you -- View this message in context: http://r.789695.n4.nabble.com/Download-data-tp4668138.html Sent from the R help mailing list archive at Nabble.com.

[R] ggplot add a legend?

2012-12-17 Thread jcrosbie
How to I go about adding a legend to the following plot? ggplot() + geom_line(aes(x=df2010$Price,y=df2010$percentCapacity), colour = red) + geom_line(aes(x=df2011$Price,y=df2011$percentCapacity), colour = green) +geom_line(aes(x=df2012$Price,y=df2012$percentCapacity), colour = blue)

[R] custom function missing value where TRUE/FALSE needed

2012-11-05 Thread jcrosbie
I can't figure out why this function wont work. #Custom Function used fallInBand - function(x){ #Assume the bands fall go up form 0 to 100 in intervals of 5 then from 100 to 1000 in intervals of 100. #returns the location (band number) if (is.na(x) == FALSE) { if(x 100) {#bands of 5

[R] subtotals based on price bands?

2012-10-17 Thread jcrosbie
I would like to create a subtotal table with custom bands. seq1 = seq(0, 100, by = 5) seq2 = seq(100, 1000, by = 100) Bands = c(seq1, seq2) #Prices Prices = sample(1:1000, 200, replace=F) #corresponding size for the given price above. size = sample(1:1000, 200, replace=F) How would I

Re: [R] subtotals based on price bands?

2012-10-17 Thread jcrosbie
to 2040 Thank you From: arun kirshna [via R] ml-node+s789695n4646484...@n4.nabble.com To: jcrosbie ja...@crosb.ie Sent: Wednesday, October 17, 2012 10:32 AM Subject: Re: subtotals based on price bands? Hi, May be this helps: seq1 = seq(0, 100, by = 5

[R] aggregate function not working?

2012-10-17 Thread jcrosbie
The aggregate function for some reason will now work for me. The error I'm getting is: Error in sort.list(y) : 'x' must be atomic for 'sort.list' Have you called 'sort' on a list? agPriceList=aggregate(PriceList$Size, list(PriceList$bandNum),sum) *Price list dataframe:* dput(PriceList)

[R] frequency table with custom bands

2012-10-16 Thread jcrosbie
I would like to create a frequency table with custom bands. seq1 = seq(0, 100, by = 5) seq2 = seq(100, 1000, by = 100) Bands = c(seq1, seq2) Prices = sample(1:1000, 200, replace=F) How would I go about find the frequency of prices within each band? -- View this message in context:

[R] conditional sum two dataframes

2012-07-26 Thread jcrosbie
I have two data frames. One with a matrix of months and the other with a matrix of values. The two dataframes correspond to each other. I would like to sum up all the values in by month. What would be an efficient way to do this? a=C(2,3,5,2,3,5) b=c(2,6,3,2,6,3) c=c(2,6,7,2,6,5) months -

[R] Table/Frame - output

2012-07-17 Thread jcrosbie
I would like to output a nicely formatted data frame to a bitmap. Is this possible in R? -- View this message in context: http://r.789695.n4.nabble.com/Table-Frame-output-tp4636790.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] remove loop which compares row i to row i-1

2012-07-16 Thread jcrosbie
Thank you, That was very helpful. I do have another problem along the same lines. But I can not think of a way to do this with a function like ddply or aggregate. Example: x = sample(0:1,42,TRUE) [1] 1 1 1 1 0 1 0 0 1 1 1 1 1 0 0 0 1 0 0 1 1 0 0 0 0 1 1 0 0 0 1 0 1 1 0 1 1 1 0 0 0 0 I want to

Re: [R] remove loop which compares row i to row i-1

2012-07-12 Thread jcrosbie
Thank you, I am sorry but I am still trying to figure out how to make the function work. I have a column called tUnitsort$BlockNumber which can range from 0 to 6. I have another two columns with the date and the hour ending for the given day. Example DateHour BlockNumber MyTo

Re: [R] remove loop which compares row i to row i-1

2012-07-12 Thread jcrosbie
To: jcrosbie ja...@crosb.ie Sent: Thursday, July 12, 2012 3:12 PM Subject: Re: remove loop which compares row i to row i-1 Hello, I've not been following this thread but this seems ndependent from previous posts. Try the following. url - http://r.789695.n4.nabble.com/file/n4636337/BR3_2011_New.csv

Re: [R] remove loop which compares row i to row i-1

2012-07-05 Thread jcrosbie
Thank you, I tired ifelse(tUnitsort[length(tUnitsort$Hour),4]=tUnitsort[-1,4],(tempMC =tUnitsort[length(tUnitsort$Hour),7]),tempMC ) But this doesn't seem to work. Where am I going wrong? -- View this message in context:

[R] remove loop which compares row i to row i-1

2012-07-03 Thread jcrosbie
I would like to remove a loop to speed up my code. I want to remove a loop which references the last row. In general I want to a remove a loop which looks something like this: for 2 to number of rows in a matrix do{ if indextrow-1 is currentIndexRow then do something. } My R code:

Re: [R] plot background - excel gradient style background ?

2012-06-29 Thread jcrosbie
I have a number of different figures I wish to create with a gradient background. In addition to the two examples I've uploaded I need a boxplot, histogram, etc. http://r.789695.n4.nabble.com/file/n4634932/fig1.png fig1.png http://r.789695.n4.nabble.com/file/n4634932/fig2.png fig2.png --

Re: [R] ggplot incorrect legend

2012-06-08 Thread jcrosbie
Thank you, that was very helpful. Would it be possible to rename the legend values as well. Example 1 as Biomass, 2 as coal, 4 as gas, 5 as hydro? ggplot(data=tempTable, aes(x=Bands8, y=AvailableMWNewFormat, fill=as.factor(FuelTypeNum))) + geom_bar(position=stack, stat=identity)+

[R] Percent of a given subset

2012-06-08 Thread jcrosbie
How would I find the Percent of FuelTypeNum within the Band given AvailableMW? example: type 1 is 1% of PB0 type 2 is 54% of PB0 type 4 is 4% of PB0 type 5 is 42% of PB0 Note: the Bands and fuel types are not always constant. Data: FuelTypeNum Bands AvailableMW

[R] flagging values without a loop

2012-06-07 Thread jcrosbie
For a given hour I want to be able to add a new column called flag. The flag column will flag the highest price in a given hour. Is there a way to do this without a loop? matrix: Unit, Day,Hour, Price, Flag afd11/2/20031 1 N afd11/2/20031 2

Re: [R] ggplot incorrect legend

2012-06-06 Thread jcrosbie
I'm expecting the legend to be 1,2,4,5,10 not 2,4,6,8,10. Is there away I can set my own colour and legend tittles? -- View this message in context: http://r.789695.n4.nabble.com/ggplot-incorrect-legend-tp4632471p4632529.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] ggplot incorrect legend

2012-06-06 Thread jcrosbie
Thank you for your help. I would expect FuelTypeNum to make up the legend. But in the legend there is an extra value of called '3' and in the chart there is an extra FuelTypeNum. code: ggplot(data=tempTable, aes(x=Bands8, y=AvailableMWNewFormat, fill=FuelTypeNum)) + geom_bar(position=stack,

Re: [R] plot background - excel gradient style background ?

2012-06-05 Thread jcrosbie
I'm not the one who is choosing to use gradient background. It's our company policy. -- View this message in context: http://r.789695.n4.nabble.com/plot-background-excel-gradient-style-background-tp4632138p4632409.html Sent from the R help mailing list archive at Nabble.com.

[R] ggplot incorrect legend

2012-06-05 Thread jcrosbie
How do I create a legend with ggplot? I think should be getting the FuelTypeNum in the legend. Plot: http://r.789695.n4.nabble.com/file/n4632471/Rplot.jpeg My code is: ggplot(data=tempTable, aes(x=Bands8, y=SubPercent, fill=FuelTypeNum)) + geom_bar(position=stack, stat=identity) +

[R] plot background - excel gradient style background ?

2012-06-01 Thread jcrosbie
Is there away of putting an excel style gradient background? I want to have dark blue in the middle and shad to white on the top and bottom. -- View this message in context: http://r.789695.n4.nabble.com/plot-background-excel-gradient-style-background-tp4632138.html Sent from the R help mailing

[R] points() function will not plot

2012-06-01 Thread jcrosbie
I can not get the point function to work with in my code. The code: AggOfTempMatrix$CumSumPercentSize-c( 0.05265450, 0.05738490, 0.05865403, 0.05911553, 0.05957703, 0.06003854, 0.06058368, 0.06098750, 0.06147208, 0.06187589, 0.06291427, 0.06331808, 0.06354884, 0.06408533, 0.06489296,