Re: [R] Legend position in ggplot

2021-06-17 Thread Felipe Carrillo via R-help
Like this? theme(legend.position= 'top'


On Thursday, June 17, 2021, 10:52:04 AM PDT, peri He 
 wrote:  
 
 Dear Friends,

I would like to see my legend outside of a ggplot (at the top).

This code is showing the legend inside of a plot:
theme(legend.position=c(0.15,0.97))

But when I changed it to : theme(legend.position=c(-0.15,1.5)) , the legend 
disappears.

I would appreciate it if you share your ideas.

Regards,

Peri



    [[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.
  
[[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] Arranging ggplot2 objects with ggplotGrob()

2020-07-24 Thread Felipe Carrillo via R-help
What about cowplot?
https://cran.r-project.org/web/packages/cowplot/vignettes/introduction.html

On Friday, July 24, 2020, 11:51:17 AM PDT, H  wrote: 
 
 
 On 07/24/2020 02:03 PM, Jeff Newmiller wrote:
> The set of people interested in helping when you supply a minimal 
> reproducible example is rather larger than the set of people willing to read 
> the documentation for you (hint) and guess what aspect of alignment you are 
> having trouble with.
>
> On July 24, 2020 10:46:57 AM PDT, H  wrote:
>> On 07/24/2020 01:14 PM, John Kane wrote:
>>> Well, I am not looking for help debugging my code but for
>> information to better understand arranging plots vertically. The code
>> above aligns them horizontally as expected.
>>> Sigh, we know the code works but we do not know what the plots are  
>> and we cannot play around with them to see if we can help you if we
>> have nothing to work with.
>>> On Fri, 24 Jul 2020 at 12:12, H > > wrote:
>>>    On 07/24/2020 05:29 AM, Erich Subscriptions wrote:
>>>    > Hav a look at the packages cowplot and patchwork
>>>    >
>>>    >> On 24.07.2020, at 02:36, H > > wrote:
>>>    >>
>>>    >> I am trying to arrange two plots vertically, ie plot 2 below
>> plot 1, where I want the plots to align columnwise but have a height
>> ratio of eg 3:1.
>>>    >>
>>>    >> My attempts so far after consulting various webpages is that
>> the following code aligns them columnwise correctly but I have, so far,
>> failed in setting the relative heights...
>>>    >>
>>>    >> g2<-ggplotGrob(s)
>>>    >> g3<-ggplotGrob(v)
>>>    >> g<-rbind(g2, g3, size = "first")
>>>    >> g$widths<-unit.pmax(g2$widths, g3$widths)
>>>    >>
>>>    >> what would the appropriate statement for the relative heights
>> to add here be?
>>>    >>
>>>    >> grid.newpage()
>>>    >> grid.draw(g)
>>>    >>
>>>    >> Thank you!
>>>    >>
>>>    >> __
>>>    >> 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.
>>>    So this is not possible without using one of those two packages?
>> I got the impression I should be able to use grid.arrange to do so but
>> was not able to get it to work without disturbing the width alignment
>> above...
>>>    __
>>>    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.
>>>
>>>
>>> -- 
>>> John Kane
>>> Kingston ON Canada
>> No need to play around with anything. I am simply looking for
>> assistance on how to use eg arrangeGrob to not only align two plots
>> columnwise but also adjust their heights relative to each other rather
>> than 1:1.
>>
>> Can arrangeGrob() be used for that?
>>
>>
>>     [[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.

Look at https://cran.r-project.org/web/packages/egg/vignettes/Ecosystem.html 
where there are two mpg charts, one above the other. What would I need to add 
to:

|library(gtable) g2 <-ggplotGrob(p2) g3 <-ggplotGrob(p3) g <-rbind(g2, g3, size 
= "first") g$widths <-unit.pmax(g2$widths, g3$widths) grid.newpage() 
grid.draw(g) |

|to make the second chart 1/2 the size of the top one?|

||


    [[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.
  
[[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] [External Email] Re: [External] Re: access for free more than 500 essential Springer Nature textbooks

2020-05-22 Thread Felipe Carrillo via R-help
They can be downladed. I saved two of them to my desktop as pdf earlier.

Sent from Yahoo Mail on Android 
 
  On Fri, May 22, 2020 at 10:35 PM, Mark Leeds wrote:   
Hi: I'm not sure about the other link that was sent because I didn't try
it  but, in the case of the link that I sent,
you can obtain the pdfs of a lot of the books shown.


On Sat, May 23, 2020 at 12:16 AM Christopher W. Ryan 
wrote:

> Am I interpreting this offer correctly, that it is for libraries to
> obtain access to the e-books for free? It does not seem to me that an
> invididual can download one--am I missing that part?
>
> Thanks
>
> --Chris Ryan
>
> Mark Leeds wrote:
> > Abby: here's an easier link for seeing what you might like.
> >
> >
> https://link.springer.com/search?facet-content-type=%22Book%22=mat-covid19_textbooks&%23038;facet-language=%22En%22&%23038;sortOrder=newestFirst&%23038;showAll=true
> >
> > On Fri, May 22, 2020 at 9:18 PM Richard O'Keefe 
> wrote:
> >
> >> the real pleasure comes from things you weren't looking for but
> recognise
> >> as just what you needed.
> >>
> >> On Sat, 23 May 2020 at 12:34, Jeff Newmiller 
> >> wrote:
> >>
> >>> You are bound to be disappointed if you invert the purpose of the list.
> >>> This is marketing... think of it as a sale... stores rarely put their
> >>> entire stock on sale... particularly if the sale price is zero. You
> have
> >> to
> >>> start with the list and look for interesting titles.
> >>>
> >>> But don't let me dissuade you from adding to your killfile if that
> seems
> >>> more useful to you.
> >>>
> >>> On May 22, 2020 5:04:29 PM PDT, Abby Spurdle 
> >> wrote:
> > The Excel file is what you need.
> 
>  Well, now I'm in a bad mood.
> 
>  I went to all the trouble of opening the thing...
>  And the first two Springer-published books I look for, aren't there.
> 
>  (1) Programming with Data, John Chambers
>  (2) Applied Econometrics with R, Z and co.
> 
>  Next time someone tells me to use an Excel document, I'm adding them
>  to the spam list.
> 
>  __
>  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.
> >>>
> >>> --
> >>> Sent from my phone. Please excuse my brevity.
> >>>
> >>> __
> >>> 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.
> >>>
> >>
> >>        [[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.
> >>
> >
> >      [[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.
> >
>

    [[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.
  
Hi: I'm not sure about the other link that was sent because I didn't try
it  but, in the case of the link that I sent,
you can obtain the pdfs of a lot of the books shown.


On Sat, May 23, 2020 at 12:16 AM Christopher W. Ryan 
wrote:

> Am I interpreting this offer correctly, that it is for libraries to
> obtain access to the e-books for free? It does not seem to me that an
> invididual can download one--am I missing that part?
>
> Thanks
>
> --Chris Ryan
>
> Mark Leeds wrote:
> > Abby: here's an easier link for seeing what you might like.
> >
> >
> https://link.springer.com/search?facet-content-type=%22Book%22=mat-covid19_textbooks&%23038;facet-language=%22En%22&%23038;sortOrder=newestFirst&%23038;showAll=true
> >
> > On Fri, May 22, 2020 at 9:18 PM Richard O'Keefe 
> wrote:
> >
> >> the real pleasure comes from things you weren't looking for but
> recognise
> >> as just what you needed.
> >>
> >> On Sat, 23 May 2020 at 12:34, Jeff Newmiller 
> >> wrote:
> >>
> >>> You are bound to be disappointed if you invert the 

Re: [R] Tinn-R project: new version (6.01.01.03) released

2019-12-23 Thread Felipe Carrillo via R-help
Josè

Sent from Yahoo Mail on Android 
 
  On Mon, Dec 23, 2019 at 12:15 PM, Abby Spurdle wrote:   
Hi Jose,Same here, I use tinn-R on a daily basis..thanks for the update and 
have a merry christmas

That's awesome.
I used Tinn-R, back in 2006, when I starting learning nontrivial R programming.
I used it extensively, before shifting to my own (still incomplete)
programming environment.

Back then, Emacs (with ESS) had the monopoly on Linux, and Tinn-R was
leading the race on Windows.
You've made extremely valuable contributions to the R community.
And I look forward to seeing future progress...


Abs


On Tue, Dec 24, 2019 at 3:40 AM Jose Claudio Faria
 wrote:
>
> Hi,
>
> A new version of Tinn-R project (6.01.01.03) was released today.
>
> Download:
> - https://nbcgib.uesc.br/tinnr/en/download
> - https://sourceforge.net/projects/tinn-r/files/Tinn-R setup/
>
> What is new:
> - https://nbcgib.uesc.br/tinnr/en/download#patch
> - https://sourceforge.net/projects/tinn-r/files/Tinn-R setup/6.1.1.3/
>
> Best,
> ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
> Jose Claudio Faria
> UESC/DCET/Brasil
> joseclaudio.faria at gmail.com
> Telefones:
> 55(73)3680.5545 - UESC
> 55(73)99966.9100 - VIVO
> ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\
>
> If you have software to deal with statistics, you have arms;
> if you have good software, you have arms and legs;
> if you have software like R, you have arms, legs and wings...
> the height of your flight depends only on you!
>
>        [[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-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.
  

[[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] Preserving numeric columns

2019-10-19 Thread Felipe Carrillo via R-help
Yes, options(knitr.kable.NA = '-')  is The answer for kable.
Do you happen to know what are the arguments used for gridExtra grid.draw to 
acomplish the same thing?

Sent from Yahoo Mail on Android 
 
  On Sat, Oct 19, 2019 at 1:01 PM, Jeff Newmiller 
wrote:   Then the polite next step is for you to indicate what that solution 
was so people searching the archives can learn from your question. Was it to 
set the kable option?

options(knitr.kable.NA = '-') 

On October 19, 2019 12:50:20 PM PDT, Felipe Carrillo  
wrote:
>You are correct. I didnt explain well and failed to mention that this
>is for knitr::kable. I already figured it out. 
>
>Sent from Yahoo Mail on Android 
> 
>On Sat, Oct 19, 2019 at 1:04 AM, Jeff
>Newmiller wrote:  Data frames are NOT
>spreadsheets. Don't treat them like spreadsheets. All elements in a
>column are parts of a vector which means they all have the same data
>type.
>
>On the other hand, if you want to generate formatted output in HTML,
>LaTeX, or Word, there are many tools for generating formatted tables in
>the data output phase of data analysis, and it is common to convert
>everything to character format intentionally then.
>
>On October 19, 2019 12:44:26 AM PDT, Felipe Carrillo via R-help
> wrote:
>>Consider the following dataset:  I need to replace NAs with "-" but I
>>lose my numeric formatting  fall.estimate <- structure(list(`Salmon` =
>>c("salmon River", "Ant Creek", "big Creek", "oso River", "linda
>>Creek"), `baseline` = c(80874.384012, 361.1997, 5012.8311, 638.6912,
>>402.1044), `target` = c(16, 720, 1, 450, 800), `1992`
>=
>>c(27618.4365, 0, 3587.61719, NA, NA), `1993` = c(100027.82328, NA,
>>5647.83116, NA, NA), `1994` = c(99414.57438, NA, 12896.93753, NA, NA),
>>`1995` = c(235027.00518, NA, 32059.63037, NA, NA), `1996` =
>>c(143004.6423, NA, 17191.2152, NA, NA), `1997` = c(112796.88894, NA,
>>27365.24435, NA, NA), `1998` = c(102858.8148, NA, 20539.17372, NA,
>NA),
>>`1999` = c(94113.26562, NA, 21916.44213, NA, NA)), row.names =
>>c(NA, -5L), class = c("tbl_df", "tbl", "data.frame"))
>>fall.estimatestr(fall.estimate)#convert to class
>dataframefall.estimate
>><- as.data.frame(fall.estimate)
>>#Remove all decimalsfall.estimate[,-1]
>><-round(fall.estimate[,-1],0)#Replace NA's' with dash
>>'-'fall.estimate[is.na(fall.estimate)] <- "-"
>>#Here all my columns get converted to character#Try to convert back to
>>numericfall.estimate <- mutate_all(fall.estimate, function(x)
>>as.numeric(as.character(x))) fall.estimate#But I get these warnings
>>aand my dashes dissapearQuestion: How can I replace my NAs with dashes
>>and keep all my dataframecolumns as numeric? Warning messages:1: In
>>FUN(newX[, i], ...) : NAs introduced by coercion2: In FUN(newX[, i],
>>...) : NAs introduced by coercion3: In FUN(newX[, i], ...) : NAs
>>introduced by coercion4: In FUN(newX[, i], ...) : NAs introduced by
>>coercion5: In FUN(newX[, i], ...) : NAs introduced by coercion6: In
>>FUN(newX[, i], ...) : NAs introduced by coercion7: In FUN(newX[, i],
>>...) : NAs introduced by coercion8: In FUN(newX[, i], ...) : NAs
>>introduced by coercion9: In FUN(newX[, i], ...) : NAs introduced by
>>coercion
>>Thanks beforehand
>>
>>
>>    [[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.

-- 
Sent from my phone. Please excuse my brevity.  

[[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] Preserving numeric columns

2019-10-19 Thread Felipe Carrillo via R-help
You are correct. I didnt explain well and failed to mention that this is for 
knitr::kable. I already figured it out. 

Sent from Yahoo Mail on Android 
 
  On Sat, Oct 19, 2019 at 1:04 AM, Jeff Newmiller 
wrote:   Data frames are NOT spreadsheets. Don't treat them like spreadsheets. 
All elements in a column are parts of a vector which means they all have the 
same data type.

On the other hand, if you want to generate formatted output in HTML, LaTeX, or 
Word, there are many tools for generating formatted tables in the data output 
phase of data analysis, and it is common to convert everything to character 
format intentionally then.

On October 19, 2019 12:44:26 AM PDT, Felipe Carrillo via R-help 
 wrote:
>Consider the following dataset:  I need to replace NAs with "-" but I
>lose my numeric formatting  fall.estimate <- structure(list(`Salmon` =
>c("salmon River", "Ant Creek", "big Creek", "oso River", "linda
>Creek"), `baseline` = c(80874.384012, 361.1997, 5012.8311, 638.6912,
>402.1044), `target` = c(16, 720, 1, 450, 800), `1992` =
>c(27618.4365, 0, 3587.61719, NA, NA), `1993` = c(100027.82328, NA,
>5647.83116, NA, NA), `1994` = c(99414.57438, NA, 12896.93753, NA, NA),
>`1995` = c(235027.00518, NA, 32059.63037, NA, NA), `1996` =
>c(143004.6423, NA, 17191.2152, NA, NA), `1997` = c(112796.88894, NA,
>27365.24435, NA, NA), `1998` = c(102858.8148, NA, 20539.17372, NA, NA),
>`1999` = c(94113.26562, NA, 21916.44213, NA, NA)), row.names =
>c(NA, -5L), class = c("tbl_df", "tbl", "data.frame"))
>fall.estimatestr(fall.estimate)#convert to class dataframefall.estimate
><- as.data.frame(fall.estimate)
>#Remove all decimalsfall.estimate[,-1]
><-round(fall.estimate[,-1],0)#Replace NA's' with dash
>'-'fall.estimate[is.na(fall.estimate)] <- "-"
>#Here all my columns get converted to character#Try to convert back to
>numericfall.estimate <- mutate_all(fall.estimate, function(x)
>as.numeric(as.character(x))) fall.estimate#But I get these warnings
>aand my dashes dissapearQuestion: How can I replace my NAs with dashes
>and keep all my dataframecolumns as numeric? Warning messages:1: In
>FUN(newX[, i], ...) : NAs introduced by coercion2: In FUN(newX[, i],
>...) : NAs introduced by coercion3: In FUN(newX[, i], ...) : NAs
>introduced by coercion4: In FUN(newX[, i], ...) : NAs introduced by
>coercion5: In FUN(newX[, i], ...) : NAs introduced by coercion6: In
>FUN(newX[, i], ...) : NAs introduced by coercion7: In FUN(newX[, i],
>...) : NAs introduced by coercion8: In FUN(newX[, i], ...) : NAs
>introduced by coercion9: In FUN(newX[, i], ...) : NAs introduced by
>coercion
>Thanks beforehand
>
>
>    [[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.

-- 
Sent from my phone. Please excuse my brevity.  

[[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] Preserving numeric columns

2019-10-19 Thread Felipe Carrillo via R-help
Consider the following dataset:  I need to replace NAs with "-" but I lose my 
numeric formatting  fall.estimate <- structure(list(`Salmon` = c("salmon 
River", "Ant Creek", "big Creek", "oso River", "linda Creek"), `baseline` = 
c(80874.384012, 361.1997, 5012.8311, 638.6912, 402.1044), `target` = 
c(16, 720, 1, 450, 800), `1992` = c(27618.4365, 0, 3587.61719, NA, NA), 
`1993` = c(100027.82328, NA, 5647.83116, NA, NA), `1994` = c(99414.57438, NA, 
12896.93753, NA, NA), `1995` = c(235027.00518, NA, 32059.63037, NA, NA), `1996` 
= c(143004.6423, NA, 17191.2152, NA, NA), `1997` = c(112796.88894, NA, 
27365.24435, NA, NA), `1998` = c(102858.8148, NA, 20539.17372, NA, NA), `1999` 
= c(94113.26562, NA, 21916.44213, NA, NA)), row.names = c(NA, -5L), class = 
c("tbl_df", "tbl", "data.frame"))
fall.estimatestr(fall.estimate)#convert to class dataframefall.estimate <- 
as.data.frame(fall.estimate)
#Remove all decimalsfall.estimate[,-1] <-round(fall.estimate[,-1],0)#Replace 
NA's' with dash '-'fall.estimate[is.na(fall.estimate)] <- "-"
#Here all my columns get converted to character#Try to convert back to 
numericfall.estimate <- mutate_all(fall.estimate, function(x) 
as.numeric(as.character(x))) fall.estimate#But I get these warnings aand my 
dashes dissapearQuestion: How can I replace my NAs with dashes and keep all my 
dataframecolumns as numeric? Warning messages:1: In FUN(newX[, i], ...) : NAs 
introduced by coercion2: In FUN(newX[, i], ...) : NAs introduced by coercion3: 
In FUN(newX[, i], ...) : NAs introduced by coercion4: In FUN(newX[, i], ...) : 
NAs introduced by coercion5: In FUN(newX[, i], ...) : NAs introduced by 
coercion6: In FUN(newX[, i], ...) : NAs introduced by coercion7: In FUN(newX[, 
i], ...) : NAs introduced by coercion8: In FUN(newX[, i], ...) : NAs introduced 
by coercion9: In FUN(newX[, i], ...) : NAs introduced by coercion
Thanks beforehand


[[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] time series x axis labels

2017-06-07 Thread Felipe Carrillo via R-help
I hope this is the appropriate list for this type of question
Consider the dataset below:I have a column DOC with values from 3 to 101and 
those are the values that I want to show on my x axis, howeverI only get 3, 
3.1, 3.2 and so on. I tried to change those values with xlim(3, 101) but I 
getthe following error:Error in unit(x, default.units) : 'x' and 'units' must 
have length > 0
question: Which argument is needed in the ts() call to make the x axis 
showbreaks every 7 days starting with 3?
wt <- structure(list(DOC = c(3, 10, 17, 24, 31, 38, 45, 52, 59, 66, 73, 80, 87, 
94, 101), AvgWeight = c(1, 1.67, 2.07, 2.275, 
3.83, 6.2, 7.4, 8.5, 10.25, 11.1, 13.625, 15.2, 16.375, 17.8, 
21.5), PondName = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L), .Label = "Pond01", class = "factor"),     SampleDate = 
structure(c(1182585600, 1183190400, 1183795200,     118440, 1185004800, 
1185609600, 1186214400, 1186819200,     1187424000, 1188028800, 1188633600, 
1189238400, 1189843200,     1190448000, 1191052800), class = c("POSIXct", 
"POSIXt"))), .Names = c("DOC", "AvgWeight", "PondName", "SampleDate"), 
row.names = c(NA, 15L), class = "data.frame")  
wt$SampleDate <- as.Date(wt$SampleDate)  wt
library(forecast)library(ggplot2)pond <- 
ts(wt$AvgWeight,start=3,frequency=52)pond d.arima <- auto.arima(pond)d.forecast 
<- forecast(d.arima, level = c(95), h = 3)d.forecast

autoplot(d.forecast) + xlim(7, 101)Error in unit(x, default.units) : 'x' and 
'units' must have length > 0

Take a look at the attached plot

__
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] Time series axis breaks

2017-06-07 Thread Felipe Carrillo via R-help
I hope this is the appropriate list for this type of question
Consider the dataset below:I have a column DOC with values from 3 to 101and 
those are the values that I want to show on my x axis, howeverI only get 3, 
3.1, 3.2 and so on. I tried to change those values with xlim(3, 101) but I 
getthe following error:Error in unit(x, default.units) : 'x' and 'units' must 
have length > 0
question: Which argument is needed in the ts() call to make the x axis 
showbreaks every 7 days starting with 3?
wt <- structure(list(DOC = c(3, 10, 17, 24, 31, 38, 45, 52, 59, 66, 73, 80, 87, 
94, 101), AvgWeight = c(1, 1.67, 2.07, 2.275, 
3.83, 6.2, 7.4, 8.5, 10.25, 11.1, 13.625, 15.2, 16.375, 17.8, 
21.5), PondName = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L), .Label = "Pond01", class = "factor"),     SampleDate = 
structure(c(1182585600, 1183190400, 1183795200,     118440, 1185004800, 
1185609600, 1186214400, 1186819200,     1187424000, 1188028800, 1188633600, 
1189238400, 1189843200,     1190448000, 1191052800), class = c("POSIXct", 
"POSIXt"))), .Names = c("DOC", "AvgWeight", "PondName", "SampleDate"), 
row.names = c(NA, 15L), class = "data.frame")  
wt$SampleDate <- as.Date(wt$SampleDate)  wt
library(forecast)library(ggplot2)pond <- 
ts(wt$AvgWeight,start=3,frequency=52)pond d.arima <- auto.arima(pond)d.forecast 
<- forecast(d.arima, level = c(95), h = 3)d.forecast

autoplot(d.forecast) + xlim(7, 101)Error in unit(x, default.units) : 'x' and 
'units' must have length > 0

Take a look at the attached plot
__
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] gridExtra-arrangeGrob

2017-01-09 Thread Felipe Carrillo via R-help
I am not sure if something was wrong with my gridExtra installation or grid but 
after uninstall/re-install of the packages (and reboot) the code is working 
properly. Thank you all. 
 

On Monday, January 9, 2017 9:51 AM, David Winsemius 
<dwinsem...@comcast.net> wrote:
 
 

 
> On Jan 9, 2017, at 3:35 AM, John Kane via R-help <r-help@r-project.org> wrote:
> 
> I'm not sure what the problem is but, if nothing else, it looks like you need 
> to do 
> library(grid)
> It may be that an early version of ggplot2 or gridExtra was automatically 
> loading grid and it no longer does.  
> 
> 
> 
> 
>    On Monday, January 9, 2017 1:08 AM, Felipe Carrillo via R-help 
><r-help@r-project.org> wrote:
> 
> 
>  Hi;The code below used to work on my older version of gridExtra but doesn't 
>work with the new version. Could someonegive me a hint on how to translate 
>this code to the new version of gridExtra code? Thank you beforehand.
> p1 <- ggplot(iris,aes(Sepal.Length,  Petal.Length, colour=Species)) +
> geom_point() + theme_bw() + theme(legend.position='top')
> 
>  grid.arrange(p1, arrangeGrob(p1,p1,p1, heights=c(0.33, .33,.33), ncol=1), 
>ncol=2)
>  #Create 2 columns with different width using the 'widths' argument in the 
>grid.arrange call
>  grid.arrange(p1, arrangeGrob(p1,p1,p1, heights=c(0.33, .40,.27), ncol=1), 
>ncol=2,widths=c(1.25,0.75))
> p <- rectGrob()  
>  grid.arrange(p, arrangeGrob(p,p,p, heights=c(0.33, .33,.33), ncol=1), ncol=2)

The lattice library attaches the grid functions via a namespace mechanism but 
it does not actually load the package. That meant that attempts to use grid 
functions from the console would fail. Perhaps this is also the practice of the 
ggplot2 authors? In any event, the grid.arrange and arrangeGrob functions are 
not from grid, but rather from gridExtra, which I am not seeing being loaded.

-- 
David.


> 
>    [[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.
> 
> 
>     [[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.

David Winsemius
Alameda, CA, USA


 
   
[[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] gridExtra-arrangeGrob

2017-01-08 Thread Felipe Carrillo via R-help
 Hi;The code below used to work on my older version of gridExtra but doesn't 
work with the new version. Could someonegive me a hint on how to translate this 
code to the new version of gridExtra code? Thank you beforehand.
p1 <- ggplot(iris,aes(Sepal.Length,  Petal.Length, colour=Species)) +
geom_point() + theme_bw() + theme(legend.position='top')

 grid.arrange(p1, arrangeGrob(p1,p1,p1, heights=c(0.33, .33,.33), ncol=1), 
ncol=2)
 #Create 2 columns with different width using the 'widths' argument in the 
grid.arrange call
  grid.arrange(p1, arrangeGrob(p1,p1,p1, heights=c(0.33, .40,.27), ncol=1), 
ncol=2,widths=c(1.25,0.75))
p <- rectGrob()  
 grid.arrange(p, arrangeGrob(p,p,p, heights=c(0.33, .33,.33), ncol=1), ncol=2)

[[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] ddply question

2014-08-30 Thread Felipe Carrillo
I apologize about cross posting but my question keeps bouncing back from the 
list
 
 How come pct doesn't work in this ddply call?
I am trying to get a percent of 'TotalCount' by SampleDate and Age
 library(plyr)
b - structure(list(SampleDate = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L), .Label = 5/8/1996, class = factor), TotalCount = c(1L,
2L, 1L, 1L, 4L, 3L, 1L, 10L, 3L), ForkLength = c(61L, 22L, NA,
NA, 72L, 34L, 100L, 23L, 25L), TotalSalvage = c(12L, 24L, 12L,
12L, 17L, 23L, 31L, 12L, 15L), Age = c(1L, 0L, NA, NA, 1L, 0L,
1L, 0L, 0L)), .Names = c(SampleDate, TotalCount, ForkLength,
TotalSalvage, Age), class = data.frame, row.names = c(NA,
-9L))
b
ddply(b,.(SampleDate,Age),summarise,salvage=sum(TotalSalvage),pct=TotalCount/sum(TotalCount))
Error: expecting result of length one, got : 4
 
#Computing TotalCount inside ddply works but the pct seems wrong...
ddply(b,.(SampleDate,Age),summarise,salvage=sum(TotalSalvage),Count=sum(TotalCount),pct=Count/sum(Count))
[[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] t.test of matching columns from two datasets using plyr

2014-08-12 Thread Felipe Carrillo
Hi,
I Have two datasets df1 and df2 with 3 matching columns. I need to do a t.test
of sp1, sp2 and sp3� and var1, var2 and var3 where the year, month and location 
match. 
I can do it with sapply or mapply but I want the end result to be a data.frame. 
I prefer to do it with
plyr or dplyr as I have been using these packages throughout this project. My 
final
dataframe should have the t.test statistic and the p.value.
�
Sample datasets
first dataframe
df1 - structure(list(Year = c(1995L, 1995L, 1995L, 1995L, 1995L, 1995L, 
1995L, 1995L, 1995L, 1995L, 1995L, 1995L, 1995L, 1995L, 1995L, 
1995L, 1995L, 1995L, 1995L, 1995L, 1995L), month = c(Feb, Mar, 
Mar, Mar, Mar, Mar, Mar, Mar, Mar, Mar, Mar, 
Mar, Mar, Mar, Mar, Apr, Apr, Apr, Apr, Apr, 
Apr), location = structure(c(5L, 5L, 5L, 5L, 5L, 5L, 2L, 4L, 
4L, 1L, 4L, 4L, 3L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 2L), .Label = c(Far West, 
North, Other, South, West), class = factor), var1 = c(111.6, 
0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 31.4, 245.9, 46.3, 59.8, 206.1, 
200.3, 88, 73.4, 33.9, 7.1), var2 = c(0, 4.7, 4.4, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 159.8, 0, 0, 142.2, 94.3, 0, 0, 0, 0), var3 = c(180.2, 
14.1, 123.7, 17.4, 5.5, 12.9, 39.3, 21, 66.6, 12.2, 13.6, 15.7, 
36.9, 0, 143.5, 35.5, 235.6, 51.3, 230.6, 81.3, 190.9)), .Names = c(Year, 
month, location, var1, var2, var3), row.names = 17093:17113, class = 
data.frame)
second dataframe
df2 - structure(list(Year = c(1995L, 1995L, 1995L, 1995L, 1995L, 1995L, 
1995L, 1995L, 1995L, 1995L, 1995L, 1995L, 1995L, 1995L, 1995L, 
1995L, 1995L, 1995L, 1995L, 1995L, 1995L), month = c(Apr, Apr, 
Apr, Apr, Apr, Apr, Apr, Apr, May, May, May, 
May, May, May, May, May, May, May, May, May, 
May), location = structure(c(3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
1L, 1L, 1L, 1L, 1L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L), .Label = c(Far West, 
North, South, West), class = factor), sp1 = c(853.0055629, 
147.7158909, 160.1536518, 65.01652491, 2332.609706, 701.4706852, 
11.36420842, 0, 2645.671425, 2769.409257, 523.4284249, 135.1274855, 
72.22498557, 35.07497333, 572.087043, 150.4768424, 111.5881472, 
61.21848041, 392.0651906, 0, 771.0337355), sp2 = c(10.27717546, 
0, 0, 0, 0, 10.16624181, 0, 0, 0, 307.7121397, 52.34284249, 19.30392649, 
24.07499519, 0, 35.75544018, 42.99338354, 0, 40.81232027, 0, 
90.9210806, 622.7580172), sp3 = c(92.49457911, 128.0204387, 203.8319205, 
175.5446173, 120.6522262, 71.1636927, 107.95998, 57.14456898, 
43.37166271, 153.8560698, 104.685685, 77.21570598, 96.29998075, 
187.0665244, 0, 0, 111.5881472, 163.2492811, 26.13767938, 45.4605403, 
207.5860057)), .Names = c(Year, month, location, sp1, 
sp2, sp3), row.names = 30:50, class = data.frame)
�
Thank you much.
[[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] predicted values

2014-02-03 Thread Felipe Carrillo
Hi Joshua,
Thanks for the suggestion, I will check into log link. I just basically want to 
fill in
missing values for days where data is not available. Negative values definetely 
won't work
for the kind of data that I am collecting.  





On Saturday, February 1, 2014 7:51 PM, Joshua Wiley jwiley.ps...@gmail.com 
wrote:
  
Dear Felipe,

That is a normal behavior --- The prediction for that simple model
decreases over time, and ends up negative.  If the outcome cannot take
on negative values, treating it as a continuous gaussian may not be
optimal --- perhaps some transformation, like using a log link so that
the expoentiated values are always positive would be better?
Alternately, if the predictions are going negative, not because the
data is over all, but say there is a quick decrease in values in the
first part of time but later on it slows, but if you have an overly
simplisitic time model, it may just keep
 decreasing.  Using a smoother
with a higher basis dimensions may help more accurately model the
function over the span of time in your dataset and then not have
predicted values.

I do not think that there would be any straight forward 'force' the
model to be positive only.

Best,

Joshua



On Sat, Feb 1, 2014 at 5:05 PM, Felipe Carrillo
mazatlanmex...@yahoo.com wrote:
 Consider this dummy dataset.
 My real dataset with over 1000 records has
 scatter large and
 small values.
 I want to predict for
 values with NA but I
 get negative predictions. Is this a normal
 behaviour or I am missing a gam argument
 to force the model to predict positive values.
 library(mgcv)
 test - data.frame(iddate=seq(as.Date(2014-01-01),
         as.Date(2014-01-12), by=days),
         value=c(300,29,22,NA,128,24,15,1,3,30,NA,2))
 test
 str(test)
 mod - gam(value ~ s(as.numeric(iddate)),data=test)
 # Predict for values with NA's
 test$pred - with(test,ifelse(is.na(value),predict(mod,test),value))
 test
         [[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.




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://joshuawiley.com/
Senior Analyst - Elkhart Group Ltd.
http://elkhartgroup.com/



 
[[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] predicted values

2014-02-01 Thread Felipe Carrillo
Consider this dummy dataset.
My real dataset with over 1000 records has
scatter large and small values.
I want to predict for values with NA but I
get negative predictions. Is this a normal
behaviour or I am missing a gam argument
to force the model to predict positive values.
library(mgcv)
test - data.frame(iddate=seq(as.Date(2014-01-01),
    as.Date(2014-01-12), by=days),
    value=c(300,29,22,NA,128,24,15,1,3,30,NA,2))
test
str(test)
mod - gam(value ~ s(as.numeric(iddate)),data=test)
# Predict for values with NA's
test$pred - with(test,ifelse(is.na(value),predict(mod,test),value))
test
[[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] print multiple plots to jpeg, one lattice and one ggplot2

2013-05-03 Thread Felipe Carrillo
Something like this?
library(gridExtra)
grid.arrange(one,two)

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx




From: Christophe Bouffioux christophe@gmail.com
To: r-help@r-project.org r-help@r-project.org 
Sent: Friday, May 3, 2013 6:33 AM
Subject: [R] print multiple plots to jpeg, one lattice and one ggplot2


hello everybody,

I want to print two plots in one png file, I tried several options but i
didn't succeed
the first plot (bwplot) print to the defined position, but the second
(ggplot) doesn't
Any idea?
Thanks a lot
Christophe


#  Example:
#-

library(ggplot2)
library(lattice)
library(grid)

one - bwplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
      panel = panel.superpose,
      panel.groups = panel.linejoin,
      xlab = treatment,
      key = list(lines = Rows(trellis.par.get(superpose.line),
                  c(1:7, 1)),
                  text = list(lab =
as.character(unique(OrchardSprays$rowpos))),
                  columns = 4, title = Row position))


df - data.frame(gp = factor(rep(letters[1:3], each = 10)),
                y = rnorm(30))
# Compute sample mean and standard deviation in each group
library(plyr)
ds - ddply(df, .(gp), summarise, mean = mean(y), sd = sd(y))

two - ggplot(df, aes(x = gp, y = y)) +
    geom_point() +
    geom_point(data = ds, aes(y = mean),
              colour = 'red', size = 3)



# 1. not working
jpeg(file=paste(pathgraph,'/fig03_profiltot','.png',sep=''),width = 600,
height = 400, units=px, res=100)
    print(one, position=c(0,0,0.5,1), more=TRUE)
    print(two, position=c(0.5,0,1,1), )
dev.off()


# 2 not working
jpeg(file=paste(pathgraph,'/fig03_profiltot','.png',sep=''),width = 600,
height = 400, units=px, res=100)
grid.newpage()
pushViewport(viewport(layout = grid.layout(1, 2)))

      print(one, vp = viewport(layout.pos.row = 1, layout.pos.col = 1))
# ça ne fonctionne pas
      print(two, vp = viewport(layout.pos.row = 1, layout.pos.col = 2))
dev.off()



# 3 not working
jpeg(file=paste(pathgraph,'/fig03_profiltot','.png',sep=''),width = 600,
height = 400, units=px, res=100)
    par(mfrow=c(1,2))
      one
      two
dev.off()

    [[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.



[[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] Summary of data for each year

2013-02-01 Thread Felipe Carrillo
 Here is another option using plyr:
 
library(plyr)
creek - read.csv(creek.csv)
 library(ggplot2)
 creek[1:10,]
 colnames(creek) - c(date,flow)
 creek$date - as.Date(creek$date, %m/%d/%Y)
 
ddply(creek,year,summarise,MED=median(flow),MEAN=mean(flow),SD=sd(flow),MIN=min(flow))

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx




From: Pascal Oettli kri...@ymail.com
To: Janesh Devkota janesh.devk...@gmail.com 
Cc: r-help@r-project.org 
Sent: Thursday, January 31, 2013 11:52 PM
Subject: Re: [R] Summary of data for each year

Hello,

One possibility is:

 creek - read.csv(creek.csv)
 colnames(creek) - c(date,flow)
 creek$date - as.Date(creek$date, %m/%d/%Y)
 creek - within(creek, year - format(date, '%Y'))

 with(creek, aggregate(flow, by=list(year=year), summary))

HTH,
Pascal


Le 01/02/2013 16:32, Janesh Devkota a écrit :
 Hello All,

 I have a data with two columns. In one column it is date and in another
 column it is flow data.

 I was able to read the data as date and flow data. I used the following
 code:

 creek - read.csv(creek.csv)
 library(ggplot2)
 creek[1:10,]
 colnames(creek) - c(date,flow)
 creek$date - as.Date(creek$date, %m/%d/%Y)

 The link to my data is https://www.dropbox.com/s/eqpena3nk82x67e/creek.csv

 Now, I want to find the summary of each year. I want to especially know
 mean, median, maximum etc.

 Thanks.

 Janesh

     [[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-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.



[[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] readJPEG function cannot open jpeg files

2013-01-14 Thread Felipe Carrillo
I have used the biOps package to read pictures and it works fine.
For example you can plot a pic just by:
library(biOps)
x - readJpeg(mypic.jpg)  ##mypic should be in you working directory
plot(x)

Notice that is only one uppercase letter on readJpeg and mypic is jpg not 
jpeg


Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx




From: William Dunlap wdun...@tibco.com
To: Jeff Newmiller jdnew...@dcn.davis.ca.us; Yi Yuan lamban...@gmail.com; 
r-help@r-project.org r-help@r-project.org 
Sent: Monday, January 14, 2013 8:44 AM
Subject: Re: [R] readJPEG function cannot open jpeg files

You can use file.info(myFile) to make sure the file exists and has 
appropriate permissions (mode
in file.info's lingo, as in Unix).  E.g.,

 file.info(c:/temp/BO.jpeg) # this one does not exist
                size isdir mode mtime ctime atime  exe
c:/temp/BO.jpeg  NA    NA NA  NA  NA  NA NA
 file.info(c:/temp/BO.jpg) # this one exists
                size isdir mode              mtime              ctime          
    atime
c:/temp/BO.jpg 150536 FALSE  666 2013-01-14 08:35:32 2013-01-14 08:33:09 
2013-01-14 08:33:09
              exe
c:/temp/BO.jpg  no

I can readJPEG() the file with mode 666, but not all permission information is 
encoded in the mode. 

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf
 Of Jeff Newmiller
 Sent: Monday, January 14, 2013 8:25 AM
 To: Yi Yuan; r-help@r-project.org
 Subject: Re: [R] readJPEG function cannot open jpeg files
 
 Being unable to open a file is a related to your operating system and how R 
 interacts with
 that OS. If your interactive development environment (IDE, of which RStudio 
 is an
 example) is trying to make things simpler for you but you don't understand 
 how to use it,
 then you need to ask help from your RStudio support resources, not here.
 
 When posting here, you should mention your results from using base R 
 functions like
 
 ?sessionInfo
 ?getwd
 ?list.files
 
 as indicated in the Posting Guide mentioned at the bottom of every R-help 
 email.
 
 Consistent with the fact that this is an interface issue between R and the 
 OS, sometimes
 you will have to investigate the problem from outside R. For example, you 
 might need to
 investigate issues with security permissions that are OS specific and 
 completely outside
 the scope of this forum.
 ---
 Jeff Newmiller                        The    .      .  Go Live...
 DCN:jdnew...@dcn.davis.ca.us        Basics: ##.#.      ##.#.  Live Go...
                                      Live:  OO#.. Dead: OO#..  Playing
 Research Engineer (Solar/Batteries            O.O#.      #.O#.  with
 /Software/Embedded Controllers)              .OO#.      .OO#.  rocks...1k
 ---
 Sent from my phone. Please excuse my brevity.
 
 Yi Yuan lamban...@gmail.com wrote:
 
 I installed jpeg package and tried to use
 
 kim-readJPEG(kim.jpeg) to read in a jpeg file, but R gave me an
 error:
 Error in readJPEG(kim.jpeg) : unable to open kim.jpeg
 
 I already put kim.jpeg in Rstudio's default working directory:
 E:\home
 work\Rstudio. So I don't think it's a problem caused by omitting the
 file's
 path. But I tried with the full path version just in case and still got
 the
 unable to open error:
 
 kim-readJPEG(E:\\ home work\\Rstudio\\kim.jpeg)
 Error in readJPEG(E:\\ home work\\Rstudio\\kim.jpeg) :
   unable to open E:\ home work\Rstudio\kim.jpeg
 
 So now I really don't know what is wrong.
 
     [[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-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-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.



[[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, 

Re: [R] save to file

2012-12-17 Thread Felipe Carrillo
I actually got it to do what I want running my R routine through a batch file. 
It saves to a file everything on the console. Thanks for 
your suggestions.

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx




From: Vivek Singh vksingh.ii...@gmail.com
To: David Winsemius dwinsem...@comcast.net 
Cc: Felipe Carrillo mazatlanmex...@yahoo.com; r-help help 
r-h...@stat.math.ethz.ch 
Sent: Sunday, December 16, 2012 11:35 PM
Subject: Re: [R] save to file


try the following. it works for linux:

$ R|tee log.txt

I stored the log for a small period.

R version 2.15.1 (2012-06-22) -- Roasted Marshmallows
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

 q()
Save workspace image? [y/n/c]: n



On Mon, Dec 17, 2012 at 3:23 PM, David Winsemius dwinsem...@comcast.net 
wrote:


On Dec 16, 2012, at 7:35 PM, Felipe Carrillo wrote:

 Well, I am going to give copies of an application to different offices and 
 want to be able to generate an output file
 in the event that an error would ocurr while running the different R 
 routines. By saving the entire R console along with the
 R version, I should be able to see where the error ocurred. I've seen text 
 files with every single text from the R console but can't find
 the way to capture that.

Most consoles will accept cmd-A or similar to select all text in a console 
session. Figure out what that keystroke combo is for your OS and then ctl- or 
cmd-C and paste into text editor.

--
David Winsemius
Alameda, CA, USA


__
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.



-- 

Thanks and Regards,

Vivek Kumar Singh

Alcatel-Lucent,
Bangalore

(91)9886317184, 8123951698



[[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] save to file

2012-12-16 Thread Felipe Carrillo
 Hi,
What's the equivalent of Save to File from the R console File menu on an R 
routine? Just trying
to capture the whole R console into a text file when my code fails.




Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx

[[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] save to file

2012-12-16 Thread Felipe Carrillo
I did check that link but it doesn't do what I want..thanks for trying though. 


Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx


From: arun smartpink...@yahoo.com
To: Felipe Carrillo mazatlanmex...@yahoo.com 
Sent: Sunday, December 16, 2012 6:55 PM
Subject: Re: [R] save to file

Hi,
sink() gives only the output to be saved in the foo.txt, but txtStart(), 
txtStop() gets the codes and the output.  Sorry, I misunderstood your question.

You can also check this link (if you haven't already seen)
http://r.789695.n4.nabble.com/Capturing-R-console-output-into-a-file-sink-savehistory-td2227013.html
A.K.  






From: Felipe Carrillo mazatlanmex...@yahoo.com
To: arun smartpink...@yahoo.com 
Sent: Sunday, December 16, 2012 9:47 PM
Subject: Re: [R] save to file


What you did That's what sink() does but I mean the entire R console screen 
including the R statement below
I just want to be able to capture everything during the R session

R version 2.15.0 (2012-03-30)
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i386-pc-mingw32/i386 (32-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
  Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R. 

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx



From: arun smartpink...@yahoo.com
To: Felipe Carrillo mazatlanmex...@yahoo.com 
Sent: Sunday, December 16, 2012 6:37 PM
Subject: Re: [R] save to file

Hi,
I am using Ubuntu 12.04.

My sessionInfo() if that helps:
sessionInfo()
R version 2.15.0 (2012-03-30)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8  
LC_NUMERIC=C  
 [3] LC_TIME=en_US.UTF-8    LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=C LC_NAME=C 
 [9] LC_ADDRESS=C   LC_TELEPHONE=C    
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C   

attached base packages:
[1] stats graphics  grDevices utils datasets 
methods   base 

other attached packages:
[1] TeachingDemos_2.8 stringr_0.6   reshape_0.8.4 plyr_1.7.1   

loaded via a namespace (and not attached):
[1] tcltk_2.15.0 tools_2.15.0
A.K.








From: Felipe Carrillo mazatlanmex...@yahoo.com
To: arun smartpink...@yahoo.com 
Sent: Sunday, December 16, 2012 9:28 PM
Subject: Re: [R] save to file


My text file is created but its empty. Did you start
library(TeachingDemos)
txtStart(foo.txt,commands=TRUE,results=TRUE,append=FALSE)
on you R.profile to capture the R statement?

Felipe D.
Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx



From: arun smartpink...@yahoo.com
To: Felipe Carrillo mazatlanmex...@yahoo.com 
Sent: Sunday, December 16, 2012 6:16 PM
Subject: Re: [R] save to file



Hi,
If there are comments in your code, you need to ?txtComment() from 
library(TeachingDemos).  I did a trial run and was able to get the snapshot 
in the output file.

A.K.



From: Felipe Carrillo
mazatlanmex...@yahoo.com
To: arun smartpink...@yahoo.com 
Sent: Sunday, December 16, 2012 9:13 PM
Subject: Re: [R] save to file


I know about sink() and capture.output() but these functions don't capture 
the entire console. I basically
want a snapshot of all the text on the R console saved to a file. I am the 
users to send me the file so that I can
see where the R crashed. I will check the Teaching Demos. Thanks

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx



From: arun smartpink...@yahoo.com
To: Felipe Carrillo mazatlanmex...@yahoo.com 
Cc: R help r-help@r-project.org 
Sent: Sunday, December 16, 2012 6:07 PM
Subject: Re: [R] save to file

HI,

I guess ?sink() may not work for you as you need  the whole R console.

Have you tried library(TeachingDemos) ?txtStart(), ?txtStop()
?

txtStart(foo.txt,commands=TRUE,results=TRUE,append=FALSE)
codes
txtStop()

A.K.



- Original Message -
From: Felipe
Carrillo mazatlanmex...@yahoo.com
To: r-h...@stat.math.ethz.ch r-h...@stat.math.ethz.ch
Cc: 
Sent: Sunday, December 16, 2012 8:30 PM
Subject: [R] save to file

 Hi

Re: [R] save to file

2012-12-16 Thread Felipe Carrillo
Well, I am going to give copies of an application to different offices and want 
to be able to generate an output file
in the event that an error would ocurr while running the different R routines. 
By saving the entire R console along with the
R version, I should be able to see where the error ocurred. I've seen text 
files with every single text from the R console but can't find
the way to capture that. 

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx


From: arun smartpink...@yahoo.com
To: Felipe Carrillo mazatlanmex...@yahoo.com 
Sent: Sunday, December 16, 2012 7:13 PM
Subject: Re: [R] save to file

As a workaround, you could copy manually the R statements R version 2.15.0 
(2012-03-30)--- 
Type 'q()' to quit R. and then use txtStart()..txtStop().  Would it work?  
The reason I am saying is that with 1000s of lines of code, this will be still 
easier. 
A.K.







From: Felipe Carrillo mazatlanmex...@yahoo.com
To: arun smartpink...@yahoo.com; r-h...@stat.math.ethz.ch 
r-h...@stat.math.ethz.ch 
Sent: Sunday, December 16, 2012 10:03 PM
Subject: Re: [R] save to file


I did check that link but it doesn't do what I want..thanks for trying though. 


Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx



From: arun smartpink...@yahoo.com
To: Felipe Carrillo mazatlanmex...@yahoo.com 
Sent: Sunday, December 16, 2012 6:55 PM
Subject: Re: [R] save to file

Hi,
sink() gives only the output to be saved in the foo.txt, but txtStart(), 
txtStop() gets the codes and the output.  Sorry, I misunderstood your 
question.

You can also check this link (if you haven't already
seen)
http://r.789695.n4.nabble.com/Capturing-R-console-output-into-a-file-sink-savehistory-td2227013.html
A.K.  






From: Felipe Carrillo mazatlanmex...@yahoo.com
To: arun smartpink...@yahoo.com 
Sent: Sunday, December 16, 2012 9:47 PM
Subject: Re: [R] save to file


What you did That's what sink() does but I mean the entire R console screen 
including the R statement below
I just want to be able to capture everything during the R session

R version 2.15.0 (2012-03-30)
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i386-pc-mingw32/i386 (32-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome
to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
  Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R. 

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx



From: arun smartpink...@yahoo.com
To: Felipe Carrillo mazatlanmex...@yahoo.com 
Sent: Sunday, December 16, 2012 6:37 PM
Subject: Re: [R] save to file

Hi,
I am using Ubuntu 12.04.

My sessionInfo() if that helps:
sessionInfo()
R version 2.15.0 (2012-03-30)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8  
LC_NUMERIC=C  
 [3] LC_TIME=en_US.UTF-8    LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=C LC_NAME=C 
 [9]
LC_ADDRESS=C   LC_TELEPHONE=C    
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C   

attached base packages:
[1] stats graphics  grDevices utils datasets 
methods   base 

other attached packages:
[1] TeachingDemos_2.8 stringr_0.6   reshape_0.8.4 plyr_1.7.1   

loaded via a namespace (and not attached):
[1] tcltk_2.15.0 tools_2.15.0
A.K.








From: Felipe Carrillo mazatlanmex...@yahoo.com
To: arun smartpink...@yahoo.com 
Sent: Sunday, December 16, 2012 9:28 PM
Subject: Re: [R] save to file


My text file is created but its empty. Did you start
library(TeachingDemos)
txtStart(foo.txt,commands=TRUE,results=TRUE,append=FALSE)
on you R.profile to capture the R statement?

Felipe D.
Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx



From: arun smartpink...@yahoo.com
To: Felipe Carrillo mazatlanmex...@yahoo.com 
Sent: Sunday, December 16, 2012 6:16 PM
Subject: Re: [R] save to file



Hi,
If there are comments in your code, you need to ?txtComment() from 
library(TeachingDemos).  I did a trial run and was able to get the snapshot 
in the output file.

A.K

Re: [R] Count cell Count by her frequency

2012-12-10 Thread Felipe Carrillo
And another way:
library(plyr)
ddply(dta,A,summarise,B=length(B))

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx


From: David L Carlson dcarl...@tamu.edu
To: 'Mat' matthias.we...@fnt.de; r-help@r-project.org 
Sent: Monday, December 10, 2012 7:43 AM
Subject: Re: [R] Count cell Count by her frequency

You request is not completely clear. I am assuming you want to count the
number of different characters in B for each category in A:

 A - c(10-1, 10-1, 10-1, 10-2, 10-3)
 B - c(aaa, bbb, abc, vvv, ggg)
 dta - data.frame(A, B)
 dta
    A  B
1 10-1 aaa
2 10-1 bbb
3 10-1 abc
4 10-2 vvv
5 10-3 ggg
 a1 - tapply(dta$B, dta$A, paste0, collapse=)
 a2 - strsplit(a1, )
 a3 - lapply(a2, unique)
 a4 - sapply(a3, length)
 dtanew - data.frame(A=names(a4), B=a4, row.names=1:length(a4))
 dtanew
    A B
1 10-1 3
2 10-2 1
3 10-3 1

--
David L Carlson
Associate Professor of Anthropology
Texas AM University
College Station, TX 77843-4352

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Mat
 Sent: Monday, December 10, 2012 2:50 AM
 To: r-help@r-project.org
 Subject: [R] Count cell Count by her frequency
 
 Hello togehter, i have a data.frame, with value like this:
 
        A      B
 1    10-1  aaa
 2    10-1  bbb
 3    10-1  abc
 4    10-2  vvv
 5    10-3  ggg
 
 I want now a evaluation, which character is how often in my data.frame.
 Like
 this one:
      A        B
 1  10-1  3
 2  10-2  1
 3  10-3  1
 
 How can i do this?
 
 Thank you.
 
 Mat
 
 
 
 --
 View this message in context: http://r.789695.n4.nabble.com/Count-cell-
 Count-by-her-frequency-tp4652650.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 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-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.



[[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] simple subset question

2012-12-02 Thread Felipe Carrillo
 Hi,
Consider the small dataset below, I want to subset by two variables in
one line but it wont work...it works though if I subset separately. I have
to be missing something obvious that I did not realize before while using 
subset..

fish - structure(list(IDWeek = c(27L, 28L, 29L, 30L, 31L, 32L, 33L, 
34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 
47L, 48L, 49L, 50L, 51L, 52L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 
34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 
47L, 48L, 49L, 50L, 51L, 52L), Total = c(0L, 0L, 326L, 1735L, 
1807L, 2208L, 3883L, 8820L, 6060L, 19326L, 63158L, 100718L, 53015L, 
91689L, 152629L, 122708L, 61293L, 15574L, 86538L, 75365L, 303259L, 
19691L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 161L, 321L, 1000L, 4425L, 
13202L, 19726L, 30518L, 84949L, 157260L, 145691L, 85801L, 62044L, 
44439L, 23272L, 22391L, 20159L, 14854L, 35379L, 31142L, 7736L, 
13221L, 4894L), Fry = c(0L, 0L, 326L, 1735L, 1807L, 2208L, 3883L, 
8759L, 6060L, 19326L, 63119L, 100524L, 52582L, 88170L, 145564L, 
111416L, 38233L, 5248L, 17826L, 11038L, 34008L, 215L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 161L, 321L, 1000L, 4425L, 13055L, 19488L, 
30518L, 84818L, 156909L, 144786L, 84207L, 57720L, 31049L, 6858L, 
1616L, 719L, 364L, 49L, 0L, 0L, 0L, 0L), Smolt = c(0L, 0L, 0L, 
0L, 0L, 0L, 0L, 62L, 0L, 0L, 38L, 195L, 433L, 3518L, 7067L, 11290L, 
23058L, 10327L, 68712L, 64328L, 269248L, 19479L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 147L, 238L, 0L, 131L, 351L, 
905L, 1592L, 4324L, 13391L, 16414L, 20774L, 19444L, 14491L, 35330L, 
31142L, 7736L, 13221L, 4894L), FryEq = c(0L, 0L, 326L, 1735L, 
1807L, 2208L, 3883L, 8864L, 6060L, 19326L, 63185L, 100854L, 53318L, 
94151L, 157576L, 130610L, 77432L, 22805L, 134639L, 120393L, 491733L, 
33327L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 161L, 321L, 1000L, 4425L, 
13306L, 19894L, 30518L, 85042L, 157506L, 146328L, 86914L, 65073L, 
53812L, 34763L, 36931L, 33769L, 24998L, 60110L, 52938L, 13149L, 
22476L, 8319L), Year = c(2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 
2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 
2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 
2012L, 2012L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 
2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 
2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 
2011L)), .Names = c(IDWeek, Total, Fry, Smolt, FryEq, 
Year), row.names = c(NA, 52L), class = data.frame)
fish
#  Subset to get the max Total for 2012
  x - subset(winter,Year==2012  Total==max(Total));b  # How come one line 
doesn't work?
  
  # It works if I subset the year first and then get the Total max from it
  xx - subset(winter,Year==2012)  
xxx - subset(xx,Total==max(Total));xxx   
xxx

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx

[[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] simple subset question

2012-12-02 Thread Felipe Carrillo
Sorry, I was trying it to subset from a bigger dataset called 'winter' and 
forgot to change the variable names
when I asked the question. David W suggestion works but the strange part is 
that I am still getting an error message
with :
  x - subset(fish,Year==2012  Total==max(Total));x
I get:
[1] IDWeek Total  Fry    Smolt  FryEq  Year  
0 rows (or 0-length row.names)
 
I will start a fresh session to see if that helps...Thank you all

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx


From: R. Michael Weylandt michael.weyla...@gmail.com
To: Felipe Carrillo mazatlanmex...@yahoo.com 
Cc: r-help@r-project.org r-help@r-project.org 
Sent: Sunday, December 2, 2012 9:42 AM
Subject: Re: [R] simple subset question

On Sun, Dec 2, 2012 at 5:21 PM, Felipe Carrillo
mazatlanmex...@yahoo.com wrote:
  Hi,
 Consider the small dataset below, I want to subset by two variables in
 one line but it wont work...it works though if I subset separately. I have
 to be missing something obvious that I did not realize before while using 
 subset..

 fish - structure(list(IDWeek = c(27L, 28L, 29L, 30L, 31L, 32L, 33L,
 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
 47L, 48L, 49L, 50L, 51L, 52L, 27L, 28L, 29L, 30L, 31L, 32L, 33L,
 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
 47L, 48L, 49L, 50L, 51L, 52L), Total = c(0L, 0L, 326L, 1735L,
 1807L, 2208L, 3883L, 8820L, 6060L, 19326L, 63158L, 100718L, 53015L,
 91689L, 152629L, 122708L, 61293L, 15574L, 86538L, 75365L, 303259L,
 19691L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 161L, 321L, 1000L, 4425L,
 13202L, 19726L, 30518L, 84949L, 157260L, 145691L, 85801L, 62044L,
 44439L, 23272L, 22391L, 20159L, 14854L, 35379L, 31142L, 7736L,
 13221L, 4894L), Fry = c(0L, 0L, 326L, 1735L, 1807L, 2208L, 3883L,
 8759L, 6060L, 19326L, 63119L, 100524L, 52582L, 88170L, 145564L,
 111416L, 38233L, 5248L, 17826L, 11038L, 34008L, 215L, 0L, 0L,
 0L, 0L, 0L, 0L, 0L, 0L, 161L, 321L, 1000L, 4425L, 13055L, 19488L,
 30518L, 84818L, 156909L, 144786L, 84207L, 57720L, 31049L, 6858L,
 1616L, 719L, 364L, 49L, 0L, 0L, 0L, 0L), Smolt = c(0L, 0L, 0L,
 0L, 0L, 0L, 0L, 62L, 0L, 0L, 38L, 195L, 433L, 3518L, 7067L, 11290L,
 23058L, 10327L, 68712L, 64328L, 269248L, 19479L, 0L, 0L, 0L,
 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 147L, 238L, 0L, 131L, 351L,
 905L, 1592L, 4324L, 13391L, 16414L, 20774L, 19444L, 14491L, 35330L,
 31142L, 7736L, 13221L, 4894L), FryEq = c(0L, 0L, 326L, 1735L,
 1807L, 2208L, 3883L, 8864L, 6060L, 19326L, 63185L, 100854L, 53318L,
 94151L, 157576L, 130610L, 77432L, 22805L, 134639L, 120393L, 491733L,
 33327L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 161L, 321L, 1000L, 4425L,
 13306L, 19894L, 30518L, 85042L, 157506L, 146328L, 86914L, 65073L,
 53812L, 34763L, 36931L, 33769L, 24998L, 60110L, 52938L, 13149L,
 22476L, 8319L), Year = c(2012L, 2012L, 2012L, 2012L, 2012L, 2012L,
 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L,
 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L,
 2012L, 2012L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L,
 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L,
 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L,
 2011L)), .Names = c(IDWeek, Total, Fry, Smolt, FryEq,
 Year), row.names = c(NA, 52L), class = data.frame)
 fish
 #  Subset to get the max Total for 2012
  x - subset(winter,Year==2012  Total==max(Total));b  # How come one line 
doesn't work?

Works fine for me if I change winter to fish here.

subset(fish,Year==2012  Total==max(Total))
  IDWeek  Total  Fry  Smolt  FryEq Year
21    47 303259 34008 269248 491733 2012


  # It works if I subset the year first and then get the Total max from it
  xx - subset(winter,Year==2012)
 xxx - subset(xx,Total==max(Total));xxx
 xxx

 Felipe D. Carrillo
 Supervisory Fishery Biologist
 Department of the Interior
 US Fish  Wildlife Service
 California, USA
 http://www.fws.gov/redbluff/rbdd_jsmp.aspx

        [[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.




[[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] simple subset question

2012-12-02 Thread Felipe Carrillo
Works with the small dataset (2 years) but I get the error message with the 
whole dataset (12 years of data). I am going to have
to check what's wrong with it...Thanks

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx


From: arun smartpink...@yahoo.com
To: Felipe Carrillo mazatlanmex...@yahoo.com 
Cc: R help r-help@r-project.org; R. Michael Weylandt 
michael.weyla...@gmail.com 
Sent: Sunday, December 2, 2012 10:29 AM
Subject: Re: [R] simple subset question

Hi,
I am getting this:
x-subset(fish,Year==2012  Total==max(Total))
 x
#   IDWeek  Total   Fry  Smolt  FryEq Year
#21 47 303259 34008 269248 491733 2012
A.K.




- Original Message -
From: Felipe Carrillo mazatlanmex...@yahoo.com
To: R. Michael Weylandt michael.weyla...@gmail.com
Cc: r-help@r-project.org r-help@r-project.org
Sent: Sunday, December 2, 2012 1:25 PM
Subject: Re: [R] simple subset question

Sorry, I was trying it to subset from a bigger dataset called 'winter' and 
forgot to change the variable names
when I asked the question. David W suggestion works but the strange part is 
that I am still getting an error message
with :
  x - subset(fish,Year==2012  Total==max(Total));x
I get:
[1] IDWeek Total  Fry    Smolt  FryEq  Year  
0 rows (or 0-length row.names)
 
I will start a fresh session to see if that helps...Thank you all

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx


From: R. Michael Weylandt michael.weyla...@gmail.com
To: Felipe Carrillo mazatlanmex...@yahoo.com 
Cc: r-help@r-project.org r-help@r-project.org 
Sent: Sunday, December 2, 2012 9:42 AM
Subject: Re: [R] simple subset question

On Sun, Dec 2, 2012 at 5:21 PM, Felipe Carrillo
mazatlanmex...@yahoo.com wrote:
  Hi,
 Consider the small dataset below, I want to subset by two variables in
 one line but it wont work...it works though if I subset separately. I have
 to be missing something obvious that I did not realize before while using 
 subset..

 fish - structure(list(IDWeek = c(27L, 28L, 29L, 30L, 31L, 32L, 33L,
 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
 47L, 48L, 49L, 50L, 51L, 52L, 27L, 28L, 29L, 30L, 31L, 32L, 33L,
 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
 47L, 48L, 49L, 50L, 51L, 52L), Total = c(0L, 0L, 326L, 1735L,
 1807L, 2208L, 3883L, 8820L, 6060L, 19326L, 63158L, 100718L, 53015L,
 91689L, 152629L, 122708L, 61293L, 15574L, 86538L, 75365L, 303259L,
 19691L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 161L, 321L, 1000L, 4425L,
 13202L, 19726L, 30518L, 84949L, 157260L, 145691L, 85801L, 62044L,
 44439L, 23272L, 22391L, 20159L, 14854L, 35379L, 31142L, 7736L,
 13221L, 4894L), Fry = c(0L, 0L, 326L, 1735L, 1807L, 2208L, 3883L,
 8759L, 6060L, 19326L, 63119L, 100524L, 52582L, 88170L, 145564L,
 111416L, 38233L, 5248L, 17826L, 11038L, 34008L, 215L, 0L, 0L,
 0L, 0L, 0L, 0L, 0L, 0L, 161L, 321L, 1000L, 4425L, 13055L, 19488L,
 30518L, 84818L, 156909L, 144786L, 84207L, 57720L, 31049L, 6858L,
 1616L, 719L, 364L, 49L, 0L, 0L, 0L, 0L), Smolt = c(0L, 0L, 0L,
 0L, 0L, 0L, 0L, 62L, 0L, 0L, 38L, 195L, 433L, 3518L, 7067L, 11290L,
 23058L, 10327L, 68712L, 64328L, 269248L, 19479L, 0L, 0L, 0L,
 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 147L, 238L, 0L, 131L, 351L,
 905L, 1592L, 4324L, 13391L, 16414L, 20774L, 19444L, 14491L, 35330L,
 31142L, 7736L, 13221L, 4894L), FryEq = c(0L, 0L, 326L, 1735L,
 1807L, 2208L, 3883L, 8864L, 6060L, 19326L, 63185L, 100854L, 53318L,
 94151L, 157576L, 130610L, 77432L, 22805L, 134639L, 120393L, 491733L,
 33327L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 161L, 321L, 1000L, 4425L,
 13306L, 19894L, 30518L, 85042L, 157506L, 146328L, 86914L, 65073L,
 53812L, 34763L, 36931L, 33769L, 24998L, 60110L, 52938L, 13149L,
 22476L, 8319L), Year = c(2012L, 2012L, 2012L, 2012L, 2012L, 2012L,
 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L,
 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L,
 2012L, 2012L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L,
 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L,
 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L,
 2011L)), .Names = c(IDWeek, Total, Fry, Smolt, FryEq,
 Year), row.names = c(NA, 52L), class = data.frame)
 fish
 #  Subset to get the max Total for 2012
  x - subset(winter,Year==2012  Total==max(Total));b  # How come one line 
doesn't work?

Works fine for me if I change winter to fish here.

subset(fish,Year==2012  Total==max(Total))
  IDWeek  Total  Fry  Smolt  FryEq Year
21    47 303259 34008 269248 491733 2012


  # It works if I subset the year first and then get the Total max from it
  xx - subset(winter,Year==2012)
 xxx - subset(xx,Total==max(Total));xxx
 xxx

 Felipe D. Carrillo
 Supervisory Fishery Biologist
 Department of the Interior
 US Fish  Wildlife Service
 California, USA
 http://www.fws.gov/redbluff

Re: [R] simple subset question

2012-12-02 Thread Felipe Carrillo
 
Using my whole dataset I get:
library(plyr)
ddply(winter,Year,summarise,maxTotal=max(Total))
 
 fish - structure(list(Year = 2002:2012, maxTotal = c(1464311L, 1071051L, 
714837L, 2115018L, 850491L, 207537L, 321195L, 935599L, 194429L, 
157260L, 303259L)), .Names = c(Year, maxTotal), row.names = c(NA, 
-11L), class = data.frame)
 
I only want to extract the max Total for 2012 and want the whole row like this:
 IDWeek  Total   Fry  Smolt  FryEq Year
21 47 303259 34008 269248 491733 2012
 
My whole dataset is too big to post it so thanks for your help and will try
to figure out why subset returns an empty row

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx


From: William Dunlap wdun...@tibco.com
To: Felipe Carrillo mazatlanmex...@yahoo.com; arun smartpink...@yahoo.com 
Cc: R help r-help@r-project.org 
Sent: Sunday, December 2, 2012 11:00 AM
Subject: RE: [R] simple subset question

 I am
 still getting an error message
 with :
   x - subset(fish,Year==2012  Total==max(Total));x
 I get:
 [1] IDWeek Total  Fry    Smolt  FryEq  Year
 0 rows (or 0-length row.names)

The above is not an error message.  It says that there
are no rows satisfying your criteria.  Note that Total==max(Total)
returns a TRUE for each row in which the Total value
equals the maximum Total value over all the years in
the data.  Are you looking for the maximum value of Total
in each year?

 tmp - transform(fish, YearlyMaxTotal = ave(Total, Year, FUN=max))
 subset(tmp, Total==YearlyMaxTotal)
  IDWeek  Total    Fry  Smolt  FryEq Year YearlyMaxTotal
21    47 303259  34008 269248 491733 2012        303259
39    39 157260 156909    351 157506 2011        157260
 subset(tmp, Total==YearlyMaxTotal  Year==2012)
  IDWeek  Total  Fry  Smolt  FryEq Year YearlyMaxTotal
21    47 303259 34008 269248 491733 2012        303259

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf
 Of Felipe Carrillo
 Sent: Sunday, December 02, 2012 10:47 AM
 To: arun
 Cc: R help
 Subject: Re: [R] simple subset question
 
 Works with the small dataset (2 years) but I get the error message with the 
 whole
 dataset (12 years of data). I am going to have
 to check what's wrong with it...Thanks
 
 Felipe D. Carrillo
 Supervisory Fishery Biologist
 Department of the Interior
 US Fish  Wildlife Service
 California, USA
 http://www.fws.gov/redbluff/rbdd_jsmp.aspx
 
 
 From: arun smartpink...@yahoo.com
 To: Felipe Carrillo mazatlanmex...@yahoo.com
 Cc: R help r-help@r-project.org; R. Michael Weylandt
 michael.weyla...@gmail.com
 Sent: Sunday, December 2, 2012 10:29 AM
 Subject: Re: [R] simple subset question
 
 Hi,
 I am getting this:
 x-subset(fish,Year==2012  Total==max(Total))
  x
 #   IDWeek  Total   Fry  Smolt  FryEq Year
 #21 47 303259 34008 269248 491733 2012
 A.K.
 
 
 
 
 - Original Message -
 From: Felipe Carrillo mazatlanmex...@yahoo.com
 To: R. Michael Weylandt michael.weyla...@gmail.com
 Cc: r-help@r-project.org r-help@r-project.org
 Sent: Sunday, December 2, 2012 1:25 PM
 Subject: Re: [R] simple subset question
 
 Sorry, I was trying it to subset from a bigger dataset called 'winter' and 
 forgot to
 change the variable names
 when I asked the question. David W suggestion works but the strange part is 
 that I am
 still getting an error message
 with :
   x - subset(fish,Year==2012  Total==max(Total));x
 I get:
 [1] IDWeek Total  Fry    Smolt  FryEq  Year
 0 rows (or 0-length row.names)
 
 I will start a fresh session to see if that helps...Thank you all
 
 Felipe D. Carrillo
 Supervisory Fishery Biologist
 Department of the Interior
 US Fish  Wildlife Service
 California, USA
 http://www.fws.gov/redbluff/rbdd_jsmp.aspx
 
 
 From: R. Michael Weylandt michael.weyla...@gmail.com
 To: Felipe Carrillo mazatlanmex...@yahoo.com
 Cc: r-help@r-project.org r-help@r-project.org
 Sent: Sunday, December 2, 2012 9:42 AM
 Subject: Re: [R] simple subset question
 
 On Sun, Dec 2, 2012 at 5:21 PM, Felipe Carrillo
 mazatlanmex...@yahoo.com wrote:
   Hi,
  Consider the small dataset below, I want to subset by two variables in
  one line but it wont work...it works though if I subset separately. I 
  have
  to be missing something obvious that I did not realize before while 
  using subset..
 
  fish - structure(list(IDWeek = c(27L, 28L, 29L, 30L, 31L, 32L, 33L,
  34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
  47L, 48L, 49L, 50L, 51L, 52L, 27L, 28L, 29L, 30L, 31L, 32L, 33L,
  34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
  47L, 48L, 49L, 50L, 51L, 52L), Total = c(0L, 0L, 326L, 1735L,
  1807L, 2208L, 3883L, 8820L, 6060L, 19326L, 63158L, 100718L, 53015L,
  91689L, 152629L, 122708L, 61293L, 15574L, 86538L, 75365L, 303259L,
  19691L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 161L, 321L, 1000L, 4425L,
  13202L, 19726L

Re: [R] simple subset question

2012-12-02 Thread Felipe Carrillo
I also thought that I could use it but ggplot didn't like it by itself,,,it 
wants to whole rowI guess it is hard
to understand because I didn't post all the ggplot code of what I am trying to 
accomplish. The strangest thing is that
ddply can extract all my Totals by year but when I try to subset only one year 
out of my whole dataset, it returns
empty rows it regardless of what year I am subsetting. I am doing  a few tests 
to see what's going on

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx


From: David Winsemius dwinsem...@comcast.net
To: Felipe Carrillo mazatlanmex...@yahoo.com 
Cc: William Dunlap wdun...@tibco.com; arun smartpink...@yahoo.com; R help 
r-help@r-project.org 
Sent: Sunday, December 2, 2012 11:54 AM
Subject: Re: [R] simple subset question

The reason I suggested the alternative that I did was because your code could 
fail when the max(Total) value was not in the subset where Year==2012.

--David
On Dec 2, 2012, at 11:34 AM, Felipe Carrillo wrote:

 
 Using my whole dataset I get:
 library(plyr)
 ddply(winter,Year,summarise,maxTotal=max(Total))
 
  fish - structure(list(Year = 2002:2012, maxTotal = c(1464311L, 1071051L,
 714837L, 2115018L, 850491L, 207537L, 321195L, 935599L, 194429L,
 157260L, 303259L)), .Names = c(Year, maxTotal), row.names = c(NA,
 -11L), class = data.frame)
 
 I only want to extract the max Total for 2012 and want the whole row like 
 this:
  IDWeek  Total  Fry  Smolt  FryEq Year
 21    47 303259 34008 269248 491733 2012
 
 My whole dataset is too big to post it so thanks for your help and will try
 to figure out why subset returns an empty row
 
 Felipe D. Carrillo
 Supervisory Fishery Biologist
 Department of the Interior
 US Fish  Wildlife Service
 California, USA
 http://www.fws.gov/redbluff/rbdd_jsmp.aspx
 
 
 From: William Dunlap wdun...@tibco.com
 To: Felipe Carrillo mazatlanmex...@yahoo.com; arun 
 smartpink...@yahoo.com
 Cc: R help r-help@r-project.org
 Sent: Sunday, December 2, 2012 11:00 AM
 Subject: RE: [R] simple subset question
 
 I am
 still getting an error message
 with :
  x - subset(fish,Year==2012  Total==max(Total));x
 I get:
 [1] IDWeek Total  Fry    Smolt  FryEq  Year
 0 rows (or 0-length row.names)
 
 The above is not an error message.  It says that there
 are no rows satisfying your criteria.  Note that Total==max(Total)
 returns a TRUE for each row in which the Total value
 equals the maximum Total value over all the years in
 the data.  Are you looking for the maximum value of Total
 in each year?
 
 tmp - transform(fish, YearlyMaxTotal = ave(Total, Year, FUN=max))
 subset(tmp, Total==YearlyMaxTotal)
  IDWeek  Total    Fry  Smolt  FryEq Year YearlyMaxTotal
 21    47 303259  34008 269248 491733 2012        303259
 39    39 157260 156909    351 157506 2011        157260
 subset(tmp, Total==YearlyMaxTotal  Year==2012)
  IDWeek  Total  Fry  Smolt  FryEq Year YearlyMaxTotal
 21    47 303259 34008 269248 491733 2012        303259
 
 Bill Dunlap
 Spotfire, TIBCO Software
 wdunlap tibco.com
 
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] 
 On Behalf
 Of Felipe Carrillo
 Sent: Sunday, December 02, 2012 10:47 AM
 To: arun
 Cc: R help
 Subject: Re: [R] simple subset question
 
 Works with the small dataset (2 years) but I get the error message with 
 the whole
 dataset (12 years of data). I am going to have
 to check what's wrong with it...Thanks
 
 Felipe D. Carrillo
 Supervisory Fishery Biologist
 Department of the Interior
 US Fish  Wildlife Service
 California, USA
 http://www.fws.gov/redbluff/rbdd_jsmp.aspx
 
 
 From: arun smartpink...@yahoo.com
 To: Felipe Carrillo mazatlanmex...@yahoo.com
 Cc: R help r-help@r-project.org; R. Michael Weylandt
 michael.weyla...@gmail.com
 Sent: Sunday, December 2, 2012 10:29 AM
 Subject: Re: [R] simple subset question
 
 Hi,
 I am getting this:
 x-subset(fish,Year==2012  Total==max(Total))
  x
 #  IDWeek  Total  Fry  Smolt  FryEq Year
 #21    47 303259 34008 269248 491733 2012
 A.K.
 
 
 
 
 - Original Message -
 From: Felipe Carrillo mazatlanmex...@yahoo.com
 To: R. Michael Weylandt michael.weyla...@gmail.com
 Cc: r-help@r-project.org r-help@r-project.org
 Sent: Sunday, December 2, 2012 1:25 PM
 Subject: Re: [R] simple subset question
 
 Sorry, I was trying it to subset from a bigger dataset called 'winter' 
 and forgot to
 change the variable names
 when I asked the question. David W suggestion works but the strange part 
 is that I am
 still getting an error message
 with :
  x - subset(fish,Year==2012  Total==max(Total));x
 I get:
 [1] IDWeek Total  Fry    Smolt  FryEq  Year
 0 rows (or 0-length row.names)
 
 I will start a fresh session to see if that helps...Thank you all
 
 Felipe D. Carrillo
 Supervisory Fishery Biologist
 Department of the Interior
 US Fish  Wildlife Service
 California, USA
 http://www.fws.gov

Re: [R] simple subset question

2012-12-02 Thread Felipe Carrillo
, 2012L, 2012L, 2012L, 2012L,
2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L,
2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2012L, 2011L, 2011L,
2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L,
2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L,
2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L, 2010L,
2010L, 2010L, 2010L, 2010L, 2010L, 2009L, 2009L, 2009L, 2009L,
2009L, 2009L, 2009L, 2009L, 2009L, 2009L, 2009L, 2009L, 2009L,
2009L, 2009L, 2009L, 2009L, 2009L, 2009L, 2009L, 2009L, 2009L,
2009L, 2009L, 2009L, 2009L, 2008L, 2008L, 2008L, 2008L, 2008L,
2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L,
2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L,
2008L, 2008L, 2008L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L,
2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L,
2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L, 2007L,
2007L, 2007L, 2006L, 2006L, 2006L, 2006L, 2006L, 2006L, 2006L,
2006L, 2006L, 2006L, 2006L, 2006L, 2006L, 2006L, 2006L, 2006L,
2006L, 2006L, 2006L, 2006L, 2006L, 2006L, 2006L, 2006L, 2006L,
2006L, 2005L, 2005L, 2005L, 2005L, 2005L, 2005L, 2005L, 2005L,
2005L, 2005L, 2005L, 2005L, 2005L, 2005L, 2005L, 2005L, 2005L,
2005L, 2005L, 2005L, 2005L, 2005L, 2005L, 2005L, 2005L, 2005L,
2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L,
2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L,
2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2004L, 2003L,
2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L,
2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L,
2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2003L, 2002L, 2002L,
2002L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L,
2002L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L,
2002L, 2002L, 2002L, 2002L, 2002L, 2002L)), .Names = c(IDWeek,
Total, Fry, Smolt, FryEq, Year), class = data.frame, row.names = 
c(NA,
-286L))
 library(ggplot2)
 library(plyr)
 dim(winter);head(winter)
   str(winter)
 test - ggplot(winter,aes(IDWeek,Total)) + geom_line(colour='blue') + 
facet_wrap(~Year,as.table=F) +
  geom_vline(xintercept=47,colour='red',linetype='dashed')  +
   geom_hline(yintercept=30,colour='orange',linetype='dashed',size=1)  +
   opts(title=Winter Chinook 2002-2012)  +
   geom_point(data=subset(winter,Year==2012  
Total==max(Total)),size=7,shape=1,color='green') # Want to be able to subset 
using max on the fly
   
test
 # But it doesn't subset at all
   
   # It works if I get the max Total like this:
   test - ggplot(winter,aes(IDWeek,Total)) + geom_line(colour='blue') + 
facet_wrap(~Year,as.table=F) +
  geom_vline(xintercept=47,colour='red',linetype='dashed')  +
   geom_hline(yintercept=30,colour='orange',linetype='dashed',size=1)  +
   opts(title=Winter Chinook 2002-2012)  +
   geom_point(data=subset(winter,Year==2012  Total  
30),size=7,shape=1,color='green') # it works if get the Total like this
   test

    # Zooming in to the weeks of interest (weeks 45 to 52) and put a point on 
the 2012 max catch which is week 37
    windows()
  test + coord_cartesian(xlim=c(45,52)) + 
scale_x_continuous(breaks=c(45,47,49,51)) +
  scale_y_continuous(limits=c(0,35)) + opts(title=Zooming in to weeks 45 
to 52)
 
 
 

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx




From: arun smartpink...@yahoo.com
To: Felipe Carrillo mazatlanmex...@yahoo.com 
Cc: William Dunlap wdun...@tibco.com; David Winsemius 
dwinsem...@comcast.net; R help r-help@r-project.org 
Sent: Sunday, December 2, 2012 1:18 PM
Subject: Re: [R] simple subset question

Hi,
From the ddply() output, you could get the whole row by:

 fish1 - structure(list(Year = 2002:2012, maxTotal = c(1464311L, 1071051L, 
714837L, 2115018L, 850491L, 207537L, 321195L, 935599L, 194429L, 
157260L, 303259L)), .Names = c(Year, maxTotal), row.names = c(NA, 
-11L), class = data.frame)


 fish[fish[,2]%in%fish1[,2][fish1[,1]==2012],]  #fish (or winter) is your 
original dataset
#   IDWeek  Total   Fry  Smolt  FryEq Year
#21 47 303259 34008 269248 491733 2012
A.K.






From: Felipe Carrillo mazatlanmex...@yahoo.com
To: William Dunlap wdun...@tibco.com; arun smartpink...@yahoo.com 
Cc: R help r-help@r-project.org 
Sent: Sunday, December 2, 2012 2:34 PM
Subject: Re: [R] simple subset question



Using my whole dataset I get:
library(plyr)
ddply(winter,Year,summarise,maxTotal=max(Total))

 fish - structure(list(Year = 2002:2012, maxTotal = c(1464311L, 1071051L, 
714837L, 2115018L, 850491L, 207537L, 321195L, 935599L, 194429L, 
157260L

Re: [R] simple subset question

2012-12-02 Thread Felipe Carrillo
I finally see what you and David W mean...I was under the assumption that by 
subsetting
Year==2012 it would also extract the max for that year.I guess I have to 
review 'subset' again :)
Thank you much 

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx




From: David L Carlson dcarl...@tamu.edu
To: 'Felipe Carrillo' mazatlanmex...@yahoo.com; 'arun' 
smartpink...@yahoo.com 
Cc: 'R help' r-help@r-project.org 
Sent: Sunday, December 2, 2012 2:54 PM
Subject: RE: [R] simple subset question

As David W. guessed. The maximum is in year 2005 not 2012 so no row from
2012 matches the maximum.

 subset(winter,Year==2012  Total==max(Total))
[1] IDWeek Total  Fry    Smolt  FryEq  Year  
0 rows (or 0-length row.names)
 winter[which(winter$Total==max(winter$Total)),]
    IDWeek  Total    Fry Smolt  FryEq Year
195    39 2115018 2083214 31805 2137281 2005

Change to

 subset(winter, Year==2012  Total==max(Total[Year==2012]))
  IDWeek  Total  Fry  Smolt  FryEq Year
21    47 303259 34008 269248 491733 2012

--
David L Carlson
Associate Professor of Anthropology
Texas AM University
College Station, TX 77843-4352


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Felipe Carrillo
 Sent: Sunday, December 02, 2012 4:40 PM
 To: arun
 Cc: R help
 Subject: Re: [R] simple subset question
 
 Actually, I dput(winter) and is not that big.so here is the whole
 thing I
 am trying to accomplish.
  winter - structure(list(IDWeek = c(27L, 28L, 29L, 30L, 31L, 32L, 33L,
 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
 47L, 48L, 49L, 50L, 51L, 52L, 27L, 28L, 29L, 30L, 31L, 32L, 33L,
 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
 47L, 48L, 49L, 50L, 51L, 52L, 27L, 28L, 29L, 30L, 31L, 32L, 33L,
 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
 47L, 48L, 49L, 50L, 51L, 52L, 27L, 28L, 29L, 30L, 31L, 32L, 33L,
 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
 47L, 48L, 49L, 50L, 51L, 52L, 27L, 28L, 29L, 30L, 31L, 32L, 33L,
 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
 47L, 48L, 49L, 50L, 51L, 52L, 27L, 28L, 29L, 30L, 31L, 32L, 33L,
 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
 47L, 48L, 49L, 50L, 51L, 52L, 27L, 28L, 29L, 30L, 31L, 32L, 33L,
 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
 47L, 48L, 49L, 50L, 51L, 52L, 27L, 28L, 29L, 30L, 31L, 32L, 33L,
 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
 47L, 48L, 49L, 50L, 51L, 52L, 27L, 28L, 29L, 30L, 31L, 32L, 33L,
 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
 47L, 48L, 49L, 50L, 51L, 52L, 27L, 28L, 29L, 30L, 31L, 32L, 33L,
 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
 47L, 48L, 49L, 50L, 51L, 52L, 27L, 28L, 29L, 30L, 31L, 32L, 33L,
 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
 47L, 48L, 49L, 50L, 51L, 52L), Total = c(0L, 0L, 326L, 1735L,
 1807L, 2208L, 3883L, 8820L, 6060L, 19326L, 63158L, 100718L, 53015L,
 91689L, 152629L, 122708L, 61293L, 15574L, 86538L, 75365L, 303259L,
 19691L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 161L, 321L, 1000L, 4425L,
 13202L, 19726L, 30518L, 84949L, 157260L, 145691L, 85801L, 62044L,
 44439L, 23272L, 22391L, 20159L, 14854L, 35379L, 31142L, 7736L,
 13221L, 4894L, 0L, 460L, 1129L, 1757L, 11105L, 27730L, 55769L,
 12298L, 32964L, 80110L, 160507L, 74134L, 101736L, 138355L, 107873L,
 53806L, 194429L, 7596L, 55497L, 30336L, 18392L, 22291L, 16850L,
 16567L, 14799L, 7909L, 93L, 329L, 363L, 2762L, 5573L, 33466L,
 96762L, 340947L, 612835L, 347972L, 526506L, 656981L, 344181L,
 145465L, 150543L, 935599L, 32789L, 15092L, 7288L, 9889L, 6945L,
 5138L, 6299L, 3095L, 108227L, 1191L, 0L, 0L, 132L, 227L, 2157L,
 7558L, 16459L, 87220L, 321195L, 209299L, 110807L, 112024L, 128058L,
 74373L, 41531L, 15111L, 21890L, 15060L, 22538L, 12443L, 11052L,
 3907L, 2640L, 2745L, 3936L, 17593L, 0L, 0L, 10775L, 4166L, 4958L,
 16221L, 29401L, 34951L, 33188L, 146044L, 105007L, 185297L, 159682L,
 207537L, 140694L, 128275L, 44274L, 27079L, 18928L, 10437L, 29984L,
 18395L, 25846L, 4573L, 31995L, 3679L, 707L, 2390L, 8860L, 24430L,
 40885L, 72792L, 205521L, 344493L, 662973L, 526409L, 631953L,
 850491L, 842678L, 445987L, 558152L, 332032L, 174326L, 80601L,
 48696L, 98571L, 103563L, 149469L, 78081L, 182478L, 2158L, 16566L,
 0L, 868L, 2044L, 4064L, 6049L, 9399L, 13304L, 45172L, 242155L,
 476864L, 712534L, 1058409L, 2115018L, 1510342L, 1138213L, 333192L,
 158820L, 94379L, 348882L, 39290L, 29701L, 47258L, 69837L, 7884L,
 49338L, 22168L, 0L, 147L, 1231L, 3216L, 5021L, 18462L, 37441L,
 64669L, 136590L, 338523L, 559448L, 714837L, 358037L, 180910L,
 291943L, 222708L, 163801L, 39109L, 23247L, 15726L, 38701L, 5795L,
 12509L, 18721L, 822L, 6674L, 765L, 1753L, 6226L

Re: [R] arrange data

2012-11-12 Thread Felipe Carrillo
Since you specifically want either nov or dec
you actually don't need '=' use instead '= ='
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx


From: Roslina Zakaria zrosl...@yahoo.com
To: Felipe Carrillo mazatlanmex...@yahoo.com 
Sent: Sunday, November 11, 2012 10:56 PM
Subject: Re: [R] arrange data


Thank you so much Felipe, I'll try your suggestion.


From: Felipe Carrillo mazatlanmex...@yahoo.com
To: Roslina Zakaria zrosl...@yahoo.com; r-help@r-project.org 
r-help@r-project.org 
Sent: Monday, November 12, 2012 12:09 PM
Subject: Re: [R] arrange data


Something like this...untested
I think cbind recycles the last value(31) since nov and dec are of different 
length
nov - kuantan.dt[(kuantan.dt$Bulan =11);nov
dec - kuantan.dt[(kuantan.dt$Bulan =12);dec
both - cbind(nov,dec)
# get the first 30 records
both - head(both,30);both



Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx



From: Roslina Zakaria zrosl...@yahoo.com
To: r-help@r-project.org r-help@r-project.org 
Sent: Sunday, November 11, 2012 6:39 PM
Subject: [R] arrange data

Dear r-users,
 
I have daily rainfall data from 1971 to 2000.  I would like to extract 
november and december data only.  I would also like to do column bind for 
november and december, therefore I would like to delete 31 December from 
december data so that the length of november and december are the same.  Hope 
somebody can help me.  I tried this below:
 
 kuantan.dt.1 - kuantan.dt[(kuantan.dt$Bulan =11)  (kuantan.dt$Bulan = 
 12),]
 head(kuantan.dt.1) ; tail(kuantan.dt.1)
    Tahun Bulan Hari Jumlah.Hujan.mm.
305    71    11    1  0.0
306    71    11    2 16.3
307    71    11    3  0.0
308    71    11    4  0.0
309    71    11    5 12.2
310    71    11    6  4.6
  Tahun Bulan Hari Jumlah.Hujan.mm.
10953 0    12   26  0.0
10954 0    12   27  0.0
10955 0    12   28 20.0
10956 0    12   29 15.5
10957 0    12   30  6.4
10958 0    12   31  9.3
    [[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.







[[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] arrange data

2012-11-11 Thread Felipe Carrillo
Something like this...untested
I think cbind recicles the last value(31) since nov and dec are of different 
length
nov - kuantan.dt[(kuantan.dt$Bulan =11);nov
dec - kuantan.dt[(kuantan.dt$Bulan =12);dec
both - cbind(nov,dec)
# get the first 30 records
both - head(both,30);both


Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx


From: Roslina Zakaria zrosl...@yahoo.com
To: r-help@r-project.org r-help@r-project.org 
Sent: Sunday, November 11, 2012 6:39 PM
Subject: [R] arrange data

Dear r-users,
 
I have daily rainfall data from 1971 to 2000.  I would like to extract 
november and december data only.  I would also like to do column bind for 
november and december, therefore I would like to delete 31 December from 
december data so that the length of november and december are the same.  Hope 
somebody can help me.  I tried this below:
 
 kuantan.dt.1 - kuantan.dt[(kuantan.dt$Bulan =11)  (kuantan.dt$Bulan = 
 12),]
 head(kuantan.dt.1) ; tail(kuantan.dt.1)
    Tahun Bulan Hari Jumlah.Hujan.mm.
305    71    11    1  0.0
306    71    11    2 16.3
307    71    11    3  0.0
308    71    11    4  0.0
309    71    11    5 12.2
310    71    11    6  4.6
  Tahun Bulan Hari Jumlah.Hujan.mm.
10953 0    12   26  0.0
10954 0    12   27  0.0
10955 0    12   28 20.0
10956 0    12   29 15.5
10957 0    12   30  6.4
10958 0    12   31  9.3
    [[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.



[[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] mean of a value of the last 2 hours

2012-10-25 Thread Felipe Carrillo
Or using ddply from plyr,
 
library(plyr)
myframe - data.frame (ID=c(Ernie, Ernie, Ernie, Bert, Bert,
Bert), Timestamp=c(24.09.2012 09:00, 24.09.2012 10:00, 24.09.2012
11:00), Hunger=c(1,1,1,2,2,1) )
myframe
myframestime - as.POSIXct (strptime(as.character(myframe$Timestamp),
%d.%m.%Y %H:%M), tz=GMT)
myframestime
myframe2 - cbind (myframe,myframestime)
myframe2
ddply(myframe2,.(ID),summarise,Last2=mean(tail(Hunger,2)))


Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx


From: Tagmarie ramga...@gmx.net
To: r-help@r-project.org 
Sent: Thursday, October 25, 2012 7:35 AM
Subject: [R] mean of a value of the last 2 hours

Hello, 
I have a data frame somewhat like that: 

myframe - data.frame (ID=c(Ernie, Ernie, Ernie, Bert, Bert,
Bert), Timestamp=c(24.09.2012 09:00, 24.09.2012 10:00, 24.09.2012
11:00), Hunger=c(1,1,1,2,2,1) )
myframestime - as.POSIXct (strptime(as.character(myframe$Timestamp),
%d.%m.%Y %H:%M), tz=GMT)
myframe2 - cbind (myframe,myframestime)
myframe2$Timestamp - NULL  
myframe2

I want to add an additional column at the right and get in each row a value
which shows the mean of hunger of the last two hours. 

Does anyone know how that works? That would be very helpful. 



--
View this message in context: 
http://r.789695.n4.nabble.com/mean-of-a-value-of-the-last-2-hours-tp4647415.html
Sent from the R help mailing list archive at Nabble.com.

__
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.



[[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] nls question

2012-07-12 Thread Felipe Carrillo
 Hi:
 Using nls how can I increase the numbers of iterations to go beyond 50.
 I just want to be able to predict for the last two weeks of the year.
 This is what I have:

 weight_random - runif(50,1,24)
 weight - sort(weight_random);weight
weightData - data.frame(weight,week=1:50)
 weightData
plot(weight ~ week, weightData)
M_model - nls(weight ~ alpha + beta*exp(gamma*week), weightData,
  start = c(alpha = 0.0, beta = 1, gamma = 0.2), trace = TRUE)
 
### I get the error below:
Error in nls(weight ~ alpha + beta * exp(gamma * week), weightData, start = 
c(alpha = 0,  : 
  number of iterations exceeded maximum of 50


M_model
### predict for another 2 weeks
newD - data.frame(week = 1:52);newD
newD$pred_wt - predict(M_model, newD)
newD
plot(pred_wt ~ week, newD, pch = 4, col = red, ylab = Weight, xlab = Week)
with(weightData, points(week, weight,col='blue'))


Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx

[[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] nls question

2012-07-12 Thread Felipe Carrillo
Thanks Bert, I increased the  number of iterations:
 
M_model - nls(weight ~ alpha + 
beta*exp(gamma*week),control=nls.control(maxiter=200), weightData,
 start = c(alpha = 0.0, beta = 1, gamma = 0.2), trace = TRUE)
 
But now the 'start' argument seems to be the problem. 
Looking at the model coefficients:
  alpha  beta gamma 
-49.108008320  52.394172340   0.005269907 
If I change the alpha and beta values inside start..I still get the error...

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx




From: Bert Gunter gunter.ber...@gene.com
To: Felipe Carrillo mazatlanmex...@yahoo.com 
Cc: r-help@r-project.org r-help@r-project.org 
Sent: Thursday, July 12, 2012 10:56 AM
Subject: Re: [R] nls question


Read the Help file!

?nls ## Note the control argument
?nls.control

-- Bert


On Thu, Jul 12, 2012 at 10:47 AM, Felipe Carrillo mazatlanmex...@yahoo.com 
wrote:

 Hi:
 Using nls how can I increase the numbers of iterations to go beyond 50.
 I just want to be able to predict for the last two weeks of the year.
 This is what I have:

 weight_random - runif(50,1,24)
 weight - sort(weight_random);weight
weightData - data.frame(weight,week=1:50)
 weightData
plot(weight ~ week, weightData)
M_model - nls(weight ~ alpha + beta*exp(gamma*week), weightData,
  start = c(alpha = 0.0, beta = 1, gamma = 0.2), trace = TRUE)
 
### I get the error below:
Error in nls(weight ~ alpha + beta * exp(gamma * week), weightData, start = 
c(alpha = 0,  :
  number of iterations exceeded maximum of 50


M_model
### predict for another 2 weeks
newD - data.frame(week = 1:52);newD
newD$pred_wt - predict(M_model, newD)
newD
plot(pred_wt ~ week, newD, pch = 4, col = red, ylab = Weight, xlab = 
Week)
with(weightData, points(week, weight,col='blue'))


Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx

        [[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.




-- 



Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:

http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm




[[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] nls question

2012-07-12 Thread Felipe Carrillo
I get a different error now:
  nls(weight ~ cbind(1, exp(gamma*week)), weightData, start = list(gamma= 
0.2), alg = plinear)
Error in nls(weight ~ cbind(1, exp(gamma * week)), weightData, start = 
list(gamma = 0.2),  : 
  step factor 0.000488281 reduced below 'minFactor' of 0.000976562
The help file says: When start is missing, a very cheap guess for start 
is tried (if algorithm != plinear). 

So I removed  'plinear' from the call and got the following:
 nls(weight ~ cbind(1, exp(gamma*week)), weightData,start = 
list(gamma=0.2),trace=TRUE)
1466475181 :  0.2 
Error in qr.qty(QR, resid) : 
  'qr' and 'y' must have the same number of rows


Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx




From: Gabor Grothendieck ggrothendi...@gmail.com
To: Felipe Carrillo mazatlanmex...@yahoo.com 
Cc: Bert Gunter gunter.ber...@gene.com; r-help@r-project.org 
r-help@r-project.org 
Sent: Thursday, July 12, 2012 12:14 PM
Subject: Re: [R] nls question

On Thu, Jul 12, 2012 at 3:02 PM, Felipe Carrillo
mazatlanmex...@yahoo.com wrote:
 Thanks Bert, I increased the  number of iterations:

 M_model - nls(weight ~ alpha + 
 beta*exp(gamma*week),control=nls.control(maxiter=200), weightData,
              start = c(alpha = 0.0, beta = 1, gamma = 0.2), trace = TRUE)

 But now the 'start' argument seems to be the problem.
 Looking at the model coefficients:
  alpha          beta        gamma
 -49.108008320  52.394172340  0.005269907
 If I change the alpha and beta values inside start..I still get the error...

Try using the plinear algorithm:

nls(weight ~ cbind(1, exp(gamma*week)), weightData, start = list(gamma
= 0.2), alg = plinear)


-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



[[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] nls question

2012-07-12 Thread Felipe Carrillo
Thank you all for your help.


Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx




From: Gabor Grothendieck ggrothendi...@gmail.com
To: Felipe Carrillo mazatlanmex...@yahoo.com 
Cc: r-help@r-project.org r-help@r-project.org 
Sent: Thursday, July 12, 2012 1:03 PM
Subject: Re: [R] nls question

On Thu, Jul 12, 2012 at 3:40 PM, Felipe Carrillo
mazatlanmex...@yahoo.com wrote:
 I get a different error now:
  nls(weight ~ cbind(1, exp(gamma*week)), weightData, start = list(gamma=
 0.2), alg = plinear)
 Error in nls(weight ~ cbind(1, exp(gamma * week)), weightData, start =
 list(gamma = 0.2),  :
  step factor 0.000488281 reduced below 'minFactor' of 0.000976562
 The help file says: When start is missing, a very cheap guess for
 start is tried (if algorithm != plinear).


Please give a reproducible example by setting the seed.  This
reproducible example converges:

 set.seed(123)
 weight_random - runif(50,1,24)
 weight - sort(weight_random)
 weightData - data.frame(weight,week=1:50)
 nls(weight ~ cbind(1, exp(gamma*week)), weightData, start = list(gamma = 
 0.2), alg = plinear)
Nonlinear regression model
  model:  weight ~ cbind(1, exp(gamma * week))
  data:  weightData
    gamma      .lin1      .lin2
1.136e-03 -3.949e+02  3.962e+02
residual sum-of-squares: 9.17

Number of iterations to convergence: 8
Achieved convergence tolerance: 9.581e-06

as does nls with Gauss Newton:

 nls(weight ~ alpha + beta*exp(gamma*week), weightData, start =
+ c(alpha = 0.0, beta = 1, gamma = 0.2)
+ )
Nonlinear regression model
  model:  weight ~ alpha + beta * exp(gamma * week)
  data:  weightData
    alpha      beta      gamma
-3.949e+02  3.961e+02  1.136e-03
residual sum-of-squares: 9.17

Number of iterations to convergence: 48
Achieved convergence tolerance: 2.906e-06


 So I removed  'plinear' from the call and got the following:
  nls(weight ~ cbind(1, exp(gamma*week)), weightData,start =
 list(gamma=0.2),trace=TRUE)

It cannot be specified as if it were a plinear model but then use
Gauss-Newton.  See ?nls


-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



[[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] ggplot- using geom_point and geom_line at the same time

2012-01-16 Thread Felipe Carrillo
Mary:
Here's one way.
## change the variable name to whatever title you want on your legend
data = melt(data, id=inputs,variable_name=customName)
data
g - ggplot(data,aes(x=inputs, value, colour= customName, fill = customName,
shape=customName))
g - g + geom_line(lwd=0.8)
g - g + geom_point()
g - g + scale_x_continuous(name='Number of inputs')
g - g + scale_y_continuous('Conversion time (sec.)')

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx


From: Mary Kindall mary.kind...@gmail.com
To: r-help@r-project.org 
Sent: Monday, January 16, 2012 1:14 PM
Subject: [R] ggplot- using geom_point and geom_line at the same time

Hi
I am plotting line chart using ggplot and want to use geom_line and
geom_point simultaneously. I want to rename my legend but uptonow I remain
unsuccessful.
Someone please point what to add for renaming the legend.
I attached my example below.
Thanks



con = textConnection(inputs  var1  var2 var3
100 10 5 2
1000 20 10 4
5000 30 15 8
1 40 20 16
3 50 25 32)
data = read.table(con, header=TRUE)
data
data = melt(data, id=inputs)
g - ggplot(data,aes(x=inputs, value, colour= variable, fill = variable,
shape=variable))
g - g + geom_line(lwd=0.8)
g - g + geom_point()
g - g + scale_x_continuous(name='Number of inputs')
g - g + scale_y_continuous('Conversion time (sec.)')
g



-- 
-
Mary Kindall
Yorktown Heights, NY
USA

    [[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.



[[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] Group several variables and apply a function to the group

2011-12-04 Thread Felipe Carrillo
 Like this?
library(plyr)
ddply(df,.(comn,mi),summarise,stDEV=sd(x))

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx


From: Aurélien PHILIPPOT aurelien.philip...@gmail.com
To: R-help@r-project.org 
Sent: Sunday, December 4, 2011 12:32 PM
Subject: [R] Group several variables and apply a function to the group

Dear R-experts,
I am struggling with the following problem, and I am looking for advice
from more experienced R-users: I have a data frame with 2 identifying
variables (comn and mi), and an output variable (x). comn is a variable for
a company and mi is a variable for a month.

comn-c(abc, abc, abc, abc, abc, abc, xyz, xyz,xyz, xyz)
mi- c(1, 1,1, 2, 2, 2, 1, 1, 3, 3)
x- c(-0.0031, 0.0009, -0.007, 0.1929,0.0087, 0.099,-0.089,
0.005, -0.0078, 0.67 )
df- data.frame(comn=comn, mi=mi, x=x)


For each company, within a particular month, I would like to compute the
standard deviation of x: for example, for abc, I would like to compute the
sd of x for month1 (when mi=1) and for month2 (when mi=2).

In other languages (Stata for instance), I would create a grouping variable
(group comnn and mi) and then, apply the sd function for each group.

However, I don't find an elegant way to do the same in R:

I was thinking about the following: I could subset my data frame by mi and
create one file per month, and then make a loop and in each file, use a
by operator for each comn. I am sure it would work, but I feel that it
would be like killing an ant with a tank.

I was wondering if anyone knew a more straightforward way to implement that
kind of operation?

Thanks a lot,

Best,
Aurelien

    [[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.



[[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] factor level issue after subsetting

2011-11-01 Thread Felipe Carrillo
Stefan:
Use the droplevels function...
dat - read.table(textConnection(
  treat yield
1  cont  98.7
2  cont  97.2
3  cont  96.1
4  cont  98.1
5    10 103.0
6    10 101.3
7    10 102.1
8    10 101.9
9    30 121.1
10    30 123.1
11    30 119.7
12    30 118.9
13    60 109.9
14    60 110.1
15    60 113.1
16    60 112.3),header=T)
dat
 plot(dat$treat,dat$yield)
 dat.sub - subset(dat,treat!=cont);dat.sub
 dat.sub - droplevels(dat.sub)    # drop unwanted levels
plot(dat.sub$treat,dat.sub$yield)

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx


From: Schreiber, Stefan stefan.schrei...@ales.ualberta.ca
To: r-help@r-project.org
Sent: Tuesday, November 1, 2011 2:28 PM
Subject: [R] factor level issue after subsetting

Dear list,

I cannot figure out why, after sub-setting my data, that particular item
which I don't want to plot is still in the newly created subset (please
see example below). R somehow remembers what was in the original data
set. A work around is exporting and importing the new subset. Then it's
all fine; but I don't like this idea and was wondering what am I missing
here?

Thanks!
Stefan

P.S. I am using R 2.13.2 for Mac.

 dat-read.csv(~/MyFiles/data.csv)
 class(dat$treat)
[1] factor
 dat
  treat yield
1  cont  98.7
2  cont  97.2
3  cont  96.1
4  cont  98.1
5    10 103.0
6    10 101.3
7    10 102.1
8    10 101.9
9    30 121.1
10    30 123.1
11    30 119.7
12    30 118.9
13    60 109.9
14    60 110.1
15    60 113.1
16    60 112.3
 plot(dat$treat,dat$yield)
 dat.sub-dat[which(dat$treat!='cont')]
 class(dat.sub$treat)
[1] factor
 dat.sub
  treat yield
5    10 103.0
6    10 101.3
7    10 102.1
8    10 101.9
9    30 121.1
10    30 123.1
11    30 119.7
12    30 118.9
13    60 109.9
14    60 110.1
15    60 113.1
16    60 112.3
 plot(dat.sub$treat,dat.sub$yield)

    [[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.



[[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] ggplot geom_boxplot vertical margins

2011-05-18 Thread Felipe Carrillo
Is this what you want? You can control how much space you
want to see on the sides of the plot:

df-data.frame(x=factor(1:100),y=rnorm(1000))
ggplot(df,aes(x=x,y=y))+geom_boxplot() + scale_x_discrete(expand=c(0,0))


 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx




- Original Message 
 From: Justin Haynes jto...@gmail.com
 To: r-help@r-project.org
 Sent: Wed, May 18, 2011 1:51:19 PM
 Subject: [R] ggplot geom_boxplot vertical margins
 
 If you plot:
 
 df-data.frame(x=factor(1:100),y=rnorm(1000))
 ggplot(df,aes(x=x,y=y))+geom_boxplot()
 
 How do I remove those pesky margins on the sides of the plot area?  Or
 maybe just reduce their size to something more like the spacing of the
 boxes?
 
 
 Thanks,
 
 Justin
 
 __
 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-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] Summarize by two or more attributes

2011-05-17 Thread Felipe Carrillo
Like This?

x-rep(c(1,15),10)
y-rnorm(20)
z-c(rep(auto,10),rep(bus,10))
a-rep(c(1,1,2,2,3,3,4,4,5,5),2)
#Create Data frame
Df-data.frame(Source=x,Rate=y,Bin=a,Type=z)
Df

ddply(Df,c('Type','Bin'),summarise,Summed=sum(Rate))

 # Adding a column to Df
ddply(Df,c('Type','Bin'),mutate,Summed=sum(Rate))
  
# Convert the result to a list
dlply(Df,c('Type','Bin'),summarise,Summed=sum(Rate))


 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx




- Original Message 
 From: LCOG1 jr...@lcog.org
 To: r-help@r-project.org
 Sent: Tue, May 17, 2011 9:48:36 AM
 Subject: [R] Summarize by two or more attributes
 
 Okay everyone heres a likely softball for someone.
 
 Consider the following data frame:
 
 #Create data
 x-rep(c(1,15),10)
 y-rnorm(20)
 z-c(rep(auto,10),rep(bus,10))
 a-rep(c(1,1,2,2,3,3,4,4,5,5),2)
 #Create Data frame
 Df-data.frame(Source=x,Rate=y,Bin=a,Type=z)
 
 
 I want to create a new column the equals the sum of the Rates for each type
 (1,15) by Bin.  
 
 A related question:  I have been using R for a while now and usually
 manipulate my data in data frames but i know lists are better for R so
 perhaps the above should be done using lists.  Feel free to offer
 suggestions coming from that angle.  
 
 Thanks guys
 
 JR-
 
 
 
 --
 View this message in context: 
http://r.789695.n4.nabble.com/Summarize-by-two-or-more-attributes-tp3529825p3529825.html

 Sent from the R help mailing list archive at Nabble.com.
 
 __
 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-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] another question on shapefiles and geom_point in ggplot2

2011-04-03 Thread Felipe Carrillo
Manuel:
I changed your variable names from x to 'long' and y to 'lat' on the 
riqueza_out.csv file.
The code below should do what you want. Also, since the legend title is kind of 
long, I broke it
down into three lines so you can see more plot area. I am cc'ing the other 
groups so more people
use it if needed.

library(rgdal)
library(ggplot2)
library(sp)
library(maptools)
gpclibPermit()
manuel - readOGR(dsn=., layer=AI_BIOTICA_010411_CRTM05)
names(manuel);dim(manuel)
  slotNames(manuel) # look at the slot names
# add the 'id' variable to the shapefile and use it to merge both files
  manuel@data$id = rownames(manuel@data)
# convert shapefile to dataframe
  manuel.df - as.data.frame(manuel)
# fortify to plot with ggplot2
  manuel_fort - fortify(manuel,region=id)
  head(manuel_fort)
# Merge shapefile and the as.dataframe shapefile
  manuel_merged - join(manuel_fort,manuel.df, by =id)
  head(manuel_merged)
# Read in the csv file
manuel_points - read.csv(riqueza_out.csv)
  head(manuel_points);dim(manuel_points)
# fortify this one too for the points or else an error will ocurr
 manuel_points - fortify(manuel_points)
 manuel_points
 
# Plot the shapefile and overlayed the points over it
p - ggplot(manuel_merged, aes(long,lat,group=group)) +
  geom_polygon(aes(data=manuel_merged,fill=Area_Influ)) +
  geom_path(color=white) + theme_bw() # remove this if you don't want black 
and white background
  p + geom_point(data=manuel_points,aes(size=ACE,colour=ACE,group=NULL)) +
  scale_size(name = Número\nde\nespecies, breaks = c(2, 4, 6, 8, 10, 12, 14, 
16, 18, 20)) +
 scale_colour_gradientn(name = 'Número\nde\nespecies',
 colours = rainbow(6), breaks = c(2, 4, 6, 8, 10, 12, 14, 16, 18, 20))+ 
 xlab(Longitud) + ylab(Latitud) + opts(axis.text.x = theme_text(size = 8, 
vjust = 1)) + 

 opts(axis.text.y = theme_text(size = 8, hjust = 1)) 
  
  
 Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx




From: Manuel Spínola mspinol...@gmail.com
To: Felipe Carrillo mazatlanmex...@yahoo.com
Sent: Sat, April 2, 2011 11:22:24 PM
Subject: Re: another question on shapefiles and geom_point in ggplot2

No problem, thank you very much Felipe.

Best,

Manuel

On 03/04/2011 12:19 a.m., Felipe Carrillo wrote: 
I meant to send you this one..Let me clean up the code a little bit and 
I will send it to you,,,do you mind if I send it to you in the morning?
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx





From: Manuel Spínola mspinol...@gmail.com
To: Felipe Carrillo mazatlanmex...@yahoo.com
Sent: Sat, April 2, 2011 11:15:28 PM
Subject: Re: another question on shapefiles and geom_point in ggplot2

Yes Felipe.  That is the graph I was looking for.

I got something closer but no like yours.  How did you do it?

Manuel

On 03/04/2011 12:10 a.m., Felipe Carrillo wrote: 
I was able to open them,,I am attaching a picture of the graph I 
created..It's 
that what
you had in mind?
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx





From: Manuel Spínola mspinol...@gmail.com
To: Felipe Carrillo mazatlanmex...@yahoo.com
Sent: Sat, April 2, 2011 10:35:51 PM
Subject: Re: another question on shapefiles and geom_point in ggplot2

It should be.  I am sending them again.

Manuel

On 02/04/2011 10:23 p.m., Felipe Carrillo wrote: 
Manuel:
I can't open the shapefile, is this the original one?
Is the csv file the one that you are trying to overlay on top of the 
shapefile?
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx





From: Manuel Spínola mspinol...@gmail.com
To: Felipe Carrillo mazatlanmex...@yahoo.com
Sent: Sat, April 2, 2011 6:14:09 PM
Subject: Re: another question on shapefiles and geom_point in ggplot2

Files attached.


On 02/04/2011 07:04 p.m., Felipe Carrillo wrote: 
If you want individual points overlayed on the shapefile, you need to 
add 
another variable to it before you fortify it.
After you fortify merge both the fortified dataset and the original 
shapefile. 
Go ahead and post your shapefile to see if
I can figure it out. Do you just want the points or want text also?
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx





From: Manuel Spínola mspinol...@gmail.com
To: Felipe Carrillo mazatlanmex...@yahoo.com
Sent: Sat, April 2, 2011 5:24:02 PM
Subject: Re: another question on shapefiles and geom_point in ggplot2

Hi Felipe,

I did the same thing that I am trying know, attached is how it looks.

Best,

Manuel

On 02/04/2011 06:09 p.m., Felipe Carrillo wrote: 
Manuel:
I did something

Re: [R] another question on shapefiles and geom_point in ggplot2

2011-04-03 Thread Felipe Carrillo
Manuel:
As far as I know one needs gpclibPermit() in order to fortify
see this:
Note: polygon geometry computations in maptools
    depend on the package gpclib, which has a
    restricted licence. It is disabled by default;
    to enable gpclib, type gpclibPermit() 
I am going to guess that ahmadou dicko doesn't show gpclibPermit() on his code
because he loaded it with Rprofile or some other way. I tried to run his code 
without
gpclibPermit() and it wouldn't let me fortify, so not sure how he did it.

On the same note, your code didn't work when you were trying to join ai_biotica 
and ai_biotica@data
because you are trying to join polygons and points (just a guess). Try to use 
fortify instead of fortify.SpatialPolygonsDataFrame. I tested with a different 
shapefile and it works for me. 

manuel@data$id = rownames(manuel@data)
   manuel_fort - fortify(manuel,region=id)
  manuel_merged - join(manuel_fort,manuel@data, by =id)

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx




From: Manuel Spínola mspinol...@gmail.com
To: Felipe Carrillo mazatlanmex...@yahoo.com
Cc: r-h...@stat.math.ethz.ch; ggpl...@googlegroups.com
Sent: Sun, April 3, 2011 1:51:02 PM
Subject: Re: another question on shapefiles and geom_point in ggplot2

Thank you very much Felipe,

Did you see the solution from ahmadou dicko?
He doesn´t use gpclibPermit()

I have another option but I cannot get the right fill for the id.

See attached map.

ai_biotica = readOGR(dsn=C:/ProyectosRespacial/ICE/SIG_Biotica_PHED, 
layer=AI_BIOTICA_010411_CRTM05)
str(ai_biotica)

# fortify to get the data

fortify.ai_biotica - 
fortify.SpatialPolygonsDataFrame(ai_biotica,region='Area_Influ')
names(fortify.ai_biotica)
str(fortify.ai_biotica)
levels(fortify.ai_biotica$group)

# mapa

ggplot(fortify.ai_biotica, aes(x = long, y=lat, group =  group)) + 
geom_polygon(colour = black, fill = NA) 


geo = read.csv(riqueza_out.csv, sep = ,, header = T)
names(geo)
str(geo)
summary(geo)

# mapa con riqueza

p = ggplot(geo, aes(x, y))
p + geom_point(aes(size = ACE, colour = ACE)) + theme_bw() + scale_size(name = 
Número de especies, breaks = c(2, 4, 6, 8, 10, 12, 14, 16, 18, 20)) + 
scale_colour_gradientn(name = 'Número de especies', colours = heat.colors(10), 
breaks = c(2, 4, 6, 8, 10, 12, 14, 16, 18, 20))+ xlab(Longitud) + 
ylab(Latitud) + opts(axis.text.x = theme_text(size = 8, vjust = 1)) + 
opts(axis.text.y = theme_text(size = 8, hjust = 1)) + 
geom_path(aes(x=long,y=lat,group=group, fill=id),data=fortify.ai_biotica)

Best,

Manuel

On 03/04/2011 01:41 p.m., Felipe Carrillo wrote: 
Manuel:
I changed your variable names from x to 'long' and y to 'lat' on the 
riqueza_out.csv file.
The code below should do what you want. Also, since the legend title is kind 
of 
long, I broke it
down into three lines so you can see more plot area. I am cc'ing the other 
groups so more people
use it if needed.

library(rgdal)
library(ggplot2)
library(sp)
library(maptools)
gpclibPermit()
manuel - readOGR(dsn=., layer=AI_BIOTICA_010411_CRTM05)
names(manuel);dim(manuel)
  slotNames(manuel) # look at the slot names
# add the 'id' variable to the shapefile and use it to merge both files
  manuel@data$id = rownames(manuel@data)
# convert shapefile to dataframe
  manuel.df - as.data.frame(manuel)
# fortify to plot with ggplot2
  manuel_fort - fortify(manuel,region=id)
  head(manuel_fort)
# Merge shapefile and the as.dataframe shapefile
  manuel_merged - join(manuel_fort,manuel.df, by =id)
  head(manuel_merged)
# Read in the csv file
manuel_points - read.csv(riqueza_out.csv)
  head(manuel_points);dim(manuel_points)
# fortify this one too for the points or else an error will ocurr
 manuel_points - fortify(manuel_points)
 manuel_points
 
# Plot the shapefile and overlayed the points over it
p - ggplot(manuel_merged, aes(long,lat,group=group)) +
  geom_polygon(aes(data=manuel_merged,fill=Area_Influ)) +
  geom_path(color=white) + theme_bw() # remove this if you don't want black 
and white background
  p + geom_point(data=manuel_points,aes(size=ACE,colour=ACE,group=NULL)) +
  scale_size(name = Número\nde\nespecies, breaks = c(2, 4, 6, 8, 10, 12, 
14, 
16, 18, 20)) +
 scale_colour_gradientn(name = 'Número\nde\nespecies',
 colours = rainbow(6), breaks = c(2, 4, 6, 8, 10, 12, 14, 16, 18, 20))+ 
 xlab(Longitud) + ylab(Latitud) + opts(axis.text.x = theme_text(size = 8, 
vjust = 1)) + 

 opts(axis.text.y = theme_text(size = 8, hjust = 1)) 
  
  
 Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx





From: Manuel Spínola mspinol...@gmail.com
To: Felipe Carrillo mazatlanmex...@yahoo.com
Sent: Sat, April 2, 2011 11:22:24 PM
Subject: Re: another question on shapefiles and geom_point in ggplot2

No problem, thank you very much Felipe.

Best,

Manuel

On 03/04/2011 12:19 a.m

Re: [R] Rexcel path problem

2011-04-01 Thread Felipe Carrillo
Jorge:
You can run save your scripts in the same folder where your wokbook is and run 
it like this:

Sub Scatter()
Call rinterface.StartRServer
'Put the dataframe into R
Call rinterface.PutDataframe(scatter, DownRightFrom(Range(RData!A1)), 
WithRowNames:=False)
Call rinterface.RRun(attach(scatter))
'Run the RScatter script
rinterface.RunRFile ThisWorkbook.Path  \RScatter.r
Call rinterface.StopRServer
End Sub

I

 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx




- Original Message 
 From: Jorge Nieves jorge.nie...@moorecap.com
 To: r-h...@stat.math.ethz.ch
 Sent: Fri, April 1, 2011 7:12:39 AM
 Subject: [R] Rexcel path problem
 
 
 Hi,
 
 I am running a test to call an R script with in excel using VBA. My VBA
 code is shown bellow. The middle section of this mail also includes the
 content of my Rscript.  The bottom part shows the error message form the
 R console.
 
 It seems that Excel is  opening the R console without any problems. 
 
 The problem I am seeing is that Rinterface.RRun  instruction is
 interpreting the \T part of the path as an R command. It does not
 recognize the X:\Trading\Energy\JorgeSpace\TMPholder\cpixe\home
 models\ as a one single string, or path.
 
 
 Any ideas how can I fix the problem?
 
 Thanks ,'
 
 Jorge
 
 
 VB code
 Sub tester()
 
     Rinterface.StartRServer
 
     Rinterface.RRun
 (source('X:\Trading\Energy\JorgeSpace\TMPholder\cpixe\home
 models\toto.R'))    
 
     Rinterface.StopRServer
     
 End Sub
 
 
 
 R cript code toto.R
 path = getwd()
 setwd(path)
 a = 5
 b=5
 x = matrix(rnorm(a*b),a,b)
 a = 5
 b=5
 
 y = matrix(rnorm(a*b),a,b)
 z = x %*% y
 savefile = paste(path,/,testresults.csv,sep=)
 write.csv(z, file = savefile)
 
 
 
 
 
 Rconsole message
 
 Type 'demo()' for some demos, 'help()' for on-line help, or
 'help.start()' for an HTML browser interface to help.
 Type 'q()' to quit R.
 
 Loading required package: rcom
 Loading required package: rscproxy
 Error: '\T' is an unrecognized escape in character string starting
 source('X:\T
   
 
 Jorge Nieves
 
 
 
     [[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-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] Tinn-R looses connection to R (Windows Vista)

2011-03-26 Thread Felipe Carrillo
Nutter, Benjamin NutterB at ccf.org writes:

 
 I've noticed it, but I haven't looked into it much since I rarely work
 on Vista.  I have found that opening R before I open Tinn-R tends to
 work better than using Tinn-R to open the preferred GUI.
 
 Benjamin 
 
 -Original Message-
 From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
project.org]
 On Behalf Of Agi Richard
 Sent: Wednesday, November 17, 2010 4:43 AM
 To: R-help at r-project.org
 Subject: [R] Tinn-R looses connection to R (Windows Vista)
 
 Hi everyone,
 I wonder, if anyone can help me with this annoying issue, although it is
 related to Tinn-R and Windows Vista...
 I am running R 2.11.1 and Tinn-R 2.3.5.2 together. I saved 2 R-hotkeys:
 ALT+A for sending the whole content of one file and ALT+S for a 
 ALT+selection
 from one file from Tinn-R to R. Everything works fine with other windows
 versions, also with Vista at the beginning of every session, but after a
 certain time (not always the same, neither the number of times, that I
 used the hotkeys is the same, so it occurs randomly, but quite fast,
 lets say on average within half an hour - 2hs) ALT+S does not work
 anymore, but instead this hotkey opens the start menue of Vista!! (The
 same function the windows key has!) I would be very happy, if anyone has
 an idea why this could be!! Is it related to R, to Tinn-R or to Vista?
 Thank you very very much in advance!
 Carol
 
 Hi:
Did you fix the problem? I just recently started experiencing the same thing 
with my laptop(windows vista). I don't have that problem with my desktop which 
it still has windows XP.
Thanks

__
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] Changes titles in ggplot2 plot

2011-02-12 Thread Felipe Carrillo
you can just probably add 
+ labs(x=Time Elapsed,y=Predicted Probability)
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx




- Original Message 
 From: Shige Song shiges...@gmail.com
 To: r-help Help r-help@r-project.org
 Sent: Sat, February 12, 2011 7:07:39 PM
 Subject: [R] Changes titles in ggplot2 plot
 
 Dear Colleagues,
 
 In the following simple ggplot2 code:
 
 m - ggplot(d.fig, aes(time, prob))
 m + stat_summary(fun.data = median_hilow, conf.int = .95, geom =
 smooth) + facet_wrap(~ Cohort, nrow=1) + coord_cartesian(ylim = c(0,
 .03))
 
 Is there a way to replace the y-axis label from prob to Predicted
 Probability and replace the x-axis label from time to Time
 Elapsed?
 
 Many thanks.
 
 Best,
 Shige
 
 __
 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.
 


 

Now that's room service!  Choose from over 150,000 hotels
in 4[[elided Yahoo spam]]
hoo.com/promo-generic-14795097

__
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] ggplot - controlling point size

2011-01-25 Thread Felipe Carrillo
try this:
qplot(x, y, data=df, colour=factor(type), size=I(1)) + geom_smooth()
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx




- Original Message 
 From: Gene Leynes gleyne...@gmail.com
 To: r-help@r-project.org
 Sent: Tue, January 25, 2011 9:28:20 AM
 Subject: [R] ggplot - controlling point size
 
 Can anyone illuminate the following for me?
 How can I get rid of the blue line in the key in the second plot?
 
 ## Create a simple data frame
 df=data.frame(x=1:1000, y=2*1:1000+rnorm(1000,sd=1000),
         type=sample(letters[1:2],1000, replace=TRUE))
 
 ## Very nice!  Almost what I want
 qplot(x, y, data=df, colour=factor(type)) + geom_smooth()
 
 ## Make a nicer plot, with smaller points
 ## but why does that add the little blue line with a 1?
 qplot(x, y, data=df, colour=factor(type), size=1) + geom_smooth()
 
     [[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-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] Sum by column

2011-01-12 Thread Felipe Carrillo
Or with ddply :
library(plyr)
dat - structure(list(ED = c(21.809467, 36.229566, 51.861284, 11.36232,
27.264634, 12.261986, 46.519313, 7.815376, 2.810428, 13.478372,
35.670182, 27.128715, 19.010294, 15.475368, 18.597983, 29.292615,
6.749846, 14.981488, 14.93511, 14.93511, 21.040785, 8.271615,
12.94232, 6.749846, 15.484412, 29.644494, 43.211212), ECOCODE = structure(c(1L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 3L, 4L, 4L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c(AA0101,
AT0101, AT0801, AT1201, PA1201, PA1301), class = factor)),
.Names = c(ED,
ECOCODE), class = data.frame, row.names = c(NA, -27L))
dat
ddply(dat,ECOCODE,summarise,EDsummed=sum(ED))
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx




- Original Message 
 From: Peter Francis peterfran...@me.com
 To: r-help@r-project.org
 Sent: Wed, January 12, 2011 2:38:19 AM
 Subject: [R] Sum by column
 
 Dear List,
 
 I have a question of convenience,
 
 I am looking to sum the values of one column based on another column - a 
example may help explain better!
 
 ED            ECOCODE
 21.809467    AA0101
 36.229566    PA1201
 51.861284    PA1201
 11.36232    PA1201
 27.264634    PA1201
 12.261986    PA1201
 46.519313    PA1201
 7.815376    PA1201
 2.810428    PA1201
 13.478372    PA1201
 35.670182    PA1301
 27.128715    AT0801
 19.010294    AT1201
 15.475368    AT1201
 18.597983    AT0101
 29.292615    AT0101
 6.749846    AT0101
 14.981488    AT0101
 14.93511    AT0101
 14.93511    AT0101
 21.040785    AT0101
 8.271615    AT0101
 12.94232    AT0101
 6.749846    AT0101
 15.484412    AT0101
 29.644494    AT0101
 43.211212    AT0101
 
 So for AA0101 it would be = 21.809467
         AT1201 it would be = 19.010294+15.475368
 
 etc
 
 I would then like to be able to output a table with ECOCODE in one column and 
the sum of ED in the other.
 
 This is stored in a dataframe called ecoregion, i understand people like 
 having 
code to change but i have none as i am a relative beginner! Sorry in advance!
 
 Thanks 
 
 Peter
 
 __
 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-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] RODBC sqlSave question

2010-12-09 Thread Felipe Carrillo
Hi:
I am getting the following error message when using the sqlSave function:
Error in sqlSave(myDB,myset)
table myset already exists

I want this table to be populated with new data everytime I execute sqlSave.
The documentation says that:
If the table exists and has the appropriate structure it is used, or else it 
is 
created anew


Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx

__
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 display a dataset on a dialog window

2010-12-08 Thread Felipe Carrillo
HI:
Is there a way to display a dataset on a dialog window? I am creating an 
application
with Visual Basic and R, and I want the user to be able to see the dataset used 
print out
on a dialog window. Not sure if there is a better way to do this, but basically 
when the user
click a button on a VB form, will need to know if the dataset actually made it 
to R and therefore
perform some calculations. Thanks in advance




__
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] drop levels problem

2010-11-29 Thread Felipe Carrillo
Hi all:
I am having trouble dropping levels, got a few hints online without success.
Please consider the dataset below:
 I was under the inpression that subset(..drop=TRUE) would work but it 
doesn't

library(ggplot2)
    library(hmisc)

x - structure(list(first = c(38.2086, 43.1768, 43.146, 41.8044, 42.4232, 
46.3646, 38.0813, 40.0745, 40.4889, 38.6246, 40.2826, 41.6056, 
34.5353, 40.0768), second = c(43.3295, 42.4326, 38.8994, 37.0894, 
42.3218, 46.1726, 39.1206, 41.2072, 42.4874, 40.2657, 38.7766, 
40.8822, 42.0165, 49.2055), third = c(42.24, 42.992, 37.7419, 
42.3448, 41.9131, 44.385, 42.7811, 44.1963, 40.8088, 43.9634, 
38.7079, 38.0791, 44.3136, 39.5333)), .Names = c(first, second, 
third), class = data.frame, row.names = c(NA, -14L))

 head(x);str(x)
xmelt - melt(x)
 names(xmelt) - c(year,fatPerc)

  # Year variable is a factor with three levels
 # Subset to plot only 'first' year
firstyear - subset(xmelt,year=='first');str(firstyear)
# Plot showing three levels still after I made the subset
  ggplot(firstyear,aes(year,fatPerc)) + geom_boxplot() + geom_jitter()

# Try to drop the levels but dropUnusedLevels() doesn't seem to work here
  dropUnusedLevels()
ggplot(firstyear,aes(year,fatPerc)) + geom_boxplot() + geom_jitter()

# code below also should drop levels but it doesn't
#data.frame(lapply(firstyear, function(x) if (is.factor(x)){ factor(x)} 
else{x}))
str(firstyear)
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA




__
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] Filling in missing time samples with na.approx

2010-11-29 Thread Felipe Carrillo
strange,,I don't see any change either, could it be that we have an older 
version of zoo?
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: Gabor Grothendieck ggrothendi...@gmail.com
 To: Jason Edgecombe ja...@rampaginggeek.com
 Cc: r-h...@stat.math.ethz.ch
 Sent: Mon, November 29, 2010 10:51:07 AM
 Subject: Re: [R] Filling in missing time samples with na.approx
 
 On Mon, Nov 29, 2010 at 1:33 PM, Jason Edgecombe
 ja...@rampaginggeek.com wrote:
  On 11/29/2010 10:00 AM, Gabor Grothendieck wrote:
 
  On Mon, Nov 29, 2010 at 9:45 AM, Jason Edgecombe
  ja...@rampaginggeek.com  wrote:
 
 
  Hi Everyone,
 
  I have a some data from a sports gps device like the following:
 
         time latitude longitude altitude  distance heartrate
  1 1277648884 0.304048 -0.793819      260  0.00        94
  2 1277648885 0.304056 -0.793772      262  4.307615        95
  3 127764 0.304060 -0.793696      263 11.262347        97
  4 1277648894 0.304075 -0.793544      263 25.237911       103
  5 1277648898 0.304085 -0.793455      263 33.322525       108
  6 1277648902 0.304064 -0.793387      256 40.042988       115
 
  As you can see, the samples have irregular holes in the time column. How
  can
  I fill in the missing samples using na.approx?
 
  I've tried to creating a blank series with no gaps and combine them, but
  merge just adds columns and rbind compains about duplicate indexes.
 
  P.S. My GPS still has holes in the data when I turn off smart recording
  :(
 
 
 
  Try this:
 
  Lines- time latitude longitude altitude  distance heartrate
  1277648884 0.304048 -0.793819      260  0.00        94
  1277648885 0.304056 -0.793772      262  4.307615        95
  127764 0.304060 -0.793696      263 11.262347        97
  1277648894 0.304075 -0.793544      263 25.237911       103
  1277648898 0.304085 -0.793455      263 33.322525       108
  1277648902 0.304064 -0.793387      256 40.042988       115
 
  # read in data
  library(zoo)
  z- read.zoo(textConnection(Lines), header = TRUE)
 
  na.approx(z, xout = seq(min(time(z)), max(time(z
 
 
 
 
 
  No change:
  na.approx(z, xout = seq(min(time(z)), max(time(z
            latitude longitude altitude  distance heartrate
  1277648884 0.304048 -0.793819      260  0.00        94
  1277648885 0.304056 -0.793772      262  4.307615        95
  127764 0.304060 -0.793696      263 11.262347        97
  1277648894 0.304075 -0.793544      263 25.237911       103
  1277648898 0.304085 -0.793455      263 33.322525       108
  1277648902 0.304064 -0.793387      256 40.042988       115
 
 
 It works for me.
 
  Lines - time latitude longitude altitude  distance heartrate
 + 1277648884 0.304048 -0.793819      260  0.00        94
 + 1277648885 0.304056 -0.793772      262  4.307615        95
 + 127764 0.304060 -0.793696      263 11.262347        97
 + 1277648894 0.304075 -0.793544      263 25.237911      103
 + 1277648898 0.304085 -0.793455      263 33.322525      108
 + 1277648902 0.304064 -0.793387      256 40.042988      115
 
  # read in data
  library(zoo)
  z - read.zoo(textConnection(Lines), header = TRUE)
 
  na.approx(z, xout = seq(min(time(z)), max(time(z
             latitude  longitude altitude  distance heartrate
 1277648884 0.3040480 -0.7938190 260.  0.00  94.0
 1277648885 0.3040560 -0.7937720 262.  4.307615  95.0
 1277648886 0.3040573 -0.7937467 262.  6.625859  95.7
 1277648887 0.3040587 -0.7937213 262.6667  8.944103  96.3
 127764 0.3040600 -0.7936960 263. 11.262347  97.0
 1277648889 0.3040625 -0.7936707 263. 13.591608  98.0
 1277648890 0.3040650 -0.7936453 263. 15.920868  99.0
 1277648891 0.3040675 -0.7936200 263. 18.250129 100.0
 1277648892 0.3040700 -0.7935947 263. 20.579390 101.0
 1277648893 0.3040725 -0.7935693 263. 22.908650 102.0
 1277648894 0.3040750 -0.7935440 263. 25.237911 103.0
 1277648895 0.3040775 -0.7935218 263. 27.259065 104.25000
 1277648896 0.3040800 -0.7934995 263. 29.280218 105.5
 1277648897 0.3040825 -0.7934773 263. 31.301371 106.75000
 1277648898 0.3040850 -0.7934550 263. 33.322525 108.0
 1277648899 0.3040797 -0.7934380 261.2500 35.002641 109.75000
 1277648900 0.3040745 -0.7934210 259.5000 36.682756 111.5
 1277648901 0.3040693 -0.7934040 257.7500 38.362872 113.25000
 1277648902 0.3040640 -0.7933870 256. 40.042988 115.0
 
 
 
 -- 
 Statistics  Software Consulting
 GKX Group, GKX Associates Inc.
 tel: 1-877-GKX-GROUP
 email: ggrothendieck at gmail.com
 
 __
 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] drop levels problem

2010-11-29 Thread Felipe Carrillo
Thanks Joshua, I get it now, levels sometimes drive me loco
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: Joshua Wiley jwiley.ps...@gmail.com
 To: Felipe Carrillo mazatlanmex...@yahoo.com
 Cc: r-h...@stat.math.ethz.ch
 Sent: Mon, November 29, 2010 11:18:45 AM
 Subject: Re: [R] drop levels problem
 
 Hi Felipe,
 
 On Mon, Nov 29, 2010 at 11:01 AM, Felipe Carrillo
 mazatlanmex...@yahoo.com wrote:
  Hi all:
  I am having trouble dropping levels, got a few hints online without success.
  Please consider the dataset below:
   I was under the inpression that subset(..drop=TRUE) would work but it
  doesn't
 
 Here drop is referring to:
 
 data.frame(1:10)[, 1]
 data.frame(1:10)[, 1, drop = FALSE]
 
 not to levels of a factor.
 
 
  library(ggplot2)
      library(hmisc)
 
  x - structure(list(first = c(38.2086, 43.1768, 43.146, 41.8044, 42.4232,
  46.3646, 38.0813, 40.0745, 40.4889, 38.6246, 40.2826, 41.6056,
  34.5353, 40.0768), second = c(43.3295, 42.4326, 38.8994, 37.0894,
  42.3218, 46.1726, 39.1206, 41.2072, 42.4874, 40.2657, 38.7766,
  40.8822, 42.0165, 49.2055), third = c(42.24, 42.992, 37.7419,
  42.3448, 41.9131, 44.385, 42.7811, 44.1963, 40.8088, 43.9634,
  38.7079, 38.0791, 44.3136, 39.5333)), .Names = c(first, second,
  third), class = data.frame, row.names = c(NA, -14L))
 
 Thanks for the nice example!
 
 
   head(x);str(x)
  xmelt - melt(x)
   names(xmelt) - c(year,fatPerc)
 
    # Year variable is a factor with three levels
   # Subset to plot only 'first' year
  firstyear - subset(xmelt,year=='first');str(firstyear)
  # Plot showing three levels still after I made the subset
    ggplot(firstyear,aes(year,fatPerc)) + geom_boxplot() + geom_jitter()
 
 right, because it is possible to have levels of a factor that have no
 observations---sometimes these are the most interesting (e.g., if you
 subset by smoking and found that there were no instances of lung
 cancer in non-smokers (not that extreme, but you get the point)).
 
 
  # Try to drop the levels but dropUnusedLevels() doesn't seem to work here
    dropUnusedLevels()
 
 sorry, I have had some difficulty installing Hmisc on my linux system
 and never gotten around to working it out.
 
  ggplot(firstyear,aes(year,fatPerc)) + geom_boxplot() + geom_jitter()
 
  # code below also should drop levels but it doesn't
  #data.frame(lapply(firstyear, function(x) if (is.factor(x)){ factor(x)}
  else{x}))
 
 it would if you assigned it back to firstyear.  You do it, and then
 just print to screen and the changed data goes off to oblivion.
 
 firstyear - data.frame(lapply(firstyear, function(x) if(is.factor(x))
 {factor(x)} else {x}))
 str(firstyear) # should now just have one level
 
 Cheers,
 
 Josh
 
  str(firstyear)
 
  Felipe D. Carrillo
  Supervisory Fishery Biologist
  Department of the Interior
  US Fish  Wildlife Service
  California, USA
 
 
 
 
  __
  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.
 
 
 -- 
 Joshua Wiley
 Ph.D. Student, Health Psychology
 University of California, Los Angeles
 http://www.joshuawiley.com/
 




__
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] subset

2010-11-29 Thread Felipe Carrillo
 Hi:
I always use subset the same way but now is returning 0 rows. 
What's wrong with the way I am subsetting?

library(ggplot2)
structure(list(first = c(38.2086, 43.1768, 43.146, 41.8044, 42.4232, 
46.3646, 38.0813, 40.0745, 40.4889, 38.6246, 40.2826, 41.6056, 
34.5353, 40.0768), second = c(43.3295, 42.4326, 38.8994, 37.0894, 
42.3218, 46.1726, 39.1206, 41.2072, 42.4874, 40.2657, 38.7766, 
40.8822, 42.0165, 49.2055), third = c(42.24, 42.992, 37.7419, 
42.3448, 41.9131, 44.385, 42.7811, 44.1963, 40.8088, 43.9634, 
38.7079, 38.0791, 44.3136, 39.5333)), .Names = c(first, second, 
third), class = data.frame, row.names = c(NA, -14L))
 head(x);str(x)
xmelt - melt(x)
 names(xmelt) - c(year,fatPerc)
  str(xmelt);xmelt
 # Subset to plot only the 'first' and third year
firstyear - subset(xmelt,year ==' first');str(firstyear) # works
# two variables,,doesn't work
firstyear - subset(xmelt,year ==' first'  year == 'third');str(firstyear)
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA




__
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] subset

2010-11-29 Thread Felipe Carrillo
My mistake, I don't subset like that, I totally got turnaround. | should do 
it, Thanks again Jorge and Joshua
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: Joshua Wiley jwiley.ps...@gmail.com
 To: Felipe Carrillo mazatlanmex...@yahoo.com
 Cc: r-h...@stat.math.ethz.ch
 Sent: Mon, November 29, 2010 1:11:23 PM
 Subject: Re: [R] subset
 
 Hi Felipe,
 
 On Mon, Nov 29, 2010 at 1:02 PM, Felipe Carrillo
 mazatlanmex...@yahoo.com wrote:
   Hi:
  I always use subset the same way but now is returning 0 rows.
  What's wrong with the way I am subsetting?
 
  library(ggplot2)
  structure(list(first = c(38.2086, 43.1768, 43.146, 41.8044, 42.4232,
  46.3646, 38.0813, 40.0745, 40.4889, 38.6246, 40.2826, 41.6056,
  34.5353, 40.0768), second = c(43.3295, 42.4326, 38.8994, 37.0894,
  42.3218, 46.1726, 39.1206, 41.2072, 42.4874, 40.2657, 38.7766,
  40.8822, 42.0165, 49.2055), third = c(42.24, 42.992, 37.7419,
  42.3448, 41.9131, 44.385, 42.7811, 44.1963, 40.8088, 43.9634,
  38.7079, 38.0791, 44.3136, 39.5333)), .Names = c(first, second,
  third), class = data.frame, row.names = c(NA, -14L))
   head(x);str(x)
  xmelt - melt(x)
   names(xmelt) - c(year,fatPerc)
    str(xmelt);xmelt
   # Subset to plot only the 'first' and third year
  firstyear - subset(xmelt,year ==' first');str(firstyear) # works
 
 Really?  It does not for me.  I think you need to remove the space:  '
 first' to 'first'
 
  # two variables,,doesn't work
  firstyear - subset(xmelt,year ==' first'  year == 'third');str(firstyear)
 
 Same spacing problem, also I wonder if you want | instead of .  
 will mean you are testing for years that are simultaneously the first
 AND (  ) the third, rather than the first OR ( | )the third.  See
 ?Logic for the distinction (in base, if it asks).
 
 HTH,
 
 Josh
 
 
  Felipe D. Carrillo
  Supervisory Fishery Biologist
  Department of the Interior
  US Fish  Wildlife Service
  California, USA
 
 
 
 
  __
  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.
 
 
 -- 
 Joshua Wiley
 Ph.D. Student, Health Psychology
 University of California, Los Angeles
 http://www.joshuawiley.com/
 




__
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] Systat NRM function

2010-11-10 Thread Felipe Carrillo
Hi:
I have some old scripts from when I used to use Systat and have the 
NRM(value1,value2) that I 

need to use with R. Does anyone know the R equivalency to this function? Thanks
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA




__
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] how to view the top 20 lines in a long dataset

2010-11-01 Thread Felipe Carrillo
is this what you want?

head(yourdataset,20)
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: Louis Plough lplo...@usc.edu
 To: r-help@r-project.org
 Sent: Mon, November 1, 2010 12:40:19 PM
 Subject: [R] how to view the top 20 lines in a long dataset
 
 Hi,
 I am simply looking for the function that will allow you to look at the top
 20 lines of a long dataset?
 
 LP
 
 
 On Mon, Nov 1, 2010 at 10:46 AM, Louis Plough lplo...@usc.edu wrote:
 
  Hi,
  I am trying to generate all possible permutations (choose 2) of a vector,
  b, for example--using 'combn' the combinations in only one direction are
  generated...
 
   b-c(.1,.2,.3)
   combn(b,2)
       [,1] [,2] [,3]
  [1,]  0.1  0.1  0.2
  [2,]  0.2  0.3  0.3
 
                         [1,] 0.1  0.2  0.3  0.2  0.3  0.3        These
  should also be there.
                         [2,] 0.1  0.2  0.3  0.1  0.1  0.2
 
  Is there another R function that can do this??
 
  Thanks,
  Louis
 
 
     [[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-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] (no subject)

2010-10-23 Thread Felipe Carrillo
http://www.sangermanomobili.it/mfoto.php


  
[[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] Count values in a dataframe with respect to groups

2010-10-08 Thread Felipe Carrillo
Here is an option:

grp = c(1,1,1, 1,2, 2,2)
 val = c(2,1,5,NA,3,NA,1)
 dta = data.frame(grp=grp, val=val)
ddply(dta,grp,summarise,count=length(na.omit(val)))
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: Marcus Drescher dresc...@tum.de
 To: r-help@r-project.org r-help@r-project.org
 Sent: Fri, October 8, 2010 8:04:40 AM
 Subject: Re: [R] Count values in a dataframe with respect to groups
 
 Thanks! It works great.
 
 One more question: how would I have to set the formula if I would have the 
columns to count (val1 and val2)?
 
 
 Betreff: Re: [R] Count values in a dataframe with respect to groups
 
 Try this:
 
 aggregate(val ~ grp, dta, length)
 
 On Fri, Oct 8, 2010 at 11:28 AM, Marcus Drescher dresc...@tum.de wrote:
 Dear all,
 
 I am looking for a function to count values belonging to a class within a 
dataframe (and ignore NAs).
 
 grp = c(1,1,1, 1,2, 2,2)
 val = c(2,1,5,NA,3,NA,1)
 
 dta = data.frame(grp=grp, val=val)
 
 The result should look like:
 
 grp count
  1    3
  2    2
 
 At the moment, I am trying to find a function for FUN in aggregate, but with 
 no 
success. Can anybody help me?
 
 Thanks in advance.
 Marcus
 
 __
 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.
 
 
 
 -- 
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O
 
 __
 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-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] gridExtra question

2010-10-01 Thread Felipe Carrillo
 
Hi:
I get a couple of warnings  when trying to download gridExtra:
install.packages(gridExtra,repos=http://R-Forge.R-project.org)

 Warning: unable to access index for repository 
http://R-Forge.R-project.org/bin/windows/contrib/2.10
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
  package ‘gridextra’ is not available

I would like to download the binary for windows

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA




__
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] gridExtra question

2010-10-01 Thread Felipe Carrillo
I must be blind, CRAN was  my first try and didn't see it there. 
It is Friday and time to take a break I guess :-)
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



From: Ista Zahn iz...@psych.rochester.edu
To: Felipe Carrillo mazatlanmex...@yahoo.com
Cc: r-h...@stat.math.ethz.ch
Sent: Fri, October 1, 2010 12:22:22 PM
Subject: Re: [R] gridExtra question

Is there some reason you don't want the CRAN version?

-Ista


On Fri, Oct 1, 2010 at 3:08 PM, Felipe Carrillo mazatlanmex...@yahoo.com 
wrote:

 
Hi:
I get a couple of warnings  when trying to download gridExtra:
install.packages(gridExtra,repos=http://R-Forge.R-project.org)

 Warning: unable to access index for repository
http://R-Forge.R-project.org/bin/windows/contrib/2.10
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
  package ‘gridextra’ is not available

I would like to download the binary for windows

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA




__
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.



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org



  
[[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] gridExtra question

2010-10-01 Thread Felipe Carrillo
It looks like the list of packages is not refreshing on my pc because
If I go to packages  install packages I don't see it there next to 'gridBase'
but I went to the CRAN website and there it is right next to 'gridBase'. 
I had to manually download the Windows binary from there, saved it to my
desktop and then installed packages from local zip files
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: Erik Iverson er...@ccbr.umn.edu
 To: Felipe Carrillo mazatlanmex...@yahoo.com
 Cc: r-h...@stat.math.ethz.ch
 Sent: Fri, October 1, 2010 12:19:42 PM
 Subject: Re: [R] gridExtra question
 
 Forgot to mention you should be able to install from a CRAN
 mirror.
 
 Felipe Carrillo wrote:
   Hi:
  I get a couple of warnings  when trying to download gridExtra:
  install.packages(gridExtra,repos=http://R-Forge.R-project.org)
  
   Warning: unable to access index for repository 
http://R-Forge.R-project.org/bin/windows/contrib/2.10
  Warning message:
  In getDependencies(pkgs, dependencies, available, lib) :
   package ‘gridextra’ is not available
  
  I would like to download the binary for windows
  
  Felipe D. Carrillo
  Supervisory Fishery Biologist
  Department of the Interior
  US Fish  Wildlife Service
  California, USA
  
  
  
  
  __
  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-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] Controling R from MS Access

2010-09-29 Thread Felipe Carrillo
HI:
I've seen a few threads about this topic but
still can't find a straightforward way on this.
  
Is there a package that can control R within an access form. For example,
I want to send a query to R, perform some statistics in R and send the output or
summary back to Access and display it on a form. I can do this using Excel as 
the 

'middleman' but was wondering if it can be done straight from access. I can 
open 
R and 

send data to Access but I prefer to do it the other way around so that I can 
automate the 

process with VBA. It is real easy to control R from Excel with RExcel but can't 
find any
examples where Access is used. Thanks for any advice.


Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA




__
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] reordering levels error

2010-08-30 Thread Felipe Carrillo
Please consider the following dataset:
I want to reorder the levels by year but get the following error:

Error in tapply(v, x, FUN, ...) : arguments must have same length
 
I suspect that I need to add the levels before I melt the dataset
 but either way I have only use 'reorder' once before and can't figure
 out how it works..Thanks for any advice.
 
winter - (list(week = c(26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L,
34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
47L, 48L, 49L, 50L, 51L, 52L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L,
22L, 23L, 24L, 25L, 26L), BY2010 = c(0L, 0L, 460L, 1126L, 1755L,
11153L, 27998L, 56336L, 12486L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L), BY2009 = c(0L, 95L, 341L, 373L, 2859L, 5769L,
33263L, 98435L, 345339L, 622621L, 349958L, 531232L, 652803L,
345358L, 142991L, 148883L, 957501L, 32495L, 14862L, 7210L, 9765L,
6846L, 5067L, 6201L, 3045L, 106230L, 1183L, 195L, 6855L, 10261L,
4179L, 650L, 240L, 165L, 1189L, 863L, 562L, 1350L, 188L, 479L,
770L, 0L, 558L, 314L, 147L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
    BY2008 = c(0L, 0L, 77L, 124L, 159L, 2376L, 9480L, 17314L,
    99574L, 323679L, 198211L, 93630L, 129183L, 111820L, 71260L,
    35241L, 14020L, 20778L, 21694L, 15016L, 13400L, 9187L, 3607L,
    2804L, 2417L, 5291L, 16216L, 898L, 558L, 709L, 972L, 61L,
    372L, 3086L, 10108L, 4295L, 882L, 2593L, 36L, 233L, 243L,
    0L, 70L, 272L, 308L, 134L, 40L, 0L, 0L, 0L, 0L, 0L, 0L),
    BY2007 = c(0L, 0L, 0L, 10775L, 4166L, 4958L, 16221L, 29401L,
    34951L, 33188L, 146044L, 105007L, 185297L, 159682L, 207537L,
    140694L, 128275L, 44274L, 27079L, 18928L, 10437L, 29984L,
    18395L, 25846L, 4573L, 31995L, 3679L, 1043L, 9636L, 1524L,
    827L, 7009L, 233L, 433L, 0L, 1103L, 257L, 128L, 66L, 70L,
    535L, 429L, 97L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
    BY2006 = c(0L, 707L, 2390L, 8860L, 24430L, 40885L, 72792L,
    205521L, 344493L, 662973L, 526409L, 631953L, 850491L, 842678L,
    445987L, 558152L, 332032L, 174326L, 80601L, 48696L, 98571L,
    103563L, 149469L, 78081L, 182478L, 2158L, 16566L, 4027L,
    2655L, 1112L, 567L, 2595L, 4976L, 6336L, 294L, 1758L, 291L,
    203L, 450L, 1098L, 788L, 195L, 532L, 0L, 0L, 0L, 0L, 0L,
    0L, 167L, 0L, 0L, 0L), BY2005 = c(0L, 0L, 868L, 2044L, 4064L,
    6049L, 9399L, 13304L, 45172L, 242155L, 476864L, 712534L,
    1058409L, 2115018L, 1510342L, 1138213L, 333192L, 158820L,
    94379L, 348882L, 39290L, 29701L, 47258L, 69837L, 7884L, 49338L,
    22168L, 19397L, 19397L, 15984L, 8688L, 1200L, 1623L, 1291L,
    1356L, 707L, 875L, 875L, 222L, 883L, 0L, 0L, 129L, 0L, 0L,
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)), .Names = c(week, BY2010,
BY2009, BY2008, BY2007, BY2006, BY2005), class = data.frame, 
row.names = c(NA,
-53L))
 str(winter)
 w_melt - melt(winter,id=week,variable=year);str(w_melt)
 #  Reorder DOESN'T WORK
 w_melt - 
reorder(w_melt$year,c(BY2005,BY2009,BY2006,BY2008,BY2007,BY2010))
pdf(wtest.pdf)
ggplot(w_melt,aes(week,value/1000,colour=year,order= - as.numeric(year))) + 
geom_line(size=.75)+  theme_bw() +
opts(title=Cumulative,axis.text.x = theme_text(angle=45,hjust=1)) +
 labs(y=Number of individuals X 1,000,x=week)
dev.off()
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA




__
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] reordering levels error

2010-08-30 Thread Felipe Carrillo
Sorry about the structure thing, I basically want my levels on this order:
 w_melt - 
reorder(w_melt$year,c(BY2005,BY2009,BY2006,BY2008,BY2007,BY2010))
 Here's the new dataset , please discard the reverse year, I was just trying it 
but it didn't do what I wanted
and forgot to delete it. 
With ggplot2 I am trying to show the line with max value above and then show 
the 
other lines in the same order as the
w_melt reorder code above.

winter - structure(list(week = c(26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L,
34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
47L, 48L, 49L, 50L, 51L, 52L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L,
22L, 23L, 24L, 25L, 26L), BY2010 = c(0L, 0L, 460L, 1126L, 1755L,
11153L, 27998L, 56336L, 12486L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L), BY2009 = c(0L, 95L, 341L, 373L, 2859L, 5769L,
33263L, 98435L, 345339L, 622621L, 349958L, 531232L, 652803L,
345358L, 142991L, 148883L, 957501L, 32495L, 14862L, 7210L, 9765L,
6846L, 5067L, 6201L, 3045L, 106230L, 1183L, 195L, 6855L, 10261L,
4179L, 650L, 240L, 165L, 1189L, 863L, 562L, 1350L, 188L, 479L,
770L, 0L, 558L, 314L, 147L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
    BY2008 = c(0L, 0L, 77L, 124L, 159L, 2376L, 9480L, 17314L,
    99574L, 323679L, 198211L, 93630L, 129183L, 111820L, 71260L,
    35241L, 14020L, 20778L, 21694L, 15016L, 13400L, 9187L, 3607L,
    2804L, 2417L, 5291L, 16216L, 898L, 558L, 709L, 972L, 61L,
    372L, 3086L, 10108L, 4295L, 882L, 2593L, 36L, 233L, 243L,
    0L, 70L, 272L, 308L, 134L, 40L, 0L, 0L, 0L, 0L, 0L, 0L),
    BY2007 = c(0L, 0L, 0L, 10775L, 4166L, 4958L, 16221L, 29401L,
    34951L, 33188L, 146044L, 105007L, 185297L, 159682L, 207537L,
    140694L, 128275L, 44274L, 27079L, 18928L, 10437L, 29984L,
    18395L, 25846L, 4573L, 31995L, 3679L, 1043L, 9636L, 1524L,
    827L, 7009L, 233L, 433L, 0L, 1103L, 257L, 128L, 66L, 70L,
    535L, 429L, 97L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
    BY2006 = c(0L, 707L, 2390L, 8860L, 24430L, 40885L, 72792L,
    205521L, 344493L, 662973L, 526409L, 631953L, 850491L, 842678L,
    445987L, 558152L, 332032L, 174326L, 80601L, 48696L, 98571L,
    103563L, 149469L, 78081L, 182478L, 2158L, 16566L, 4027L,
    2655L, 1112L, 567L, 2595L, 4976L, 6336L, 294L, 1758L, 291L,
    203L, 450L, 1098L, 788L, 195L, 532L, 0L, 0L, 0L, 0L, 0L,
    0L, 167L, 0L, 0L, 0L), BY2005 = c(0L, 0L, 868L, 2044L, 4064L,
    6049L, 9399L, 13304L, 45172L, 242155L, 476864L, 712534L,
    1058409L, 2115018L, 1510342L, 1138213L, 333192L, 158820L,
    94379L, 348882L, 39290L, 29701L, 47258L, 69837L, 7884L, 49338L,
    22168L, 19397L, 19397L, 15984L, 8688L, 1200L, 1623L, 1291L,
    1356L, 707L, 875L, 875L, 222L, 883L, 0L, 0L, 129L, 0L, 0L,
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)), .Names = c(week, BY2010,
BY2009, BY2008, BY2007, BY2006, BY2005), class = data.frame, 
row.names = c(NA,
-53L))
winter
 w_melt - melt(winter,id=week,variable=year);str(w_melt)
 #  Reorder DOESN'T WORK
 w_melt - 
reorder(w_melt$year,c(BY2005,BY2009,BY2006,BY2008,BY2007,BY2010))
pdf(wtest.pdf)
ggplot(w_melt,aes(week,value/1000,colour)) + geom_line(size=.75)+  theme_bw() +
opts(title=Cumulative,axis.text.x = theme_text(angle=45,hjust=1)) +
 labs(y=Number of individuals X 1,000,x=week)
dev.off()

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: David Winsemius dwinsem...@comcast.net
 To: r-help Help r-h...@stat.math.ethz.ch
 Sent: Mon, August 30, 2010 2:49:15 PM
 Subject: Re: [R] reordering levels error
 
 
 On Aug 30, 2010, at 5:25 PM, Felipe Carrillo wrote:
 
  Please consider the following dataset:
  I want to reorder the levels by year but get the following error:
  
  Error in tapply(v, x, FUN, ...) : arguments must have same length
  
  I suspect that I need to add the levels before I melt the dataset
   but either way I have only use 'reorder' once before and can't figure
   out how it works..Thanks for any advice.
  
  winter - (list(week = c(26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L,
 
 I believe you omitted a necessarystructure call above.
 
  34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
  47L, 48L, 49L, 50L, 51L, 52L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
  9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L,
  22L, 23L, 24L, 25L, 26L), BY2010 = c(0L, 0L, 460L, 1126L, 1755L,
  11153L, 27998L, 56336L, 12486L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  0L, 0L, 0L, 0L), BY2009 = c(0L, 95L, 341L, 373L, 2859L, 5769L,
  33263L, 98435L, 345339L, 622621L, 349958L, 531232L, 652803L,
  345358L, 142991L, 148883L, 957501L, 32495L, 14862L, 7210L, 9765L,
  6846L, 5067L, 6201L, 3045L, 106230L, 1183L, 195L, 6855L, 10261L

Re: [R] reordering levels error

2010-08-30 Thread Felipe Carrillo

 Thanks Dennis:
I always seem to have a hard time defining levels. That's exactly what I 
needed. 

 


From: Dennis Murphy djmu...@gmail.com
To: Felipe Carrillo mazatlanmex...@yahoo.com
Cc: r-h...@stat.math.ethz.ch
Sent: Mon, August 30, 2010 5:41:02 PM
Subject: Re: [R] reordering levels error

Hi:

I don't know if this is exactly what you wanted, but here goes. I made
a few adjustments in the data frame before calling ggplot():

# library(ggplot2)

# Reorient the order in which variables appear
winter - winter[, c(1, 7, 3, 6, 4, 5, 2)]

# Get rid of second week 26 at the end
winter2 - winter[-53, ]

# Create an ordered factor for labeling the weeks
wkord - c(26:52, 1:25)
winter2$week - ordered(winter2$week, levels = wkord)

# melt the data frame
w - melt(winter2, id = 'week')

# create ordered factor for year
w$year - substring(as.character(w$variable), 3, 6)
w$year - factor(w$year, levels = c(2005, 2009, 2006, 2008, 2007, 2010),
  ordered = TRUE)

# x variable in ggplot() must be continuous for geom_line() to work
g - ggplot(w,aes(x = wk, y = value/1000, colour = year))

# Plot with week numbers on x-axis, rotated and resized for presentation
g + geom_line() + scale_x_continuous(breaks = 1:52, labels = levels(w$week)) +
 opts(axis.text.x = theme_text(angle = 90, vjust = 0.5, hjust = 1, size = 7))

HTH,
Dennis


On Mon, Aug 30, 2010 at 2:25 PM, Felipe Carrillo mazatlanmex...@yahoo.com 
wrote:

Please consider the following dataset:
I want to reorder the levels by year but get the following error:

Error in tapply(v, x, FUN, ...) : arguments must have same length
 
I suspect that I need to add the levels before I melt the dataset
 but either way I have only use 'reorder' once before and can't figure
 out how it works..Thanks for any advice.
 
winter - (list(week = c(26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L,
34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L,
47L, 48L, 49L, 50L, 51L, 52L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L,
22L, 23L, 24L, 25L, 26L), BY2010 = c(0L, 0L, 460L, 1126L, 1755L,
11153L, 27998L, 56336L, 12486L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L), BY2009 = c(0L, 95L, 341L, 373L, 2859L, 5769L,
33263L, 98435L, 345339L, 622621L, 349958L, 531232L, 652803L,
345358L, 142991L, 148883L, 957501L, 32495L, 14862L, 7210L, 9765L,
6846L, 5067L, 6201L, 3045L, 106230L, 1183L, 195L, 6855L, 10261L,
4179L, 650L, 240L, 165L, 1189L, 863L, 562L, 1350L, 188L, 479L,
770L, 0L, 558L, 314L, 147L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
    BY2008 = c(0L, 0L, 77L, 124L, 159L, 2376L, 9480L, 17314L,
    99574L, 323679L, 198211L, 93630L, 129183L, 111820L, 71260L,
    35241L, 14020L, 20778L, 21694L, 15016L, 13400L, 9187L, 3607L,
    2804L, 2417L, 5291L, 16216L, 898L, 558L, 709L, 972L, 61L,
    372L, 3086L, 10108L, 4295L, 882L, 2593L, 36L, 233L, 243L,
    0L, 70L, 272L, 308L, 134L, 40L, 0L, 0L, 0L, 0L, 0L, 0L),
    BY2007 = c(0L, 0L, 0L, 10775L, 4166L, 4958L, 16221L, 29401L,
    34951L, 33188L, 146044L, 105007L, 185297L, 159682L, 207537L,
    140694L, 128275L, 44274L, 27079L, 18928L, 10437L, 29984L,
    18395L, 25846L, 4573L, 31995L, 3679L, 1043L, 9636L, 1524L,
    827L, 7009L, 233L, 433L, 0L, 1103L, 257L, 128L, 66L, 70L,
    535L, 429L, 97L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
    BY2006 = c(0L, 707L, 2390L, 8860L, 24430L, 40885L, 72792L,
    205521L, 344493L, 662973L, 526409L, 631953L, 850491L, 842678L,
    445987L, 558152L, 332032L, 174326L, 80601L, 48696L, 98571L,
    103563L, 149469L, 78081L, 182478L, 2158L, 16566L, 4027L,
    2655L, 1112L, 567L, 2595L, 4976L, 6336L, 294L, 1758L, 291L,
    203L, 450L, 1098L, 788L, 195L, 532L, 0L, 0L, 0L, 0L, 0L,
    0L, 167L, 0L, 0L, 0L), BY2005 = c(0L, 0L, 868L, 2044L, 4064L,
    6049L, 9399L, 13304L, 45172L, 242155L, 476864L, 712534L,
    1058409L, 2115018L, 1510342L, 1138213L, 333192L, 158820L,
    94379L, 348882L, 39290L, 29701L, 47258L, 69837L, 7884L, 49338L,
    22168L, 19397L, 19397L, 15984L, 8688L, 1200L, 1623L, 1291L,
    1356L, 707L, 875L, 875L, 222L, 883L, 0L, 0L, 129L, 0L, 0L,
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)), .Names = c(week, BY2010,
BY2009, BY2008, BY2007, BY2006, BY2005), class = data.frame,
row.names = c(NA,
-53L))
 str(winter)
 w_melt - melt(winter,id=week,variable=year);str(w_melt)
 #  Reorder DOESN'T WORK
 w_melt -
reorder(w_melt$year,c(BY2005,BY2009,BY2006,BY2008,BY2007,BY2010))
pdf(wtest.pdf)
ggplot(w_melt,aes(week,value/1000,colour=year,order= - as.numeric(year))) +
geom_line(size=.75)+  theme_bw() +
opts(title=Cumulative,axis.text.x = theme_text(angle=45,hjust=1)) +
 labs(y=Number of individuals X 1,000,x=week)
dev.off()
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA




__
R-help@r-project.org mailing list
https

Re: [R] Trouble using grid.layout in Sweave

2010-07-26 Thread Felipe Carrillo
I just run the code below with sweave and works fine
It looks like you might be missing the sequence of vplay


fig.R,echo=F,fig=T=
library(ggplot2)
vplay- function(x, y) 
viewport(layout.pos.row=x, layout.pos.col=y) 
grid.newpage() 
p - ggplot(diamonds, aes(x=carat, y=..density..)) + 
geom_histogram(binwidth=0.2)
p - p + facet_grid(. ~ cut)
pushViewport(viewport(layout=grid.layout(3,3))) 
print(p, vp=vplay(1,1)) 
print(p, vp=vplayt(2:3,2:3)) 
print(p, vp=vplay(1, 2:3)) 
print(p, vp=vplay(2:3, 1)) 
@
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: Sebastian Weber sebastian.we...@physik.tu-darmstadt.de
 To: r-help@r-project.org
 Sent: Mon, July 26, 2010 7:51:06 AM
 Subject: [R] Trouble using grid.layout in Sweave
 
 Hi!
 
 I am troubled by Sweave which I want to use in order to plot graphics which
 I build up successively by the use of grid.layout. Here is the code:
 
 fig=TRUE,label=evolDist,height=6in,width=3in,pdf=FALSE=
 
 ## combined plot via grid viewports
 grid.newpage()
 pushViewport(viewport(layout=grid.layout(2,1)))
 vlay - function(x,y) viewport(layout.pos.row=x, layout.pos.col=y)
 print(pl$gscoreDist, vp=vlay(1,1))
 print(pl$acceptDist, vp=vlay(2,1))
 dev.off()
 
 @
 
 The error is the following from Sweave:
 
 Error in grid.newpage() : Non-finite location and/or size for viewport
 In addition: There were 24 warnings (use warnings() to see them)
 Error in driver$runcode(drobj, chunk, chunkopts) :
   Error in grid.newpage() : Non-finite location and/or size for viewport
 Calls: Sweave - Anonymous
 Execution halted
 
 
 Any hints? Of course, I can always wrap the code into a fig=FALSE, and
 pdf()-call, but that is not how sweave is meant to be used, as I got it.
 
 Many thanks in advance,
 
 Sebastian Weber
 
     [[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-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] How to generate a sequence of dates without hardcoding the year

2010-07-26 Thread Felipe Carrillo
Thanks Jim and Enrique, that should work since I am only trying to show
the month along my X axis it regardless of what year it is.
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: jim holtman jholt...@gmail.com
 To: Felipe Carrillo mazatlanmex...@yahoo.com
 Cc: r-h...@stat.math.ethz.ch
 Sent: Sat, July 24, 2010 4:02:57 PM
 Subject: Re: [R] How to generate a sequence of dates without hardcoding the 
year
 
 Is this what you want if you want to assume that the date without a
 year is this year:
 
  seq(as.Date(7-1,%m-%d),by=week, length=52)
 [1] 2010-07-01 2010-07-08 2010-07-15 2010-07-22 2010-07-29
 2010-08-05 2010-08-12 2010-08-19
 [9] 2010-08-26 2010-09-02 2010-09-09 2010-09-16 2010-09-23
 2010-09-30 2010-10-07 2010-10-14
 [17] 2010-10-21 2010-10-28 2010-11-04 2010-11-11 2010-11-18
 2010-11-25 2010-12-02 2010-12-09
 [25] 2010-12-16 2010-12-23 2010-12-30 2011-01-06 2011-01-13
 2011-01-20 2011-01-27 2011-02-03
 [33] 2011-02-10 2011-02-17 2011-02-24 2011-03-03 2011-03-10
 2011-03-17 2011-03-24 2011-03-31
 [41] 2011-04-07 2011-04-14 2011-04-21 2011-04-28 2011-05-05
 2011-05-12 2011-05-19 2011-05-26
 [49] 2011-06-02 2011-06-09 2011-06-16 2011-06-23
 
 
 
 On Sat, Jul 24, 2010 at 5:07 PM, Felipe Carrillo
 mazatlanmex...@yahoo.com wrote:
  Hi:
  I have a dataframe named 'spring' and I am trying to add a new variable 
named
  'IdDate'
  This line of code works fine:
  spring$idDate - seq(as.Date(2008-07-01),as.Date(2009-06-30),by=week)
 
  But I don't want to hardcode the year because it will be used again the
  following year
  Is it possible to just generate dates with the month and day?
 
  I tried the code below:
  seq(as.Date(7-1,%B%d),as.Date(6-30,%B%d),by=week)
 
  and got this error message:
  Error in seq.int(0, to - from, by) : 'to' must be finite
  Thanks for any pointers
 
 
  Felipe D. Carrillo
  Supervisory Fishery Biologist
  Department of the Interior
  US Fish  Wildlife Service
  California, USA
 
 
 
 
  __
  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.
 
 
 
 
 -- 
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390
 
 What is the problem that you are trying to solve?
 




__
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 generate a sequence of dates without hardcoding the year

2010-07-24 Thread Felipe Carrillo
Hi:
I have a dataframe named 'spring' and I am trying to add a new variable named 
'IdDate'
This line of code works fine:
spring$idDate - seq(as.Date(2008-07-01),as.Date(2009-06-30),by=week)

But I don't want to hardcode the year because it will be used again the 
following year
Is it possible to just generate dates with the month and day? 

I tried the code below:
seq(as.Date(7-1,%B%d),as.Date(6-30,%B%d),by=week)

and got this error message:
Error in seq.int(0, to - from, by) : 'to' must be finite
Thanks for any pointers

 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA




__
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] Figures in Latex

2010-07-23 Thread Felipe Carrillo
Hannah: I am not sure if this is what you
need but you can use an array to do that.
Copy and paste the below code to your latex code.

\newpage
\begin{landscape}
\begin{figure}[h]
\begin{center}$
\begin{array}{cc}
\includegraphics[width=2in]{yourgraphicname} 
\includegraphics[width=2in]{yourgraphicname} \\
\includegraphics[width=2in]{yourgraphicname} 
\includegraphics[width=2in]{yourgraphicname\\
\includegraphics[width=2in]{yourgraphicname} 
\includegraphics[width=2in]{yourgraphicname}\\
\end{array}$
\end{center}
\caption{is this what you had in mind?}
\end{figure}
\end{landscape}
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: Kingsford Jones kingsfordjo...@gmail.com
 To: li li hannah@gmail.com
 Cc: r-help r-help@r-project.org
 Sent: Fri, July 23, 2010 12:49:20 PM
 Subject: Re: [R] Figures in Latex
 
 to make the desired within R's plotting device rather than in latex try:
 
 par(mfrow = c(3, 2))
 
 and you'll probably want to adjust other mar, parameters as well (e.g.
 mar, cex.lab, etc).
 
 Or, take advantage of the flexibility offered by the graphics package
 by studying ?layout
 
 hth,
 Kingsford
 
 
 
 On Fri, Jul 23, 2010 at 7:43 AM, li li hannah@gmail.com wrote:
  Hi all,
    I want to add 6 plots in the format of 2 columns and 3 rows as one
  figure in latex. The plots are in .eps file.
  I know how to add 2 plots side by side, but could not figure out how to do
  multiple rows.
   I know this may not be the right place to ask such a question. But I do
  not know who to ask, so just try my
  luck here.
   Thank you in advance.
                                                       Hannah
 
         [[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-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-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] latex table question

2010-07-18 Thread Felipe Carrillo
I' ve seen latex questions being solved here that's why I sent my question
to this list but someone already told me about the latex forum so the same 
question has already been solved there, Sorry about that.

 



- Original Message 
 From: Uwe Ligges lig...@statistik.tu-dortmund.de
 To: Felipe Carrillo mazatlanmex...@yahoo.com
 Cc: r-h...@stat.math.ethz.ch
 Sent: Sun, July 18, 2010 10:24:39 AM
 Subject: Re: [R] latex table question
 
 Why do you think R-help is a mailing list about LaTeX?
 
 Best,
 Uwe Ligges
 
 
 
 On 13.07.2010 23:05, Felipe Carrillo wrote:
  Hi:
  My head is spinning with this latex doc so hopefully after I align my 
  tables 
to
  the left of the page
  my headache are going to be over. I always use:
  \hspace*{-0.1in}
  to move my figures horizontally to the left margin of the page but the table
  below doesn't move at all,
  but instead it gets sideways. Not sure if \begin{landscape} has something 
  to 
do
  with it or is just me.
  I  hope someone could lend some help on this matter.
 
  \documentclass[11pt]{article}
  \usepackage{longtable,verbatim}
  \usepackage{longtable,pdflscape,graphicx}
  \usepackage{fmtcount,hyperref} % displaying latex counters
   %\usepackage[top=0.2inch, bottom=0.2inch, left=2cm, right=2cm]{geometry}
  \usepackage{fullpage}
  \usepackage{ctable}
  \title{United States Department of the Interior}
  \begin{document}
   %\setlength{\topmargin}{-1inch} % Just an example
  \setkeys{Gin}{width=1\textwidth} % makes all the graphics scales
  \maketitle
  echo=F,results=hide=
  reportDF- structure(list(IDDate = c(3/12/2010, 3/13/2010, 3/14/2010,
  3/15/2010), FirstRunoftheYear = c(33 (119 ? 119), n (0 ? 0), 893 
  (110 
?
  146),
  140 (111 ? 150)), SecondRunoftheYear = c(33 (71 ? 71), n (0 ? 0),
  337 (67 ? 74), 140 (68 ? 84)), ThirdRunoftheYear = c(890 (32 ? 47),
  n (0 ? 0), 10,602 (32 ? 52), 2,635 (34 ? 66)), FourthRunoftheYear = 
c(0 (
  ? ),
  n (0 ? 0), 0 ( ? ), 0 ( ? )), LastRunoftheYear = c(0 ( ? ), n (0 ? 
0),
  0 ( ? ), 0 ( ? ))), .Names = c(IDDate, First Run of the Year, 
Second
  Run of the Year,
  Third Run of the Year, Fourth Run of the Year, Last Run of the Year),
  row.names = c(NA, 4L), class = data.frame)
  @
  \begin{landscape}
  \begin{table}[!tbp]
  \begin{center}
  \begin{tabular}{ll}\hline\hline
  \multicolumn{1}{c}{IDDate}
  \multicolumn{1}{c}{First Run of the Year}
  \multicolumn{1}{c}{Second Run of the Year}
  \multicolumn{1}{c}{Third Run of the Year}
  \multicolumn{1}{c}{Fourth Run of the Year}
  \multicolumn{1}{c}{Last Run of the Year}\tabularnewline
  \hline
  13/12/201033 (119 ? 119)33 (71 ? 71)890 (32 ? 47)0 ( ? )0 ( ?
  )\tabularnewline
  23/13/2010n (0 ? 0)n (0 ? 0)n (0 ? 0)n (0 ? 0)n (0 ? 0)\tabularnewline
  33/14/2010893 (110 ? 146)337 (67 ? 74)10,602 (32 ? 52)0 ( ? )0 ( ?
  )\tabularnewline
  43/15/2010140 (111 ? 150)140 (68 ? 84)2,635 (34 ? 66)0 ( ? )0 ( ?
  )\tabularnewline
  \hline
  \end{tabular}
  \end{center}
  \end{table}\end{landscape}
  \end{document}
 
  Felipe D. Carrillo
  Supervisory Fishery Biologist
  Department of the Interior
  US Fish  Wildlife Service
  California, USA
 
 
 
 
  __
  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-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] How to select the column header with \Sexpr{}

2010-07-13 Thread Felipe Carrillo
Thanks Izta:
I see your point, then I should extract the column names when the 
dataset is first read because is a dataframe:
 report - structure(list(Date = c(3/12/2010, 3/13/2010, 3/14/2010,
 3/15/2010), Run1 = c(33 (119 ? 119), n (0 ? 0), 893 (110 ? 146),
 140 (111 ? 150)), Run2 = c(33 (71 ? 71), n (0 ? 0),
 337 (67 ? 74), 140 (68 ? 84)), Run3 = c(890 (32 ? 47),
 n (0 ? 0), 10,602 (32 ? 52), 2,635 (34 ? 66)), Run4 = c(0 ( ? ),
 n (0 ? 0), 0 ( ? ), 0 ( ? )), Run4 = c(0 ( ? ), n (0 ? 0),
0 ( ? ), 0 ( ? ))), .Names = c(ID_Date, Run1, Run2,
Run3, Run4, Run5), row.names = c(NA, 4L), class = data.frame)
str(report)
'data.frame':   4 obs. of  6 variables:
 $ ID_Date: chr  3/12/2010 3/13/2010 3/14/2010 3/15/2010
 $ Run1   : chr  33 (119 ? 119) n (0 ? 0) 893 (110 ? 146) 140 (111 ? 
150)
 $ Run2   : chr  33 (71 ? 71) n (0 ? 0) 337 (67 ? 74) 140 (68 ? 84)
 $ Run3   : chr  890 (32 ? 47) n (0 ? 0) 10,602 (32 ? 52) 2,635 (34 ? 
66)
 $ Run4   : chr  0 ( ? ) n (0 ? 0) 0 ( ? ) 0 ( ? )
 $ Run5   : chr  0 ( ? ) n (0 ? 0) 0 ( ? ) 0 ( ? )
 names(report)[1]  # I can extract the column name here
[1] Date

But after I use 'stringr to convert the character '?' to '-'
'report' is not a dataframe anymore and returns a NULL when trying to extract 
the
column names. 
I was not aware that \Sexpr{} only work on dataframes, thanks for your help.



- Original Message 
 From: Ista Zahn iz...@psych.rochester.edu
 To: Felipe Carrillo mazatlanmex...@yahoo.com
 Cc: David Winsemius dwinsem...@comcast.net; r-h...@stat.math.ethz.ch
 Sent: Tue, July 13, 2010 7:13:39 AM
 Subject: Re: [R] How to select the column header with \Sexpr{}
 
 Hi Felipe,
 The problem has nothing to do with Sweave or \Sexpr. The problem is
 that by the time you call \Sexpr report is a matrix, and you cannot
 access the column names of a matrix with names(). You need to use
 colnames() or convert the matrix to a data.frame.
 
 Perhaps a true useR can write R code in a Sweave file without checking
 it, but for mere mortals it is best to evaluate the R code in an
 interactive session to make sure it works before asking Sweave to
 insert it into your .tex file. If you had tried to evaluate
 names(report)[1] in an interactive session you would have discovered
 your problem immediately.
 
 Best,
 Ista
 
 On Tue, Jul 13, 2010 at 4:15 AM, Felipe Carrillo
 mazatlanmex...@yahoo.com wrote:
  I had tried that earlier and didn't work either, I probably have \Sexpr in 
the
  wrong place. See example:
  Column one header gets blank:
 
  \documentclass[11pt]{article}
  \usepackage{longtable,verbatim,ctable}
  \usepackage{longtable,pdflscape}
  \usepackage{fmtcount,hyperref}
  \usepackage{fullpage}
  \title{United States}
  \begin{document}
  \setkeys{Gin}{width=1\textwidth}
  \maketitle
  echo=F,results=hide=
  report - structure(list(Date = c(3/12/2010, 3/13/2010, 3/14/2010,
  3/15/2010), Run1 = c(33 (119 ? 119), n (0 ? 0), 893 (110 ? 146),
  140 (111 ? 150)), Run2 = c(33 (71 ? 71), n (0 ? 0),
  337 (67 ? 74), 140 (68 ? 84)), Run3 = c(890 (32 ? 47),
  n (0 ? 0), 10,602 (32 ? 52), 2,635 (34 ? 66)), Run4 = c(0 ( ? ),
  n (0 ? 0), 0 ( ? ), 0 ( ? )), Run4 = c(0 ( ? ), n (0 ? 0),
  0 ( ? ), 0 ( ? ))), .Names = c(ID_Date, Run1, Run2,
  Run3, Run4, Run5), row.names = c(NA, 4L), class = data.frame)
  require(stringr)
  report - t(apply(report, 1, function(x) {str_replace(x, \\?, -)}))
  #report
  #latex(report,file=)
  @
  \begin{landscape}
  \begin{table}[!tbp]
   \begin{center}
   \begin{tabular}{ll}\hline\hline
  \multicolumn{1}{c}{\Sexpr{names(report)[1]}}   # Using \Sexpr here
  \multicolumn{1}{c}{Run1}
  \multicolumn{1}{c}{Run2}
  \multicolumn{1}{c}{Run3}
  \multicolumn{1}{c}{Run4}
  \multicolumn{1}{c}{Run5}\tabularnewline
  \hline
  13/12/201033 (119 ? 119)33 (71 ? 71)890 (32 ? 47)0 ( ? )0 ( ?
  )\tabularnewline
  23/13/2010n (0 ? 0)n (0 ? 0)n (0 ? 0)n (0 ? 0)n (0 ? 0)\tabularnewline
  33/14/2010893 (110 ? 146)337 (67 ? 74)10,602 (32 ? 52)0 ( ? )0 ( ?
  )\tabularnewline
  43/15/2010140 (111 ? 150)140 (68 ? 84)2,635 (34 ? 66)0 ( ? )0 ( ?
  )\tabularnewline
  \hline
  \end{tabular}
  \end{center}
  \end{table}
  \end{landscape}
  \end{document}
 
  Felipe D. Carrillo
  Supervisory Fishery Biologist
  Department of the Interior
  US Fish  Wildlife Service
  California, USA
 
 
 
  - Original Message 
  From: David Winsemius dwinsem...@comcast.net
  To: Felipe Carrillo mazatlanmex...@yahoo.com
  Cc: Duncan Murdoch murdoch.dun...@gmail.com; r-h...@stat.math.ethz.ch
  Sent: Mon, July 12, 2010 3:14:49 PM
  Subject: Re: [R] How to select the column header with \Sexpr{}
 
 
  On Jul 12, 2010, at 5:45 PM, Felipe Carrillo wrote:
 
   Thanks for the quick reply Duncan.
   I don't think I have explained myself well, I have a dataset named 
report
 and
   my column headers are run1,run2,run3,run4 and so on.
  
   I know how to access the data below those columns with 
   \Sexpr{report[1,1]} 

   \Sexpr{report[1,2]} and so on, but I can't access my column headers
   with \Sexpr

[R] Wrap column headers caption

2010-07-13 Thread Felipe Carrillo
Hi:
Using this dataframe with quite long column headers, how can I wrap the 
text so that the columns are narrower. I was trying to use strwrap without 
success. Thanks

reportDF - structure(list(IDDate = c(3/12/2010, 3/13/2010, 3/14/2010,
3/15/2010), FirstRunoftheYear = c(33 (119 ? 119), n (0 ? 0), 893 (110 ? 
146),
140 (111 ? 150)), SecondRunoftheYear = c(33 (71 ? 71), n (0 ? 0),
337 (67 ? 74), 140 (68 ? 84)), ThirdRunoftheYear = c(890 (32 ? 47),
n (0 ? 0), 10,602 (32 ? 52), 2,635 (34 ? 66)), FourthRunoftheYear = c(0 
( 
? ),
n (0 ? 0), 0 ( ? ), 0 ( ? )), LastRunoftheYear = c(0 ( ? ), n (0 ? 0),
0 ( ? ), 0 ( ? ))), .Names = c(IDDate, First Run of the Year, Second 
Run of the Year,
Third Run of the Year, Fourth Run of the Year, Last Run of the Year), 
row.names = c(NA, 4L), class = data.frame)
 


Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA




__
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] latex table question

2010-07-13 Thread Felipe Carrillo
Hi:
My head is spinning with this latex doc so hopefully after I align my tables to 
the left of the page
my headache are going to be over. I always use:
\hspace*{-0.1in}
to move my figures horizontally to the left margin of the page but the table 
below doesn't move at all,
but instead it gets sideways. Not sure if \begin{landscape} has something to do 
with it or is just me.
I  hope someone could lend some help on this matter. 

\documentclass[11pt]{article}
\usepackage{longtable,verbatim}
\usepackage{longtable,pdflscape,graphicx}
\usepackage{fmtcount,hyperref} % displaying latex counters
 %\usepackage[top=0.2inch, bottom=0.2inch, left=2cm, right=2cm]{geometry}
\usepackage{fullpage} 
\usepackage{ctable}
\title{United States Department of the Interior}
\begin{document}
 %\setlength{\topmargin}{-1inch} % Just an example
\setkeys{Gin}{width=1\textwidth} % makes all the graphics scales
\maketitle
echo=F,results=hide=
reportDF - structure(list(IDDate = c(3/12/2010, 3/13/2010, 3/14/2010,
3/15/2010), FirstRunoftheYear = c(33 (119 ? 119), n (0 ? 0), 893 (110 ?
146),
140 (111 ? 150)), SecondRunoftheYear = c(33 (71 ? 71), n (0 ? 0),
337 (67 ? 74), 140 (68 ? 84)), ThirdRunoftheYear = c(890 (32 ? 47),
n (0 ? 0), 10,602 (32 ? 52), 2,635 (34 ? 66)), FourthRunoftheYear = c(0 (
? ),
n (0 ? 0), 0 ( ? ), 0 ( ? )), LastRunoftheYear = c(0 ( ? ), n (0 ? 0),
0 ( ? ), 0 ( ? ))), .Names = c(IDDate, First Run of the Year, Second
Run of the Year,
Third Run of the Year, Fourth Run of the Year, Last Run of the Year),
row.names = c(NA, 4L), class = data.frame)
@
\begin{landscape}
\begin{table}[!tbp]
\begin{center}
\begin{tabular}{ll}\hline\hline
\multicolumn{1}{c}{IDDate}
\multicolumn{1}{c}{First Run of the Year}
\multicolumn{1}{c}{Second Run of the Year}
\multicolumn{1}{c}{Third Run of the Year}
\multicolumn{1}{c}{Fourth Run of the Year}
\multicolumn{1}{c}{Last Run of the Year}\tabularnewline
\hline
13/12/201033 (119 ? 119)33 (71 ? 71)890 (32 ? 47)0 ( ? )0 ( ? 
)\tabularnewline
23/13/2010n (0 ? 0)n (0 ? 0)n (0 ? 0)n (0 ? 0)n (0 ? 0)\tabularnewline
33/14/2010893 (110 ? 146)337 (67 ? 74)10,602 (32 ? 52)0 ( ? )0 ( ? 
)\tabularnewline
43/15/2010140 (111 ? 150)140 (68 ? 84)2,635 (34 ? 66)0 ( ? )0 ( ? 
)\tabularnewline
\hline
\end{tabular}
\end{center}
\end{table}\end{landscape}
\end{document}
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA




__
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] export tables to excel files on multiple sheets with titles for each table

2010-07-13 Thread Felipe Carrillo
Check the WriteXLS package, I think it does that and also saves
each R object on a different excel sheet.
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: eugen pircalabelu eugen_pircalab...@yahoo.com
 To: R-help r-h...@stat.math.ethz.ch
 Sent: Tue, July 13, 2010 1:21:33 PM
 Subject: [R] export tables to excel files on multiple sheets with titles for 
each table
 
 Hello R-users,
 Checking the archives, I recently came across this topic: 
 export tables to Excel files 
(http://r.789695.n4.nabble.com/export-tables-to-Excel-files-td1565679.html#a1565679),
,
 and the following interesting references have been proposed:
 http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows
 http://www.r-bloggers.com/export-data-frames-to-multi-worksheet-excel-file-2/
 
 but my problem is somehow a small extension to what has been discussed, and 
 although i have a solution, i seek something more elegant. I want to export 
 multiple dataframes (on multiple sheets), but i also want each of them to 
 have 

 its own title that is to be written also in Excel. The packages/functions 
 that 
i 

 have checked, cannot accommodate a title that is to be written on the sheet, 
 along with the actual dataframe of interest.
 
 I can do something similar to what i need, but without writing the dataframes 
on 

 multiple sheets.
 
 #head(USArrests) and head(iris) written with accompanying title one under 
 each 

 other 
 
 write.excel-function (tab, ...){
 zz - file(example.dat, a+b) 
 cat(\TITLE extra line,file = zz, sep = \n)
 write.table(tab, file=zz, row.names=F,sep=\t)
 close(zz)}
 write.excel(head(USArrests))
 write.excel(head(iris))
 
 Any suggestion on how to export the same information on two separate sheets, 
and 

 keeping also a title for each of them, is highly appreciated, as i have been 
 searching for some time for a good solution.
 
 Thank you very much and have a great day ahead!
 
 
 
 
 
 
 Eugen Pircalabelu
 (0032)471 842 140
 (0040)727 839 293
 
 __
 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-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 select the column header with \Sexpr{}

2010-07-12 Thread Felipe Carrillo
Hi:
Since I work with a few different fish runs my column headers change everytime
I start a new Year. I have been using \Sexpr{} for my row and columns and now 
I am trying to use with my report column headers. \Sexpr{1,1} is row 1 column 1,
what can I use for headers? I tried \Sexpr{0,1} but sweave didn't like 
it..Thanks in advance
for any hints

 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA


   
__
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] How to select the column header with \Sexpr{}

2010-07-12 Thread Felipe Carrillo
Thanks for the quick reply Duncan.
I don't think I have explained myself well, I have a dataset named report and 
my column headers are run1,run2,run3,run4 and so on. 

I know how to access the data below those columns with \Sexpr{report[1,1]}  
\Sexpr{report[1,2]} and so on, but I can't access my column headers
with \Sexpr{} because I can't find the way to reference run1,run2,run3 and 
run4. 
Sorry if I am not explain myself really well.
 



- Original Message 
 From: Duncan Murdoch murdoch.dun...@gmail.com
 To: Felipe Carrillo mazatlanmex...@yahoo.com
 Cc: r-h...@stat.math.ethz.ch
 Sent: Mon, July 12, 2010 2:18:15 PM
 Subject: Re: [R] How to select the column header with \Sexpr{}
 
 On 12/07/2010 5:10 PM, Felipe Carrillo wrote:
  Hi:
  Since I work with a few different fish runs my column headers change 
everytime
  I start a new Year. I have been using \Sexpr{} for my row and columns and 
  now 
I am trying to use with my report column headers. \Sexpr{1,1} is row 1 column 
1,
  what can I use for headers? I tried \Sexpr{0,1} but sweave didn't like 
it..Thanks in advance
  for any hints
  
 
 \Sexpr takes an R expression, and inserts the first element of the result 
 into 
your text.  Using just 0,1 (not including the quotes) is not a valid R 
expression.
 
 You need to use paste() or some other function to construct the label you 
 want 
to put in place, e.g. \Sexpr{paste(0,1,sep=,)} will give you 0,1.
 
 Duncan Murdoch
 




__
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] How to select the column header with \Sexpr{}

2010-07-12 Thread Felipe Carrillo
I had tried that earlier and didn't work either, I probably have \Sexpr in the 
wrong place. See example:
Column one header gets blank:

\documentclass[11pt]{article}
\usepackage{longtable,verbatim,ctable}
\usepackage{longtable,pdflscape}
\usepackage{fmtcount,hyperref}
\usepackage{fullpage} 
\title{United States}
\begin{document}
\setkeys{Gin}{width=1\textwidth} 
\maketitle
echo=F,results=hide=
report - structure(list(Date = c(3/12/2010, 3/13/2010, 3/14/2010, 
3/15/2010), Run1 = c(33 (119 ? 119), n (0 ? 0), 893 (110 ? 146), 
140 (111 ? 150)), Run2 = c(33 (71 ? 71), n (0 ? 0), 
337 (67 ? 74), 140 (68 ? 84)), Run3 = c(890 (32 ? 47), 
n (0 ? 0), 10,602 (32 ? 52), 2,635 (34 ? 66)), Run4 = c(0 ( ? ), 
n (0 ? 0), 0 ( ? ), 0 ( ? )), Run4 = c(0 ( ? ), n (0 ? 0), 
0 ( ? ), 0 ( ? ))), .Names = c(ID_Date, Run1, Run2, 
Run3, Run4, Run5), row.names = c(NA, 4L), class = data.frame)
require(stringr)
report - t(apply(report, 1, function(x) {str_replace(x, \\?, -)}))
#report
#latex(report,file=)
@
\begin{landscape}
\begin{table}[!tbp]
 \begin{center}
 \begin{tabular}{ll}\hline\hline
\multicolumn{1}{c}{\Sexpr{names(report)[1]}}   # Using \Sexpr here
\multicolumn{1}{c}{Run1}
\multicolumn{1}{c}{Run2}
\multicolumn{1}{c}{Run3}
\multicolumn{1}{c}{Run4}
\multicolumn{1}{c}{Run5}\tabularnewline
\hline
13/12/201033 (119 ? 119)33 (71 ? 71)890 (32 ? 47)0 ( ? )0 ( ? 
)\tabularnewline
23/13/2010n (0 ? 0)n (0 ? 0)n (0 ? 0)n (0 ? 0)n (0 ? 0)\tabularnewline
33/14/2010893 (110 ? 146)337 (67 ? 74)10,602 (32 ? 52)0 ( ? )0 ( ? 
)\tabularnewline
43/15/2010140 (111 ? 150)140 (68 ? 84)2,635 (34 ? 66)0 ( ? )0 ( ? 
)\tabularnewline
\hline
\end{tabular}
\end{center}
\end{table}
\end{landscape}
\end{document}
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: David Winsemius dwinsem...@comcast.net
 To: Felipe Carrillo mazatlanmex...@yahoo.com
 Cc: Duncan Murdoch murdoch.dun...@gmail.com; r-h...@stat.math.ethz.ch
 Sent: Mon, July 12, 2010 3:14:49 PM
 Subject: Re: [R] How to select the column header with \Sexpr{}
 
 
 On Jul 12, 2010, at 5:45 PM, Felipe Carrillo wrote:
 
  Thanks for the quick reply Duncan.
  I don't think I have explained myself well, I have a dataset named report 
and
  my column headers are run1,run2,run3,run4 and so on.
  
  I know how to access the data below those columns with \Sexpr{report[1,1]} 
  \Sexpr{report[1,2]} and so on, but I can't access my column headers
  with \Sexpr{} because I can't find the way to reference run1,run2,run3 and 
run4.
  Sorry if I am not explain myself really well.
 
 Wouldn't this just be:
 
 \Sexpr{names(report)}  # ?  or perhaps you want specific items in that vector?
 
 Sexpr{names(report)[1]}, Sexpr{names(report)[2]}, etc
 
 --David.
  
  
  
  
  - Original Message 
  From: Duncan Murdoch murdoch.dun...@gmail.com
  To: Felipe Carrillo mazatlanmex...@yahoo.com
  Cc: r-h...@stat.math.ethz.ch
  Sent: Mon, July 12, 2010 2:18:15 PM
  Subject: Re: [R] How to select the column header with \Sexpr{}
  
  On 12/07/2010 5:10 PM, Felipe Carrillo wrote:
  Hi:
  Since I work with a few different fish runs my column headers change
  everytime
  I start a new Year. I have been using \Sexpr{} for my row and columns and 
now
  I am trying to use with my report column headers. \Sexpr{1,1} is row 1 
column 1,
  what can I use for headers? I tried \Sexpr{0,1} but sweave didn't like
  it..Thanks in advance
  for any hints
  
  
  \Sexpr takes an R expression, and inserts the first element of the result 
into
  your text.  Using just 0,1 (not including the quotes) is not a valid R
  expression.
  
  You need to use paste() or some other function to construct the label you 
want
  to put in place, e.g. \Sexpr{paste(0,1,sep=,)} will give you 0,1.
  
  Duncan Murdoch
  
  
  
  
  
  __
  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.
 
 David Winsemius, MD
 West Hartford, CT
 
 


  
__
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] R2wd- how to open an existing document

2010-07-06 Thread Felipe Carrillo
Hi:
How can one open an existing word document with wdGet()
I am getting an error message when trying to open it like this: 
wdGet(filename=myDoc.doc,path=c/mydata)
Looking at Tal Galili's website example it appears that double backslashes
are used but i tried it and didn't work either. Thanks
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA




__
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] R2wd- how to open an existing document

2010-07-06 Thread Felipe Carrillo
Hi:
I am doing exactly that but I still get the following error message:

Error in if (!(tmp[[ActiveDocument]][[Name]] == filename)) 
tmp$Open(paste(path,  : 

  argument is of length zero

 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: Erik Iverson er...@ccbr.umn.edu
 To: Felipe Carrillo mazatlanmex...@yahoo.com
 Cc: r-h...@stat.math.ethz.ch
 Sent: Tue, July 6, 2010 3:03:31 PM
 Subject: Re: [R] R2wd- how to open an existing document
 
 Having no clue about the specifics here, but what about:
 
 wdGet(filename = myDoc.doc, path = c:/mydata)
 
 You are leaving out what didn't work means.
 
 What error are you receiving?
 
 Felipe Carrillo wrote:
  Hi:
  How can one open an existing word document with wdGet()
  I am getting an error message when trying to open it like this: 
wdGet(filename=myDoc.doc,path=c/mydata)
  Looking at Tal Galili's website example it appears that double backslashes
  are used but i tried it and didn't work either. Thanks
   Felipe D. Carrillo
  Supervisory Fishery Biologist
  Department of the Interior
  US Fish  Wildlife Service
  California, USA
  
  
  
  
  __
  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-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] predict newdata question

2010-06-26 Thread Felipe Carrillo
Thanks Bill, that worked great!!
 
 You ask:

# How can I use predict here, 'newdata' 
 crashes
predict(m1,newdata=wolf$predicted);wolf # it doesn't work

To 
 use predict() you need to give a fitted model object (here m1) and a *data 
 frame* to specify the values of the predictors for which you want 
 predictions.  Here wolf$predicted is not a data frame, it is a 
 vector.

What I think you want is

pv - predict(m1, newdata = 
 wolf)

That will get you linear predictors.  To get probabilities you 
 need to say so as

probs - predict(m1, newdata = wolf, type = 
 response)

You can put these back into the data frame if you wish, 
 e.g.

wolf - within(wold, {
    lpreds - 
 predict(m1, wolf)
    probs - predict(m1, wolf, type = 
 response)
})

Now if you look at 

head(wolf)

you will 
 see two extra columns.


-Original Message-
From:  ymailto=mailto:r-help-boun...@r-project.org; 
 href=mailto:r-help-boun...@r-project.org;r-help-boun...@r-project.org 
 [mailto: 
 href=mailto:r-help-boun...@r-project.org;r-help-boun...@r-project.org] On 
 Behalf Of Felipe Carrillo
Sent: Saturday, 26 June 2010 10:35 AM
To:  ymailto=mailto:r-h...@stat.math.ethz.ch; 
 href=mailto:r-h...@stat.math.ethz.ch;r-h...@stat.math.ethz.ch
Subject: 
 [R] predict newdata question

Hi:
I am using a subset of the below 
 dataset to predict PRED_SUIT for
the whole dataset but I am having trouble 
 with 'newdata'. The model
was created with 153 records and want to predict 
 for 208 records. 

[lots of stuff 
 omitted]

wolf$prob99-(exp(wolf$predicted))/(1+exp(wolf$predicted))
head(wolf);dim(wolf)
   
 # How can I use predict here, 'newdata' 
 crashes
 predict(m1,newdata=wolf$predicted);wolf  # it doesn't 
 work

Thanks for any hints


Felipe D. Carrillo
Supervisory 
 Fishery Biologist
Department of the Interior
US Fish  Wildlife 
 Service
California, 
 USA




__
 ymailto=mailto:R-help@r-project.org; 
 href=mailto:R-help@r-project.org;R-help@r-project.org mailing list
 href=https://stat.ethz.ch/mailman/listinfo/r-help; target=_blank 
 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-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] predict newdata question

2010-06-26 Thread Felipe Carrillo

 Thanks Bill, that worked great!!
 
 You ask:

# How can I use 
 predict here, 'newdata' 
 
 crashes
predict(m1,newdata=wolf$predicted);wolf # it doesn't work

To 
 
 use predict() you need to give a fitted model object (here m1) and a 
 *data 
 frame* to specify the values of the predictors for which you want 
 
 predictions.  Here wolf$predicted is not a data frame, it is a 
 
 vector.

What I think you want is

pv - predict(m1, newdata = 
 
 wolf)

That will get you linear predictors.  To get probabilities 
 you 
 need to say so as

probs - predict(m1, newdata = wolf, 
 type = 
 response)

You can put these back into the data frame if 
 you wish, 
 e.g.

wolf - within(wold, {
    lpreds - 
 
 predict(m1, wolf)
    probs - predict(m1, wolf, type = 
 
 response)
})

Now if you look at 

head(wolf)

you will 
 
 see two extra columns.


-Original Message-
From: 
  ymailto=mailto: 
  href=mailto:r-help-boun...@r-project.org;r-help-boun...@r-project.org 
 
 href=mailto: 
 href=mailto:r-help-boun...@r-project.org;r-help-boun...@r-project.org 
 ymailto=mailto:r-help-boun...@r-project.org; 
 href=mailto:r-help-boun...@r-project.org;r-help-boun...@r-project.org 
 
 [mailto: href=mailto: ymailto=mailto:r-help-boun...@r-project.org; 
 href=mailto:r-help-boun...@r-project.org;r-help-boun...@r-project.org 
 ymailto=mailto:r-help-boun...@r-project.org; 
 href=mailto:r-help-boun...@r-project.org;r-help-boun...@r-project.org] On 
 
 Behalf Of Felipe Carrillo
Sent: Saturday, 26 June 2010 10:35 
 AM
To:  ymailto=mailto: 
href=mailto:r-h...@stat.math.ethz.ch;r-h...@stat.math.ethz.ch 
 
 href=mailto: 
 href=mailto:r-h...@stat.math.ethz.ch;r-h...@stat.math.ethz.ch 
 ymailto=mailto:r-h...@stat.math.ethz.ch; 
 href=mailto:r-h...@stat.math.ethz.ch;r-h...@stat.math.ethz.ch
Subject: 
 
 [R] predict newdata question

Hi:
I am using a subset of the 
 below 
 dataset to predict PRED_SUIT for
the whole dataset but I am 
 having trouble 
 with 'newdata'. The model
was created with 153 
 records and want to predict 
 for 208 records. 

[lots of stuff 
 
 
 omitted]

wolf$prob99-(exp(wolf$predicted))/(1+exp(wolf$predicted))
head(wolf);dim(wolf)
   
 
 # How can I use predict here, 'newdata' 
 
 crashes
 predict(m1,newdata=wolf$predicted);wolf  # it doesn't 
 
 work

Thanks for any hints


Felipe D. Carrillo
Supervisory 
 
 Fishery Biologist
Department of the Interior
US Fish  
 Wildlife 
 Service
California, 
 
 USA




__
 
 ymailto=mailto: href=mailto:R-help@r-project.org;R-help@r-project.org 
 
 href=mailto: href=mailto:R-help@r-project.org;R-help@r-project.org 
 ymailto=mailto:R-help@r-project.org; 
 href=mailto:R-help@r-project.org;R-help@r-project.org mailing list
 
 href= https://stat.ethz.ch/mailman/listinfo/r-help; target=_blank 
  href=https://stat.ethz.ch/mailman/listinfo/r-help; target=_blank 
 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.




__
 ymailto=mailto:R-help@r-project.org; 
 href=mailto:R-help@r-project.org;R-help@r-project.org mailing list
 href=https://stat.ethz.ch/mailman/listinfo/r-help; target=_blank 
 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-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] predict newdata question

2010-06-25 Thread Felipe Carrillo
Hi:
I am using a subset of the below dataset to predict PRED_SUIT for
the whole dataset but I am having trouble with 'newdata'. The model
was created with 153 records and want to predict for 208 records. 

wolf2 - structure(list(gridcell = c(367L, 444L, 533L, 587L, 598L, 609L, 
620L, 629L, 641L, 651L, 662L, 674L, 684L, 695L, 738L, 748L, 804L, 
805L, 872L, 919L, 929L, 938L, 950L, 958L, 966L, 975L, 976L, 985L, 
994L, 1006L, 1015L, 1019L, 1022L, 1025L, 1027L, 1028L, 1029L, 
1032L, 1040L, 1043L, 1050L, 1053L, 1061L, 1070L, 1074L, 1078L, 
1080L, 1082L, 1083L, 1084L, 1090L, 1095L, 1096L, 1099L, 1106L, 
1116L, 1124L, 1125L, 1130L, 1133L, 1134L, 1137L, 1138L, 1139L, 
1145L, 1150L, 1151L, 1154L, 1161L, 1162L, 1163L, 1171L, 1175L, 
1179L, 1181L, 1184L, 1188L, 1189L, 1193L, 1194L, 1199L, 1204L, 
1207L, 1214L, 1222L, 1231L, 1232L, 1241L, 1250L, 1256L, 1275L, 
1279L, 378L, 421L, 432L, 480L, 492L, 501L, 511L, 522L, 545L, 
555L, 566L, 575L, 705L, 716L, 728L, 760L, 774L, 785L, 794L, 816L, 
831L, 841L, 850L, 860L, 861L, 873L, 889L, 899L, 908L, 917L, 931L, 
933L, 942L, 944L, 954L, 963L, 971L, 986L, 988L, 996L, 997L, 1007L, 
1009L, 1014L, 1041L, 1052L, 1062L, 1064L, 1069L, 1107L, 1108L, 
1117L, 1120L, 1172L, 1216L, 1225L, 1239L, 1245L, 1265L, 1287L, 
1293L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 
14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 
27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 
40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 
53L, 54L, 55L), MAJOR_LC = c(42L, 42L, 42L, 42L, 42L, 42L, 42L, 
42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 51L, 
51L, 51L, 42L, 42L, 42L, 71L, 51L, 51L, 51L, 71L, 71L, 51L, 42L, 
71L, 42L, 51L, 51L, 42L, 51L, 42L, 51L, 42L, 51L, 51L, 51L, 42L, 
51L, 42L, 51L, 71L, 42L, 51L, 42L, 42L, 51L, 51L, 42L, 51L, 42L, 
42L, 51L, 51L, 51L, 71L, 51L, 42L, 51L, 42L, 51L, 71L, 42L, 51L, 
42L, 42L, 51L, 51L, 42L, 51L, 51L, 71L, 82L, 51L, 42L, 51L, 51L, 
42L, 82L, 83L, 51L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 
42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 
42L, 42L, 42L, 42L, 42L, 51L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 
42L, 42L, 42L, 51L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 
42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 71L, 
51L, 51L, 51L, 31L, 81L, 41L, 42L, 41L, 42L, 41L, 42L, 42L, 42L, 
42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 81L, 81L, 42L, 
42L, 42L, 51L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 42L, 
42L, 42L, 51L, 42L, 31L, 42L, 81L, 43L, 41L, 42L, 42L, 42L, 42L, 
42L, 42L, 42L, 42L, 42L, 42L), RD_DENSITY = c(1.046, 1.626, 2.356, 
1.912, 0.203, 0.049, 0.055, 1.96, 1.515, 0.361, 0.183, 0.022, 
1.702, 0.8, 1.356, 0.216, 0.509, 0.915, 0.689, 0.817, 0.93, 0.808, 
0.121, 0.026, 0.283, 1.256, 0.56, 0.881, 0.649, 1.074, 0.851, 
0.758, 0.375, 0.554, 1.111, 0.783, 1.113, 0.619, 0.587, 0.975, 
0.892, 0.162, 0.714, 1.582, 0.408, 0.227, 1.816, 1.586, 0.888, 
1.247, 2.016, 0.457, 0.816, 0.933, 0.894, 2.101, 0.091, 2.265, 
0.389, 0.343, 1.718, 0.738, 0.597, 1.098, 1.865, 1.082, 0.654, 
1.104, 0.43, 0.418, 0.164, 1.068, 0.708, 0.011, 1.61, 1.143, 
0.124, 2.039, 0.547, 0.794, 1.694, 0.526, 1.505, 0.861, 0.771, 
0.216, 1.018, 2.88, 0.892, 0.741, 0.437, 1.16, 0.966, 0.961, 
0.591, 2.052, 0.82, 0.638, 2.107, 3.082, 0.387, 0.716, 1.065, 
1.602, 0.93, 0.234, 0.257, 0.186, 0, 0.408, 0.914, 0.281, 0.019, 
0.13, 0.704, 0.305, 1.132, 0.347, 0, 0.252, 0.733, 0.925, 0.276, 
0.368, 0.596, 0.284, 0.158, 0.627, 0.719, 0.472, 0.264, 0.251, 
0.525, 0.231, 0.568, 0.204, 0.44, 0.466, 0.19, 0.134, 0.001, 
0.422, 0.2, 0.073, 0.528, 0, 0.42, 0.626, 0.121, 0.181, 1.324, 
1.265, 0.827, 11.611, 3.443, 5.382, 2.269, 3.677, 1.1, 4.876, 
0.003, 2.86, 2.375, 1.885, 0.044, 0.728, 1.314, 3.042, 0.469, 
0.248, 0.675, 1.91, 0.228, 4.058, 3.563, 0.801, 3.421, 0.515, 
1.945, 1.235, 1.999, 2.495, 1.193, 1.896, 1.689, 1.144, 1.028, 
0.858, 1.703, 4.009, 0.096, 1.85, 0.081, 0, 1.759, 5.549, 4.99, 
4.267, 1.792, 0.204, 2.144, 0.212, 9.263, 1.615, 3.502, 1.927, 
1.665, 2.17), WOLVES_99 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 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, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L), WOLVES_01 = c(0L, 1L, 1L, 0L, 0L, 
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 1L, 

Re: [R] Plotting Data on a Map

2010-06-23 Thread Felipe Carrillo
Hi:
I am practicing with the attached shapefile and was wondering
if I can get some help. Haven't used 'rgdal' and 'maptools' much
but it appears to be a great way bring map data into R.
Please take a look at the comments and let me know if I need to
explain better what I am trying to accomplish.

library(rgdal)
library(maptools)
library(ggplot2)
dsn=C:/Documents and Settings/fcarrillo/Desktop/Software/R Scripts
and Datasets/NCTC/Data Analisys II/Data 4 Data Analysis II March 2009-
March2010/Data
wolves.map - readOGR(dsn=dsn, layer=PNW_wolf_habitat_grid)
class(wolves.map)
dim(wolves.map)
head(wolves.map,1)
names(wolves.map)
gpclibPermit()
wolves.ds - fortify(wolves.map)
head(wolves.ds);tail(wolves.ds)
# Shapefile of 5 states
wolves.plot - ggplot(wolves.ds,aes(long,lat,group=group)) +
geom_polygon(colour='white',fill='lightblue')
wolves.plot
# How to show the state borders of Washington, Oregon, Idaho, Montana
and Wyoming on map?

# Subset from wolves to create a logistic regression model based on
WOLVES_99 and then apply to all the 5 states
# Remove the WOLVES_99 2(two value) and use one for presence and
zero for absence to end up with 153 records.
#wolfsub-subset(wolves,subset=!(WOLVES_99==2))
#wolfsub - subset(wolves.map,WOLVES_99!=2)
wolfsub - wolves.map[!wolves.map$WOLVES_99 %in% 2,];wolfsub
dim(wolfsub)
# 42 = Forest, 51 = Shrub,  81 = Agriculture
wolfsub$Forest-ifelse(wolfsub$MAJOR_LC==42,1,0)
wolfsub$Shrub-ifelse(wolfsub$MAJOR_LC==51,1,0)
wolfsub$Agriculture-ifelse(wolfsub$MAJOR_LC81,1,0)
names(wolfsub);dim(wolfsub)
# create the model
mod1-glm(WOLVES_99~RD_DENSITY+Forest+Shrub
+Agriculture,family=binomial,data=wolfsub)
summary(mod1)
wolfsub$pred99-fitted(mod1)
names(wolfsub)
#fitted(mod1)
wolfsub$pred99

# Add the wolfsub data to the map to see the map
wolfsub - fortify(wolfsub);names(wolfsub)
area_mod - wolves.plot + geom_polygon(data=wolfsub,aes(fill=))
#Want to fill by WOLVES_99 but is gone #after fortify
area_mod
#Not sure how to proceed from here to fit the 'mod1' model to all
#the 5 states.

 



From: Tom Hopper tomhop...@gmail.com
To: Felipe Carrillo mazatlanmex...@yahoo.com
Sent: Tue, June 22, 2010 9:40:19 PM
Subject: Re: Plotting Data on a Map

Felipe, 


I am just learning these tools, too, so it may be a good learning opportunity 
for both of us. Please send me the files and I will try to put it together and 
plot it.


Regards,


Tom


On Mon, Jun 21, 2010 at 11:57 PM, Felipe Carrillo mazatlanmex...@yahoo.com 
wrote:

Hi Tom:
I am just starting to use rgdal and maptools but I have a long way to go. I 
went to a training
a couple of weeks ago and the instructor showed us a csv file and a shapefile 
with wolf data from
a national park in the midwest. I am trying to put all of the csv data and 
some predicted data 
on a map using ggplot2 but I am stuck with it. I am just trying to do this 
example because I want to
see if I can apply this example to fish. Let me know if interested.


Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA




From: Tom Hopper tomhop...@gmail.com
To: ggpl...@googlegroups.com
Sent: Mon, June 21, 2010 2:27:14 PM
Subject: Re: Plotting Data on a Map


Hadley, 


Thank you!


I doing this, I've encountered an encountered and unexpected difference 
between the  graphs on my Mac and my Windows machines. It appears that there 
is a default setting different between the two programs.


Using the same commands on both Mac and Windows, I found that the polygon 
borders are plotted on the Mac, but not on Windows, so on the Mac I see the 
country borders, but on Windows I do not. On the Mac, it looks like the 
default for geom_polygon is something like size = 0.01, colour = gray50. 
On Windows, it's more like colour = alpha(gray50, 0), though in fact the 
visibility of polygon borders seems to be independent of both the size and 
colour settings.


Regards,


Tom


On Mon, Jun 21, 2010 at 3:00 AM, Hadley Wickham had...@rice.edu wrote:

Hi Tom,

Thanks for contribution! Ploting map data is never easy and its always
nice to see a success story.

Hadley


On Saturday, June 19, 2010, Tom Hopper tomhop...@gmail.com wrote:
 Well, it turns out that, in my haste to thank Fernando, I posted code 
 with some typos. I have also had a chance to test it on my Mac, and found 
 that fortify() was throwing an error (Error in nchar(ID) : invalid 
 multibyte string 1). I have added a call, currently commented out, to 
 Sys.setlocale() to fix this. I have tested the code below under R 2.11.1 
 on both Windows XP and Mac OS X 10.5.8, with the latest packages 
 installed. In fact, the plot looks better in the Mac Quartz window.


 Sorry for the previous errors.


 # Download electricity generation data from 
 http://tonto.eia.doe.gov/cfapps/ipdbproject/iedindex3.cfm?tid=2pid=2aid=12cid=syid=2004eyid=2008unit=BKWH


 # Download new map data from 
 http://thematicmapping.org/downloads/world_borders.php




 # Bring

Re: [R] Plotting Data on a Map

2010-06-23 Thread Felipe Carrillo
For some reason the shapefile can't get attached.
The shapefile is too large to put it in dput..Is there
another way to do this?



- Original Message 
 From: Felipe Carrillo mazatlanmex...@yahoo.com
 To: Tom Hopper tomhop...@gmail.com
 Cc: r-h...@stat.math.ethz.ch; ggpl...@googlegroups.com
 Sent: Wed, June 23, 2010 1:52:29 PM
 Subject: Re: [R] Plotting Data on a Map
 
 Hi:
I am practicing with the attached shapefile and was wondering
if I can 
 get some help. Haven't used 'rgdal' and 'maptools' much
but it appears to be 
 a great way bring map data into R.
Please take a look at the comments and let 
 me know if I need to
explain better what I am trying to 
 accomplish.

library(rgdal)
library(maptools)
library(ggplot2)
dsn=C:/Documents 
 and Settings/fcarrillo/Desktop/Software/R Scripts
and Datasets/NCTC/Data 
 Analisys II/Data 4 Data Analysis II March 2009-
March2010/Data
wolves.map 
 - readOGR(dsn=dsn, 
 layer=PNW_wolf_habitat_grid)
class(wolves.map)
dim(wolves.map)
head(wolves.map,1)
names(wolves.map)
gpclibPermit()
wolves.ds 
 - fortify(wolves.map)
head(wolves.ds);tail(wolves.ds)
# Shapefile of 5 
 states
wolves.plot - ggplot(wolves.ds,aes(long,lat,group=group)) 
 +
geom_polygon(colour='white',fill='lightblue')
wolves.plot
# How to 
 show the state borders of Washington, Oregon, Idaho, Montana
and Wyoming on 
 map?

# Subset from wolves to create a logistic regression model based 
 on
WOLVES_99 and then apply to all the 5 states
# Remove the WOLVES_99 
 2(two value) and use one for presence and
zero for absence to end up with 
 153 records.
#wolfsub-subset(wolves,subset=!(WOLVES_99==2))
#wolfsub 
 - subset(wolves.map,WOLVES_99!=2)
wolfsub - 
 wolves.map[!wolves.map$WOLVES_99 %in% 2,];wolfsub
dim(wolfsub)
# 42 = 
 Forest, 51 = Shrub,  81 = 
 Agriculture
wolfsub$Forest-ifelse(wolfsub$MAJOR_LC==42,1,0)
wolfsub$Shrub-ifelse(wolfsub$MAJOR_LC==51,1,0)
wolfsub$Agriculture-ifelse(wolfsub$MAJOR_LC81,1,0)
names(wolfsub);dim(wolfsub)
# 
 create the 
 model
mod1-glm(WOLVES_99~RD_DENSITY+Forest+Shrub
+Agriculture,family=binomial,data=wolfsub)
summary(mod1)
wolfsub$pred99-fitted(mod1)
names(wolfsub)
#fitted(mod1)
wolfsub$pred99

# 
 Add the wolfsub data to the map to see the map
wolfsub - 
 fortify(wolfsub);names(wolfsub)
area_mod - wolves.plot + 
 geom_polygon(data=wolfsub,aes(fill=))
#Want to fill by WOLVES_99 but is 
 gone #after fortify
area_mod
#Not sure how to proceed from here to fit the 
 'mod1' model to all
#the 5 states.

 



From: Tom 
 Hopper  href=mailto:tomhop...@gmail.com;tomhop...@gmail.com
To: Felipe 
 Carrillo  href=mailto:mazatlanmex...@yahoo.com;mazatlanmex...@yahoo.com
Sent: 
 Tue, June 22, 2010 9:40:19 PM
Subject: Re: Plotting Data on a 
 Map

Felipe, 


I am just learning these 
 tools, too, so it may be a good learning opportunity for both of us. Please 
 send 
 me the files and I will try to put it together and plot 
 it.


Regards,


Tom


On 
 Mon, Jun 21, 2010 at 11:57 PM, Felipe Carrillo  
 ymailto=mailto:mazatlanmex...@yahoo.com; 
 href=mailto:mazatlanmex...@yahoo.com;mazatlanmex...@yahoo.com 
 wrote:

Hi Tom:
I am just starting to use rgdal and 
 maptools but I have a long way to go. I went to a training
a couple 
 of weeks ago and the instructor showed us a csv file and a shapefile with 
 wolf 
 data from
a national park in the midwest. I am trying to put all of 
 the csv data and some predicted data 
on a map using ggplot2 but I am 
 stuck with it. I am just trying to do this example because I want 
 to
see if I can apply this example to fish. Let me know if 
 interested.


Felipe D. 
 Carrillo
Supervisory Fishery Biologist
Department of the 
 Interior
US Fish  Wildlife Service
California, 
 USA




From: Tom 
 Hopper  href=mailto:tomhop...@gmail.com;tomhop...@gmail.com
To: 
  href=mailto:ggpl...@googlegroups.com;ggpl...@googlegroups.com
Sent: 
 Mon, June 21, 2010 2:27:14 PM
Subject: Re: Plotting Data on a 
 Map


Hadley, 
 


Thank 
 you!


I doing this, I've 
 encountered an encountered and unexpected difference between the  graphs on 
 my 
 Mac and my Windows machines. It appears that there is a default setting 
 different between the two 
 programs.


Using the same commands 
 on both Mac and Windows, I found that the polygon borders are plotted on the 
 Mac, but not on Windows, so on the Mac I see the country borders, but on 
 Windows 
 I do not. On the Mac, it looks like the default for geom_polygon is something 
 like size = 0.01, colour = gray50. On Windows, it's more like colour = 
 alpha(gray50, 0), though in fact the visibility of polygon borders seems to 
 be 
 independent of both the size and colour 
 settings.


Regards,


Tom


On 
 Mon, Jun 21, 2010 at 3:00 AM, Hadley Wickham  
 ymailto=mailto:had...@rice.edu; 
 href=mailto:had...@rice.edu;had...@rice.edu 
 wrote:

Hi 
 Tom,

Thanks for contribution! Ploting map 
 data is never easy and its always
nice to see a success 
 story.

Hadley


On 
 Saturday, June 19, 2010, Tom Hopper  
 href=mailto:tomhop

[R] rgdal-maptools

2010-06-23 Thread Felipe Carrillo
The shapefile data can be downloaded from the link below:
download all the six files and save them on your working directory
and make sure the dsn path is set to where the files are saved.
My shapefiles are saved on C:/Data.


https://secure.filesanywhere.com/fs/v.aspx?v=897263875a6472a99baa

Hi:
I am practicing with the attached shapefile and was wondering if I can 
get some help. Haven't used 'rgdal' and 'maptools' much but it appears to be 
a great way to bring map data into R.
Please take a look at the comments and let me know if I need to
explain better what I am trying to accomplish.

library(rgdal)
library(maptools)
library(ggplot2)
dsn=C:/Data
wolves.map - readOGR(dsn=dsn, layer=PNW_wolf_habitat_grid)
class(wolves.map)
dim(wolves.map)
head(wolves.map,1)
names(wolves.map)
gpclibPermit()
wolves.ds - fortify(wolves.map)
head(wolves.ds);tail(wolves.ds)
# Shapefile of 5 states
wolves.plot - ggplot(wolves.ds,aes(long,lat,group=group)) +
geom_polygon(colour='white',fill='lightblue')
wolves.plot
# How to show the state borders of Washington, Oregon, Idaho, Montana and 
Wyoming on map?

# Subset from wolves to create a logistic regression model based on WOLVES_99 
and then apply to all the 5 states
# Remove the WOLVES_99 2(two value) and use one for presence and zero for 
absence to end up with 153 records.

wolfsub - wolves.map[!wolves.map$WOLVES_99 %in% 2,];wolfsub
dim(wolfsub)
# 42 = Forest, 51 = Shrub,  81 = Agriculture
wolfsub$Forest-ifelse(wolfsub$MAJOR_LC==42,1,0)
wolfsub$Shrub-ifelse(wolfsub$MAJOR_LC==51,1,0)
wolfsub$Agriculture-ifelse(wolfsub$MAJOR_LC81,1,0)
names(wolfsub);dim(wolfsub)

# Create the model
mod1-glm(WOLVES_99~RD_DENSITY+Forest+Shrub+Agriculture,family=binomial,data=wolfsub)
summary(mod1)
wolfsub$pred99-fitted(mod1)
names(wolfsub)
#fitted(mod1)
wolfsub$pred99

# Add the wolfsub data to the map to see the map
wolfsub - fortify(wolfsub);names(wolfsub) 
area_mod - wolves.plot + geom_polygon(data=wolfsub,aes(fill=)) #Want to 
fill by WOLVES_99 but is gone #after fortify
area_mod
#Not sure how to proceed from here to fit the 'mod1' model to all the 5 states.

 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA




__
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] Date conversion

2010-06-11 Thread Felipe Carrillo
Thanks Joshua, I wanted to use some kind of date format in latex
but ended up using exactly what you and Marc suggested.
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: Joshua Wiley jwiley.ps...@gmail.com
 To: Felipe Carrillo mazatlanmex...@yahoo.com
 Cc: r-h...@stat.math.ethz.ch
 Sent: Thu, June 10, 2010 1:18:27 PM
 Subject: Re: [R] Date conversion
 
 Hello Felipe,

Is this what you want?

format(as.Date(3/10/10, 
 format=%m/%d/%y), %B %d, %Y)

Josh

On Thu, Jun 10, 2010 at 8:29 
 AM, Felipe Carrillo
 href=mailto:mazatlanmex...@yahoo.com;mazatlanmex...@yahoo.com 
 wrote:
 Hi:
 Can't find a way to convert from shortDate to 
 LongDate format. I got:
 3/10/10 that I want to convert to March 10, 
 2010. I am using:

 \documentclass[11pt]{article}
 
 \usepackage{longtable,verbatim}
 \usepackage{ctable}
 
 \usepackage{datetime}
 \title{my title}
 \begin{document}
 
   % Convert date
 \dddate\3/10/10
 
 end{document}

 My report is changing every two weeks so I will 
 eventually
 use \Sexpr{report[1,1]} to grab the date from column 1, row 
 1
 of a table named report but right now my report has the date
 
 formated as described above (3/10/10).


 Felipe D. 
 Carrillo
 Supervisory Fishery Biologist
 Department of the 
 Interior
 US Fish  Wildlife Service
 California, 
 USA




 
 __
  ymailto=mailto:R-help@r-project.org; 
 href=mailto:R-help@r-project.org;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.




-- 
 
Joshua Wiley
Senior in Psychology
University of California, 
 Riverside
http://www.joshuawiley.com/




__
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] Patch for legend.position={left,top,bottom} in ggplot2

2010-06-10 Thread Felipe Carrillo
Hi:
I downloaded the patch, how do I incorporate it to my current version of 
ggplot2?
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: Hadley Wickham had...@rice.edu
 To: Karsten Loesing karsten.loes...@gmx.net
 Cc: r-help@r-project.org r-help@r-project.org; Hadley Wickham 
 had...@rice.edu
 Sent: Thu, June 10, 2010 5:52:43 AM
 Subject: Re: [R] Patch for legend.position={left,top,bottom} in ggplot2
 
 Cool! Thanks Karsten. If you send me a github pull request I'll incorporate 
 it.
Hadley

On Thursday, June 10, 2010, Karsten Loesing  
ymailto=mailto:karsten.loes...@gmx.net; 
 href=mailto:karsten.loes...@gmx.net;karsten.loes...@gmx.net 
 wrote:
 Hi everyone,

 here's the same patch as a new 
 branch on GitHub.

  
  http://github.com/kloesing/ggplot2/commit/a25e4fbfa4017ed1

 
 Best,
 --Karsten


 On 6/7/10 3:39 PM, Karsten 
 Loesing wrote:
 Hi Hadley and everyone,

 
 here's a patch for ggplot2 that fixes the behavior of
 
 opts(legend.position={left,top,bottom}). If you try the following 
 code
 in an unmodified ggplot2

 options(warn = 
 -1)
 suppressPackageStartupMessages(library(ggplot2))
 
 data - data.frame(
     x = c(1, 2, 3, 4, 5, 6),
     
 y = c(2, 3, 4, 3, 4, 5),
     colour = c(TRUE, TRUE, TRUE, FALSE, 
 FALSE, FALSE))
 ggplot(data, aes(x = x, y = y, colour = colour)) 
 +
     geom_line() + opts(title = title, legend.position = 
 right)
 ggplot(data, aes(x = x, y = y, colour = colour)) 
 +
     geom_line() + opts(title = title, legend.position = 
 left)
 ggplot(data, aes(x = x, y = y, colour = colour)) 
 +
     geom_line() + opts(title = title, legend.position = 
 top)
 ggplot(data, aes(x = x, y = y, colour = colour)) 
 +
     geom_line() + opts(title = title, legend.position = 
 bottom)

 you'll see that plots 2 to 4 are 
 broken.

 I think I located the bug in 
 surround_viewports() where the graphical
 elements are placed into 
 the grid. If we increment all rows and columns
 of the graphical 
 elements for positions left, top, and bottom by
 1, those 
 graphs look sane again. I assume that a new first row and
 column 
 were added at some point in the development, but only the
 parameters 
 for the default position right were adjusted. Here's the 
 patch:


 --- ggplot2-orig2     2010-06-07 
 13:14:35.0 +0200
 +++ ggplot2   2010-06-07 15:22:33.0 
 +0200
 @@ -7003,27 +7003,27 @@
      )
    } 
 else if (position == left) {
      viewports - 
 vpList(
 -      vp(panels, 2, 3),
 -     
  vp(legend_box, 2, 1),
 -      vp(ylabel, 2, 2),
 -   
    vp(xlabel, 3, 3),
 -      vp(title, 1, 3)
 +     
  vp(panels, 3, 4),
 +      vp(legend_box, 3, 2),
 +   
    vp(ylabel, 3, 3),
 +      vp(xlabel, 4, 4),
 +     
  vp(title, 2, 4)
      )
    } else if (position == 
 top) {
      viewports - vpList(
 -     
  vp(panels, 3, 2),
 -      vp(legend_box, 2, 2),
 -   
    vp(ylabel, 3, 1),
 -      vp(xlabel, 4, 2),
 -     
  vp(title, 1, 2)
 +      vp(panels, 4, 3),
 +     
  vp(legend_box, 3, 3),
 +      vp(ylabel, 4, 2),
 +   
    vp(xlabel, 5, 3),
 +      vp(title, 2, 3)
     
  )
    } else if (position == bottom) {
      viewports 
 - vpList(
 -      vp(panels, 2, 2),
 -     
  vp(legend_box, 4, 2),
 -      vp(ylabel, 2, 1),
 -   
    vp(xlabel, 3, 2),
 -      vp(title, 1, 2)
 +     
  vp(panels, 3, 3),
 +      vp(legend_box, 5, 3),
 +   
    vp(ylabel, 3, 2),
 +      vp(xlabel, 4, 3),
 +     
  vp(title, 2, 3)
      )
    } else {
     
  viewports - vpList(


 Best,
 
 --Karsten




-- 
Assistant Professor / 
 Dobelman Family Junior Chair
Department of Statistics / Rice 
 University
http://had.co.nz/

__
 ymailto=mailto:R-help@r-project.org; 
 href=mailto:R-help@r-project.org;R-help@r-project.org mailing list
 href=https://stat.ethz.ch/mailman/listinfo/r-help; target=_blank 
 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-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] Latex: Date Format conversion

2010-06-10 Thread Felipe Carrillo
Hi:
Can't find a way to convert from shortDate to LongDate format. I got:
3/10/10 that I want to convert to March 10, 2010. I am using:

\documentclass[11pt]{article}
\usepackage{longtable,verbatim}
\usepackage{ctable}
\usepackage{datetime}
\title{my title}
\begin{document}
  % Convert date
\dddate\3/10/10
end{document} 

My report is changing every two weeks so I will eventually 
use \Sexpr{report[1,1]} to grab the date from column 1, row 1
of a table named report but right now my report has the date
formated as described above (3/10/10).
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA




__
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] Date conversion

2010-06-10 Thread Felipe Carrillo
Hi:
Can't find a way to convert from shortDate to LongDate format. I got:
3/10/10 that I want to convert to March 10, 2010. I am using:

\documentclass[11pt]{article}
\usepackage{longtable,verbatim}
\usepackage{ctable}
\usepackage{datetime}
\title{my title}
\begin{document}
  % Convert date
\dddate\3/10/10
end{document} 

My report is changing every two weeks so I will eventually 
use \Sexpr{report[1,1]} to grab the date from column 1, row 1
of a table named report but right now my report has the date
formated as described above (3/10/10).

 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA




__
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] Latex: Date Format conversion

2010-06-10 Thread Felipe Carrillo

 Marc:
My report is done every two weeks and is created automatically.
I click a command button on an Excel form and it runs a .rnw script 
in R creating a latex dynamic report. Excel sends 15 days of data
to R, eg: 6/1/10 to 6/15/10. Right above my report I usually write the range
of the report manually, something like Report from 6/1/10 - 6/15/10 so
I want to see if latex can select that range of dates dynamically because my
report dates are constantly changing. I would like latex to look at the 
beginning 
and last date of my report and fill out the dates on the fly. I can do this 
easily with
the following: 
Report from \Sexpr{report[1,1]}  -  \Sexpr{report[1,15]} 
and it prints the correct values:
Report from 6/1/10 - 6/15/10
But I want those values formatted like this:
Report from June 01, 2010 - June 15, 2010
I am looking for a latex command to convert the dates, something like this 
pseudo-code:
Report from \longdate\Sexpr{report[1,1]}  -  \longdate\Sexpr{report[1,15]} 
Where long date will be the format that converts 6/1/10 to June 01, 2010
Thanks for helping.



- Original Message 
 From: Marc Schwartz marc_schwa...@me.com
 To: Felipe Carrillo mazatlanmex...@yahoo.com
 Cc: r-h...@stat.math.ethz.ch
 Sent: Thu, June 10, 2010 8:40:16 AM
 Subject: Re: [R] Latex: Date Format conversion
 
 On Jun 10, 2010, at 10:21 AM, Felipe Carrillo wrote:

 Hi:
 
 Can't find a way to convert from shortDate to LongDate format. I got:
 
 3/10/10 that I want to convert to March 10, 2010. I am using:
 
 
 \documentclass[11pt]{article}
 \usepackage{longtable,verbatim}
 
 \usepackage{ctable}
 \usepackage{datetime}
 \title{my 
 title}
 \begin{document}
  % Convert date
 
 \dddate\3/10/10
 end{document} 
 
 My report is 
 changing every two weeks so I will eventually 
 use \Sexpr{report[1,1]} 
 to grab the date from column 1, row 1
 of a table named report but 
 right now my report has the date
 formated as described above 
 (3/10/10).

Felipe,

Do you want the report to be dated for the day 
 that it is processed by latex?

If so, just use:

  
 \today

to generate the current date at run time in the long format that 
 you have above.

HTH,

Marc Schwartz




__
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] Latex: Date Format conversion

2010-06-10 Thread Felipe Carrillo
Marc:
Thanks for reinforcing that, I was just trying to go that route. 
It seems to be  simpler to import the dataset and just grab the first and
last date from it and then format it. Thanks again.
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: Marc Schwartz marc_schwa...@me.com
 To: Felipe Carrillo mazatlanmex...@yahoo.com
 Cc: r-h...@stat.math.ethz.ch
 Sent: Thu, June 10, 2010 10:19:40 AM
 Subject: Re: [R] Latex: Date Format conversion
 
 Felipe,

I would not do the processing in TeX, but do it in R and then 
 pass the results to the \Sexpr{}'s.

If I am correctly understanding the 
 process flow, put the following R code chunk before the point where you need 
 to 
 output the formatted dates:

results=hide

  
 START - format(as.Date(report[1, 1], %m/%d/%y), %B %d, %Y)
  END 
 - format(as.Date(report[1, 15], %m/%d/%y), %B %d, 
 %Y)

@


Then have the following in the document body:


 Report from \Sexpr{START}  -  \Sexpr{END]} 


To take an 
 example of your two dates below:

 format(as.Date(6/1/10, 
 %m/%d/%y), %B %d, %Y)
[1] June 01, 2010

 
 format(as.Date(6/15/10, %m/%d/%y), %B %d, %Y)
[1] June 15, 
 2010


See ?as.Date for more information.

Note, that one 
 possible complication is that if the dates in Excel are stored as dates and 
 not 
 as text, that is they are exported as numbers to R, pay close attention to 
 the 
 last example in ?as.Date. If this is the case, then you will need to modify 
 the 
 R code chunk above as per the examples on the help page, to correctly convert 
 the numbers to R's date type and then format the result as you 
 desire.

HTH,

Marc

On Jun 10, 2010, at 11:37 AM, Felipe 
 Carrillo wrote:

 
  Marc:
 My report is done every 
 two weeks and is created automatically.
 I click a command button on an 
 Excel form and it runs a .rnw script 
 in R creating a latex dynamic 
 report. Excel sends 15 days of data
 to R, eg: 6/1/10 to 6/15/10. Right 
 above my report I usually write the range
 of the report manually, 
 something like Report from 6/1/10 - 6/15/10 so
 I want to see if latex 
 can select that range of dates dynamically because my
 report dates are 
 constantly changing. I would like latex to look at the beginning 
 and 
 last date of my report and fill out the dates on the fly. I can do this 
 easily 
 with
 the following: 
 Report from \Sexpr{report[1,1]}  - 
  \Sexpr{report[1,15]} 
 and it prints the correct values:
 
 Report from 6/1/10 - 6/15/10
 But I want those values formatted like 
 this:
 Report from June 01, 2010 - June 15, 2010
 I am looking for 
 a latex command to convert the dates, something like this pseudo-code:
 
 Report from \longdate\Sexpr{report[1,1]}  -  
 \longdate\Sexpr{report[1,15]} 
 Where long date will be the format that 
 converts 6/1/10 to June 01, 2010
 Thanks for helping.
 




__
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] cumsum function with data frame

2010-06-03 Thread Felipe Carrillo
You can also use ddply from the plyr package:

library(plyr)
Data - read.table(textConnection(variable    Year  value
EC01    2005    5
EC01    2006    10
AAO1    2005  2
AAO1  2006  4),header=T)
Data
ddply(Data,.(variable),summarise,Year=Year,value=value,CUMSUM=cumsum(value))
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: Joris Meys jorism...@gmail.com
 To: n.via...@libero.it n.via...@libero.it
 Cc: r-help@r-project.org
 Sent: Thu, June 3, 2010 9:26:17 AM
 Subject: Re: [R] cumsum function with data frame
 
 See ?split and ?unsplit.

Data - 
 read.table(textConnection(variable        Year    
   value
EC01            2005    
     5
EC01            2006  
       10
AAO1            
 2005          2
AAO1        
   2006          4),header=T)

Datalist 
 -split(Data,Data$variable)
resultlist - 
 lapply(Datalist,function(x){
    x$cumul - 
 cumsum(x$value)
    return(x)
})
result - 
 unsplit(resultlist,Data$variable)
result

  variable Year value 
 cumul
1    EC01 2005    5    5
2  
   EC01 2006    10    15
3    AAO1 
 2005    2    2
4    AAO1 2006    
 4    6

On a side note: I've used this construction now for a 
 number of problems.
Some could be better solved using more specific functions 
 (e.g. ave() for
adding a column with means for example). I'm not sure however 
 this is the
most optimal approach to applying a function to subsets of a 
 dataframe and
adding the result of that function as an extra variable. 
 Anybody care to
elaborate on how the R masters had it in 
 mind?

Cheers
Joris

On Thu, Jun 3, 2010 at 5:58 PM,  ymailto=mailto:n.via...@libero.it; 
 href=mailto:n.via...@libero.it;n.via...@libero.it  
 ymailto=mailto:n.via...@libero.it; 
 href=mailto:n.via...@libero.it;n.via...@libero.itwrote:


 
 Dear list,
 I have a problem with the cumsum function.
 I have a 
 data frame like the following one
 variable        
 Year      value
 EC01          
   2005        5

 EC01    
         2006        10

 
 AAO1            2005        
   2

 AAO1          2006  
         4
 what I would like to obtain is
 
 variable        Year      value  
 cumsum


 EC01            
 2005        5          
 5


 EC01            
 2006        10        
 15


 AAO1            
 2005          2          
   2


 AAO1          
 2006          4          
   6


 if I use the by function or the aggregate 
 function the result is a list or
 something else, what I want is a data 
 frame as I showed above...
 anyone knows how to get it???
 THANKS 
 A LOT





        
 [[alternative HTML version deleted]]

 
 __
  ymailto=mailto:R-help@r-project.org; 
 href=mailto:R-help@r-project.org;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.




-- 
Joris Meys
Statistical 
 Consultant

Ghent University
Faculty of Bioscience 
 Engineering
Department of Applied mathematics, biometrics and process 
 control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 
 87
 href=mailto:joris.m...@ugent.be;joris.m...@ugent.be
---
Disclaimer 
 : http://helpdesk.ugent.be/e-maildisclaimer.php

    
 [[alternative HTML version 
 deleted]]

__
 ymailto=mailto:R-help@r-project.org; 
 href=mailto:R-help@r-project.org;R-help@r-project.org mailing list
 href=https://stat.ethz.ch/mailman/listinfo/r-help; target=_blank 
 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-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] cumsum function with data frame

2010-06-03 Thread Felipe Carrillo
Better yet, is shorter using tranform instead of summarise:
Data - read.table(textConnection(variable    Year  value
EC01    2005    5
EC01    2006    10
AAO1    2005  2
AAO1  2006  4),header=T)

ddply(Data,.(variable),transform,CUMSUM=cumsum(value))
 



- Original Message 
 From: Felipe Carrillo mazatlanmex...@yahoo.com
 To: Joris Meys jorism...@gmail.com; n.via...@libero.it 
 n.via...@libero.it
 Cc: r-help@r-project.org
 Sent: Thu, June 3, 2010 11:28:58 AM
 Subject: Re: [R] cumsum function with data frame
 
 You can also use ddply from the plyr package:

library(plyr)
Data - 
 read.table(textConnection(variable    Year  value
EC01    
 2005    5
EC01    2006    10
AAO1    2005  
 2
AAO1  2006  
 4),header=T)
Data
ddply(Data,.(variable),summarise,Year=Year,value=value,CUMSUM=cumsum(value))
 
Felipe 
 D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US 
 Fish  Wildlife Service
California, USA



- Original 
 Message 
 From: Joris Meys  ymailto=mailto:jorism...@gmail.com; 
 href=mailto:jorism...@gmail.com;jorism...@gmail.com
 To:  ymailto=mailto:n.via...@libero.it; 
 href=mailto:n.via...@libero.it;n.via...@libero.it  
 ymailto=mailto:n.via...@libero.it; 
 href=mailto:n.via...@libero.it;n.via...@libero.it
 Cc:  ymailto=mailto:r-help@r-project.org; 
 href=mailto:r-help@r-project.org;r-help@r-project.org
 Sent: Thu, 
 June 3, 2010 9:26:17 AM
 Subject: Re: [R] cumsum function with data 
 frame
 
 See ?split and ?unsplit.

Data - 
 
 read.table(textConnection(variable        Year    
   value
EC01      
       2005    
     5
EC01            2006  
       10
AAO1  
           
 2005          2
AAO1        
   2006          
 4),header=T)

Datalist 
 
 -split(Data,Data$variable)
resultlist - 
 
 lapply(Datalist,function(x){
    x$cumul - 
 cumsum(x$value)
  
   return(x)
})
result - 
 
 unsplit(resultlist,Data$variable)
result

  variable Year value 
 
 cumul
1    EC01 2005    5    5
2  
   EC01 2006    10    
 15
3    AAO1 
 2005    2    2
4    AAO1 2006    
 4    
 6

On a side note: I've used this construction now for a 
 number 
 of problems.
Some could be better solved using more specific functions 
 
 (e.g. ave() for
adding a column with means for example). I'm not 
 sure however 
 this is the
most optimal approach to applying a 
 function to subsets of a 
 dataframe and
adding the result of that 
 function as an extra variable. 
 Anybody care to
elaborate on how the 
 R masters had it in 
 mind?

Cheers
Joris

On Thu, Jun 3, 
 2010 at 5:58 PM,  ymailto=mailto: 
 href=mailto:n.via...@libero.it;n.via...@libero.it 
 
 href=mailto: href=mailto:n.via...@libero.it;n.via...@libero.it 
 ymailto=mailto:n.via...@libero.it; 
 href=mailto:n.via...@libero.it;n.via...@libero.it  
 ymailto=mailto: href=mailto:n.via...@libero.it;n.via...@libero.it 
 
 href=mailto: href=mailto:n.via...@libero.it;n.via...@libero.it 
 ymailto=mailto:n.via...@libero.it; 
 href=mailto:n.via...@libero.it;n.via...@libero.itwrote:


 
 
 Dear list,
 I have a problem with the cumsum function.
 I 
 have a 
 data frame like the following one
 variable        
 
 Year      value
 EC01          
   2005        
 5

 EC01    
         2006        10

 
 
 AAO1            2005        
   2

 AAO1          
 2006  
         4
 what I would like to obtain is
 
 
 variable        Year      value  
 cumsum


 EC01    
         
 2005        5          
 5


 EC01  
           
 2006        10        
 15


 
 AAO1            
 2005          2          
   
 2


 AAO1          
 2006          4          
 
   6


 if I use the by function or the aggregate 
 
 function the result is a list or
 something else, what I want is 
 a data 
 frame as I showed above...
 anyone knows how to get 
 it???
 THANKS 
 A 
 LOT





        
 
 [[alternative HTML version deleted]]

 
 
 __
  ymailto=mailto: ymailto=mailto:R-help@r-project.org; 
 href=mailto:R-help@r-project.org;R-help@r-project.org 
 
 href=mailto: href=mailto:R-help@r-project.org;R-help@r-project.org 
 ymailto=mailto:R-help@r-project.org; 
 href=mailto:R-help@r-project.org;R-help@r-project.org mailing list
 
 
   target=_blank 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.




-- 
Joris Meys
Statistical 
 
 Consultant

Ghent University
Faculty of Bioscience 
 
 Engineering
Department of Applied mathematics, biometrics and process 
 
 control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 
 59 
 87
 href=mailto: href=mailto:joris.m...@ugent.be;joris.m...@ugent.be 
 ymailto=mailto:joris.m...@ugent.be; 
 href=mailto:joris.m...@ugent.be;joris.m...@ugent.be
---
Disclaimer 
 
 : http://helpdesk.ugent.be/e-maildisclaimer.php

Re: [R] Put two plots side by side

2010-05-31 Thread Felipe Carrillo
Two different ways:
library(ggplot2)
x=5
size=50
A=data.frame(X=sample(x, size, replace=T), Y=sample(x, size, 
replace=T),a=rep(1:2,each=25));A
# Facetting
qplot(X,Y,data=A) + geom_jitter(position=position_jitter(width=.03)) + 
facet_grid(.~a)
# Or with vp
p=qplot(X, Y, data=A) + geom_jitter(position=position_jitter(width=.03))
ggsave(p, file='main.png')
p1=qplot(X, Y, data=A) + geom_jitter(position=position_jitter(width=.3))
ggsave(p1, file='main2.png')
vport - function(x, y)
viewport(layout.pos.row=x, layout.pos.col=y)
grid.newpage()
pushViewport(viewport(layout=grid.layout(1,2)))
print(p, vp=vport(1,1))
print(p1, vp=vport(1,2))
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: Erik Iverson er...@ccbr.umn.edu
 To: Peng Yu pengyu...@gmail.com
 Cc: ggplot2 ggpl...@googlegroups.com
 Sent: Sun, May 30, 2010 7:45:22 PM
 Subject: Re: Put two plots side by side
 
 
 
 I want to put the above two plots side by side (essentially, 
 to mimic
 par(mfrow=c(1,2)) in the traditional graphic system). Is there 
 a
 convenient way to do so in ggplot2?
 

Yes.

My 
 understanding is that you need to create use grid functions to do this. You 
 can 
 create a viewport with a layout (using grid.layout) and then print the 
 ggplot2 
 objects using the vp argument.  I don't know if there is a ggplot2 
 abstraction for this idea.

-- You received this message because you are 
 subscribed to the ggplot2 mailing list.
Please provide a reproducible 
 example: http://gist.github.com/270442

To post: email  ymailto=mailto:ggpl...@googlegroups.com; 
 href=mailto:ggpl...@googlegroups.com;ggpl...@googlegroups.com
To 
 unsubscribe: email ggplot2+ 
 href=mailto:unsubscr...@googlegroups.com;unsubscr...@googlegroups.com
More 
 options: http://groups.google.com/group/ggplot2




__
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] Can not save plot to png file correctly

2010-05-31 Thread Felipe Carrillo
You can save as png like this too:

library(ggplot2)
data=data.frame(
  X=sample(10,1000,replace=T)
  , Y=letters[1:10])
png(mypng.png)
qplot(X, data=data, geom='histogram') + facet_wrap( ~ Y)
dev.off()
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: Peng Yu pengyu...@gmail.com
 To: ggplot2 ggpl...@googlegroups.com
 Sent: Mon, May 31, 2010 12:20:12 PM
 Subject: Can not save plot to png file correctly
 
 library(ggplot2)

data=data.frame(
  
 X=sample(10,1000,replace=T)
  , Y=letters[1:10]
  
 )

p=qplot(X, data=data, geom='histogram') + facet_wrap( ~ Y)
save(p, 
 file='error.png')

The above qplot work properly if I don't plot it to a 
 file. But if I
plot it to a png file, the png file is always corrupted. Would 
 you
please let me know what is wrong?

-- 
 
Regards,
Peng

-- 
You received this message because you are 
 subscribed to the ggplot2 mailing list.
Please provide a reproducible 
 example: http://gist.github.com/270442

To post: email  ymailto=mailto:ggpl...@googlegroups.com; 
 href=mailto:ggpl...@googlegroups.com;ggpl...@googlegroups.com
To 
 unsubscribe: email ggplot2+ 
 href=mailto:unsubscr...@googlegroups.com;unsubscr...@googlegroups.com
More 
 options: http://groups.google.com/group/ggplot2




__
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] Can not save plot to png file correctly

2010-05-31 Thread Felipe Carrillo
With ggsave the graph windows pops up but using:
png(mypng.png)
qplot(X, data=data, geom='histogram') + facet_wrap( ~ Y)
dev.off()
The graph is saved in the background
Is there a way to hide the graph window when
using ggsave?

You can save as png like this too:

library(ggplot2)
data=data.frame(
  X=sample(10,1000,replace=T)
  , Y=letters[1:10])
png(mypng.png)
qplot(X, data=data, geom='histogram') + facet_wrap( ~ Y)
dev.off()

 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA




__
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] Problem with Sweave not recognising \Sexpr{}

2010-05-25 Thread Felipe Carrillo
 I had the same problem before and I think it has something to do with the 
R2HTML package. 
To take care of that problem simply sweave your rnw file like this:
Sweave(yourfile.Rnw,syntax=SweaveSyntaxNoweb)
and try Sexpr{} again.
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: Mike White mikewhite@btconnect.com
 To: r-help@r-project.org r-help@r-project.org
 Sent: Tue, May 25, 2010 2:25:36 AM
 Subject: [R] Problem with Sweave not recognising \Sexpr{}
 
 I am trying to run the Sweave example at 
 http://www.stat.uni-muenchen.de/~leisch/Sweave/Sweave-Rnews-2002-3.pdf
However, 
 the \Sexpr{} code is not being evaluated, although the actual R code within 
 the 
 {} runs ok in R.
Below is part of the resulting .tex file.  Can anyone 
 help identify the cause? I am using R 2.10.1 on Windows XP.

Consider the 
 \texttt{cats} regression example from Venables \ Ripley
(1997). The data 
 frame contains measurements of heart and body weight
of \Sexpr{nrow(cats)} 
 cats (\Sexpr{sum(cats$Sex==F)} female,
\Sexpr{sum(cats$Sex==M)} 
 male).

Thanks
Mike 
 White

__
 ymailto=mailto:R-help@r-project.org; 
 href=mailto:R-help@r-project.org;R-help@r-project.org mailing list
 href=https://stat.ethz.ch/mailman/listinfo/r-help; target=_blank 
 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-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] Dataframe to word, using R2wd

2010-05-15 Thread Felipe Carrillo
Hi:
Just adding on to this question...Is it a way to add footnotes to tables with 
R2wd? I started using this nice package
about a month ago and is one of the things that I can't figure out yet..
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: Tal Galili tal.gal...@gmail.com
 To: Jeremy Miles jeremy.mi...@gmail.com
 Cc: r-help@r-project.org
 Sent: Sat, May 15, 2010 1:03:12 AM
 Subject: Re: [R] Dataframe to word, using R2wd
 
 Hi Jeremy,

1) This is not the command to use on data.frames, it is: 
 wdTable
2) There is a slightly newer version of R2wd, that (for now) can only 
 be
downloaded 
 here:
http://www.r-statistics.com/2010/05/exporting-r-output-to-ms-word-with-r2wd-an-example-session/
(That 
 posts also offers a step by step on 
 R2wd)

Cheers,
Tal



Contact
Details:---
Contact 
 me:  href=mailto:tal.gal...@gmail.com;tal.gal...@gmail.com |  
 972-52-7275845
Read me:  href=http://www.talgalili.com;www.talgalili.com (Hebrew) |  
target=_blank 
 href=http://www.biostatistics.co.il;www.biostatistics.co.il (Hebrew) 
 |
 href=http://www.r-statistics.com;www.r-statistics.com 
 (English)
--




On 
 Sat, May 15, 2010 at 8:46 AM, Jeremy Miles  
 ymailto=mailto:jeremy.mi...@gmail.com; 
 href=mailto:jeremy.mi...@gmail.com;jeremy.mi...@gmail.comwrote:

 
 Hi All,

 I'm trying to use R2wd to send a dataframe to 
 Word.  The dataframe
 isn't huge - 300 rows, 12 variables, although 
 it has some long strings
 in it.

 Using:

 
 wdTable(format(myDataFrame))

 or

 
 wdTable(myDataFrame)

 Produces a very complex table, which Word 
 struggles to process and
 layout.  (I can't work out what the table 
 is - it seems to be nested
 tables. Converting to text gives one long 
 column.)

 Using

 
 wdBody(MyDataFrame)

 or

 
 wdNormal(MyDataFrame)

 Is there another way to use R2wd to send 
 the dataframe to word?

 Thanks (in advance)

 
 Jeremy




 --
 Jeremy Miles
 
 Psychology Research Methods Wiki:  
 href=http://www.researchmethodsinpsychology.com;www.researchmethodsinpsychology.com

 
 __
  ymailto=mailto:R-help@r-project.org; 
 href=mailto:R-help@r-project.org;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.


    [[alternative HTML version 
 deleted]]

__
 ymailto=mailto:R-help@r-project.org; 
 href=mailto:R-help@r-project.org;R-help@r-project.org mailing list
 href=https://stat.ethz.ch/mailman/listinfo/r-help; target=_blank 
 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-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.


  1   2   3   >