[R] Calling R (GAMM) from Fortran

2009-11-19 Thread Paul Warren Simonin


   Hello,

     I am currently working on a modeling project using Fortran to run  
large repetitive loops (many DO loops). As part of this process I  
would like to use a model fit in R and currently stored as an R  
object. This is a rather complex model, a GAMM, and I am curious  
whether there is a way to call this model from Fortran. I am not sure  
call is correct terminology, but I would basically like to use this  
GAMM to make a prediction as part of each DO loop. Is this possible? I  
have found instructions, etc. for calling Fortran from R but not vice  
versa.

     Thank you for any information or advice. General advice to  
address this situation is also welcome.

   Thanks again!

   -Paul Simonin

[[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] Create histogram from data matrix

2009-04-17 Thread Paul Warren Simonin

Hello!
  Thanks for reading this request for assistance. I have a question  
regarding creating a histogram-like figure from data that are not  
currently in the correct format for the hist command.
  Specifically, my data have been processed and are in a matrix with  
columns containing the variables of interest and separate columns  
containing the number of times this variable was observed (counts).  
This data frame/matrix is rather large (1600 rows), and there are  
multiple rows corresponding to the same variable level (e.g.,  
temperature=8, 5 observations in one row, then the next:  
temperature=8, 9 observations, and so on). In other words, the data  
are not one long vector R can read and plot as a histogram, nor are  
they condensed. My goal is to create a figure in which one axis is  
bins (e.g., temperature values) and the other is number of  
observations in this bin (e.g., number of organisms seen).
  My question is: Is there a way R can be told to read my data to  
create a plot like that I desire? So far I have tried several options,  
including bar plots with no success.


  If there is no way to do this with my data as the are currently  
arrange, is there an efficient way to re-arrange them?


Thanks a lot for any assistance or advice!

Sincerely,
Paul Simonin


--
Paul W. Simonin
Graduate Research Assistant, MS Program
Vermont Cooperative Fish and Wildlife Research Unit
The Rubenstein School of Environment and Natural Resources
University of Vermont
81 Carrigan Dr.
Burlington, VT 05405
Ph:802-656-3153

__
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] Create histogram from data matrix

2009-04-17 Thread Paul Warren Simonin

Thank you all for your advice.
  I have received some good tips, but it was suggested I write back  
with a small simulated data set to better illustrate my needs. So,  
currently my data frame looks something like:


ID (date)  Temperature  Number of fish
200706183   5   456
200706183   5   765
200706183   4   567
200706183   3   876
200706183   3   888
200706183   2   111
200706184   8   2345
200706184   8   654
200706184   8   7786
200706184   7   345
200706184   6   234
200706184   6   123


I need to create a plots for each ID (date) of the number of fish  
observed at each temperature. Obviously my data frame is much larger.  
These plots do not have to be in a specific histogram format, but it  
seems this may be appropriate.
Thanks for any additional advice as to how this may be done, either  
using plot commands or reformatting my data.


It seemed the ggplot2 options may be good but so far I have tried  
qplot with no success:


my most recent code looks like:

qplot(temp,number of fish, geom=histogram,binwidth=1)

I have tried various tweaks of this, but no success.

Thanks for any advice!
-Paul Simonin


Quoting stephen sefick ssef...@gmail.com:


It would be easier if you were to make a data frame of fake values to
illustrate your point, so that we could just copy it into an R session
and see if we can't get it to work.  So, a stab in the dark would to
look at ggplot2 specifically the hist argument in qplot and the
facets, the lattice package, or reshape to change the format of your
data. If you want me to fool around with it use dput and take a small
subset of your data or make up data to be able to be copied into an R
session.
hope that helps,

Stephen

On Fri, Apr 17, 2009 at 10:59 AM, Paul Warren Simonin
paul.simo...@uvm.edu wrote:

Hello!
 Thanks for reading this request for assistance. I have a question regarding
creating a histogram-like figure from data that are not currently in the
correct format for the hist command.
 Specifically, my data have been processed and are in a matrix with columns
containing the variables of interest and separate columns containing the
number of times this variable was observed (counts). This data frame/matrix
is rather large (1600 rows), and there are multiple rows corresponding to
the same variable level (e.g., temperature=8, 5 observations in one row,
then the next: temperature=8, 9 observations, and so on). In other words,
the data are not one long vector R can read and plot as a histogram, nor are
they condensed. My goal is to create a figure in which one axis is bins
(e.g., temperature values) and the other is number of observations in this
bin (e.g., number of organisms seen).
 My question is: Is there a way R can be told to read my data to create a
plot like that I desire? So far I have tried several options, including bar
plots with no success.

 If there is no way to do this with my data as the are currently arrange, is
there an efficient way to re-arrange them?

Thanks a lot for any assistance or advice!

Sincerely,
Paul Simonin


--
Paul W. Simonin
Graduate Research Assistant, MS Program
Vermont Cooperative Fish and Wildlife Research Unit
The Rubenstein School of Environment and Natural Resources
University of Vermont
81 Carrigan Dr.
Burlington, VT 05405
Ph:802-656-3153

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





--
Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis





--
Paul W. Simonin
Graduate Research Assistant, MS Program
Vermont Cooperative Fish and Wildlife Research Unit
The Rubenstein School of Environment and Natural Resources
University of Vermont
81 Carrigan Dr.
Burlington, VT 05405
Ph:802-656-3153

__
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 a data frame for plotting

2009-04-09 Thread Paul Warren Simonin

Hello,

  I have a question regarding how to subset/select parts of a data  
frame (matrix) in order to plot data associated only with this subset.  
Specifically I have a large data frame in which one column contains ID  
values (dates), and other columns contain data I would like to plot  
(temperature, light, etc.). I would like to break up this large matrix  
so as to plot data associated with specific ID values (dates)  
separately. I have learned of several commands that supposedly subset  
matrices in this manner and have tried the following code with no  
success:


200706183-subset(AllData, ID = 200706183)
200706183-gx.subset(AllData, ID == 200706183)
200706183-subset(x=AllData, AllData$ID = 200706183)
200706183-gx.subset(x=AllData, AllData$ID == 200706183)

In using this code my plan was to create smaller data frame objects  
which I could then plot. My first question, though, is whether this is  
the correct approach. Is there a more efficient way I can create plots  
conditional on certain criteria such as code = 200706183 ?
  If I do need to first create separate smaller data frames, how do I  
go about doing this? Am I missing something in the above commands?
  Any other advice is certainly welcome too, as I admit to being a  
bit new to R. Thank you very much for any answers, tips, suggestions,  
etc.!


Best wishes,
Paul Simonin

--
Paul W. Simonin
Graduate Research Assistant, MS Program
Vermont Cooperative Fish and Wildlife Research Unit
The Rubenstein School of Environment and Natural Resources
University of Vermont
81 Carrigan Dr.
Burlington, VT 05405
Ph:802-656-3153

__
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] Log transformation and -Inf values for use in glm()

2009-02-06 Thread Paul Warren Simonin

Hello,
  I am writing regarding log transformation of data in a single  
matrix column, and subsequent use of these data in a glm model fit. I  
have a data matrix in which I am using the log function to transform  
the values. This transformation results in -Inf values in some places,  
though. I then receive an error when this matrix is used in the glm  
function, and would like to know this can be avoided.
  I have attempted several methods already including the use of  
na.exclue commands in the glm statement:


DistributionT-glm(EarlyLn$yoyras~EarlyLn$temp,family=gaussian(link  
= identity),na.exclude)


I have also attempted to use the is.finite command:

EarlyLn$yoyras-EarlyLn[is.finite(EarlyLn$yoyras)==T,]

I know another option would be to use a type of find and replace  
command to remove entire rows of the matrix that contain 0's (before  
log transformation) or -Inf (after transformation), but I do not know  
how this is done.


Thank you for any advice or tips regarding conducting this  
transformation and feeding the data matrix into glm.


Sincerely,
Paul S.

__
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] Plot with x-axis dates

2009-02-06 Thread Paul Warren Simonin

Hello,
  I am attempting to create plots using two continuous variables and  
it seems I should be able to use the simple plot command. However,  
my x-axis values are dates, and I believe this could be the reason I  
am receiving error messages reading:


Error in Summary.factor(c(2L, 4L, 3L, 5L, 6L, 7L, 1L), na.rm = FALSE) :
  range not meaningful for factors

I have attempted to convert the date values to official dates within R  
and have done that successfully using the as.date function, but this  
did not help in the plots. So, how can one create plots in which the  
x-axis is date values? I know it would be possible to convert all my  
dates into a different linear scale (e.g., julian dates). However, I  
would like to complete this process as simply as possible.

Thank you for any advice or information.
Sincerely,
Paul S.

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