Comments (11)
Hmmm - I just wrote a set of automated tests and it all looks ok (f7ba8cd). Could you please try the latest development version and see if you still have problems?
from roxygen.
On 10/24/2011 8:42 PM, hadley wickham wrote:
Hmmm - I just wrote a set of automated tests and it all looks ok (f7ba8cd). Could you please try the latest development version and see if you still have problems?
I tried with v2.1 roxygen2 which was at link and it did not work. See
attached .r and the created .rd file. If I take away quotes it works.
--jeff
\name{EnvironCovariates}
\alias{EnvironCovariates}
\title{Extracts environmental covariate data for SMI Zc analysis
: by extracting data from ACCESS database and creating a series of
anomaly summaries for sea surface temperature(SST), upwelling index (UWI) and
multivariate ENSO index (MEI).}
\arguments{
\item{average.years}{years to use for average for anomaly
creationccc}
\item{fdir}{directory containing environmental.data.mdb}
\item{sites}{SST sites to be used in SST averaging (from
create.SST.anomalies) 1) ESB, 2)WSB, 3)PtArg, 4)PtSM,
5)PtSL, 6)CSM, 7)MB, 8)PtReyes}
}
\value{
dataframe with rows as years from 1987 to last year in
data and the columns are:
time,OcttoJuneSSTAnomalies,ApriltoJuneSSTAnomalies,JulytoJuneSSTAnomalies,
OcttoJuneUWI33Anomalies, ApriltoJuneUWI33Anomalies,
JulytoJuneUWI33Anomalies, OcttoJuneUWI36Anomalies,
ApriltoJuneUWI36Anomalies, JulytoJuneUWI36Anomalies,
OcttoJuneMEI, ApriltoJuneMEI, JulytoJuneMEI
}
\description{
Extracts environmental covariate data for SMI Zc analysis
: by extracting data from ACCESS database and creating a
series of anomaly summaries for sea surface
temperature(SST), upwelling index (UWI) and multivariate
ENSO index (MEI).
}
\author{
Jeff Laake
}
#' Extracts environmental covariate data for SMI Zc analysis
#' : by extracting data from ACCESS database and creating a series of
#' anomaly summaries for sea surface temperature(SST), upwelling index (UWI) and
#' multivariate ENSO index (MEI).
#'
#' @export
#' @import CIPinnipedAnalysis
#' @param average.years years to use for average for anomaly creationccc
#' @param fdir directory containing environmental.data.mdb
#' @param sites SST sites to be used in SST averaging (from create.SST.anomalies)
#' 1) ESB, 2)WSB, 3)PtArg, 4)PtSM, 5)PtSL, 6)CSM, 7)MB, 8)PtReyes
#' @return dataframe with rows as years from 1987 to last year in data and the columns are:
#' time,OcttoJuneSSTAnomalies,ApriltoJuneSSTAnomalies,JulytoJuneSSTAnomalies,
#' OcttoJuneUWI33Anomalies, ApriltoJuneUWI33Anomalies, JulytoJuneUWI33Anomalies,
#' OcttoJuneUWI36Anomalies, ApriltoJuneUWI36Anomalies, JulytoJuneUWI36Anomalies,
#' OcttoJuneMEI, ApriltoJuneMEI, JulytoJuneMEI
#' @author Jeff Laake
"EnvironCovariates"<-function(average.years=c(1994:1996,1998:2008),fdir="",sites=1:5)
{
SST Anomalies
if(fdir=="")fdir=system.file(package = "CIPinnipedAnalysis")
anomalies=create.SST.anomalies(average.years,fdir=fdir,store=FALSE)
fpath=file.path(fdir,"environmental.data.mdb")
connection=odbcConnectAccess(fpath)
SSTAnomalies=t(apply(anomalies[,,sites],c(2,1),mean,na.rm=TRUE))
SSTAnomalies[is.nan(SSTAnomalies)]=NA
nyears=nrow(SSTAnomalies)
OcttoJuneSSTAnomalies=rowMeans(cbind(SSTAnomalies[1:(nyears-1),c("Oct","Nov","Dec")],SSTAnomalies[2:nyears,c("Jan","Feb","Mar","Apr","May","June")]),na.rm=TRUE)
ApriltoJuneSSTAnomalies=rowMeans(SSTAnomalies[,c("Apr","May","June")],na.rm=TRUE)
names(ApriltoJuneSSTAnomalies)=as.character(as.numeric(names(ApriltoJuneSSTAnomalies))-1)
JulytoJuneSSTAnomalies=rowMeans(cbind(SSTAnomalies[1:(nyears-1),c("July","Aug","Sept","Oct","Nov","Dec")],SSTAnomalies[2:nyears,c("Jan","Feb","Mar","Apr","May","June")]),na.rm=TRUE)
UpwellingIndex for 33N & 36N
UWI=sqlFetch(connection,"UWIAnomaly")
UWI=UWI[order(UWI$Year,UWI$Month),]
UWI=tapply(UWI$UWI,list(UWI$Year,UWI$Month,UWI$Location),unique)
minyear=min(as.numeric(dimnames(UWI)[[1]]))
maxyear=max(as.numeric(dimnames(UWI)[[1]]))
nyears=maxyear-minyear+1
OcttoJuneUWI33Anomalies=rowMeans(cbind(UWI[1:(nyears-1),as.character(10:12),1],UWI[2:nyears,as.character(1:6),1]),na.rm=TRUE)
ApriltoJuneUWI33Anomalies=rowMeans(UWI[,as.character(4:6),1],na.rm=TRUE)[1:nyears]
names(ApriltoJuneUWI33Anomalies)=as.character(as.numeric(names(ApriltoJuneUWI33Anomalies))-1)
JulytoJuneUWI33Anomalies=rowMeans(cbind(UWI[1:(nyears-1),as.character(7:12),1],UWI[2:nyears,as.character(1:6),1]),na.rm=TRUE)
OcttoJuneUWI36Anomalies=rowMeans(cbind(UWI[1:(nyears-1),as.character(10:12),2],UWI[2:nyears,as.character(1:6),2]),na.rm=TRUE)
ApriltoJuneUWI36Anomalies=rowMeans(UWI[,as.character(4:6),2],na.rm=TRUE)
names(ApriltoJuneUWI36Anomalies)=as.character(as.numeric(names(ApriltoJuneUWI36Anomalies))-1)
JulytoJuneUWI36Anomalies=rowMeans(cbind(UWI[1:(nyears-1),as.character(7:12),2],UWI[2:nyears,as.character(1:6),2]),na.rm=TRUE)
Multivariate ENSO Index - lagged by 3 months
MEI=sqlFetch(connection,"MEI")
minyear=min(MEI$Year)
maxyear=max(MEI$Year)
nyears=maxyear-minyear+1
MEI=tapply(MEI$MEI,list(MEI$Year,MEI$Month),unique)
OcttoJuneMEI=rowMeans(cbind(MEI[1:(nyears-1),as.character(7:12)],MEI[2:nyears,as.character(1:3)]),na.rm=TRUE)
ApriltoJuneMEI=rowMeans(MEI[,as.character(1:3)],na.rm=TRUE)
names(ApriltoJuneMEI)=as.character(as.numeric(names(ApriltoJuneMEI))-1)
JulytoJuneMEI=rowMeans(cbind(MEI[1:(nyears-1),as.character(4:12)],MEI[2:nyears,as.character(1:3)]),na.rm=TRUE)
Create dataframe with values from 1987:2009
maxyear=max(as.numeric(names(JulytoJuneMEI)))
time is meant to match the beginning year of a survival interval from time to time+1; that is why the
April-to-June is set as the previous year to model survival of pup cohort born in the previous year
envcovdf=data.frame(time=1987:maxyear,
OcttoJuneSSTAnomalies=OcttoJuneSSTAnomalies[as.character(1987:maxyear)],
ApriltoJuneSSTAnomalies=ApriltoJuneSSTAnomalies[as.character(1987:maxyear)],
JulytoJuneSSTAnomalies=JulytoJuneSSTAnomalies[as.character(1987:maxyear)],
OcttoJuneUWI33Anomalies=OcttoJuneUWI33Anomalies[as.character(1987:maxyear)],
ApriltoJuneUWI33Anomalies=ApriltoJuneUWI33Anomalies[as.character(1987:maxyear)],
JulytoJuneUWI33Anomalies=JulytoJuneUWI33Anomalies[as.character(1987:maxyear)],
OcttoJuneUWI36Anomalies=OcttoJuneUWI36Anomalies[as.character(1987:maxyear)],
ApriltoJuneUWI36Anomalies=ApriltoJuneUWI36Anomalies[as.character(1987:maxyear)],
JulytoJuneUWI36Anomalies=JulytoJuneUWI36Anomalies[as.character(1987:maxyear)],
OcttoJuneMEI=OcttoJuneMEI[as.character(1987:maxyear)],
ApriltoJuneMEI=ApriltoJuneMEI[as.character(1987:maxyear)],
JulytoJuneMEI=JulytoJuneMEI[as.character(1987:maxyear)]
)
odbcClose(connection)
return(envcovdf)
}
from roxygen.
Ok - should definitely be fixed now.
from roxygen.
On 10/25/2011 12:40 PM, hadley wickham wrote:
Ok - should definitely be fixed now.
That worked but now it is throwing in an odd character into the usage
regardless of whether I use quotes. See attached. --jeff
#' Extracts environmental covariate data for SMI Zc analysis
#' : by extracting data from ACCESS database and creating a series of
#' anomaly summaries for sea surface temperature(SST), upwelling index (UWI) and
#' multivariate ENSO index (MEI).
#'
#' @export
#' @import CIPinnipedAnalysis
#' @param average.years years to use for average for anomaly creation
#' @param fdir directory containing environmental.data.mdb
#' @param sites SST sites to be used in SST averaging (from create.SST.anomalies)
#' 1) ESB, 2)WSB, 3)PtArg, 4)PtSM, 5)PtSL, 6)CSM, 7)MB, 8)PtReyes
#' @return dataframe with rows as years from 1987 to last year in data and the columns are:
#' time,OcttoJuneSSTAnomalies,ApriltoJuneSSTAnomalies,JulytoJuneSSTAnomalies,
#' OcttoJuneUWI33Anomalies, ApriltoJuneUWI33Anomalies, JulytoJuneUWI33Anomalies,
#' OcttoJuneUWI36Anomalies, ApriltoJuneUWI36Anomalies, JulytoJuneUWI36Anomalies,
#' OcttoJuneMEI, ApriltoJuneMEI, JulytoJuneMEI
#' @author Jeff Laake
EnvironCovariates<-function(average.years=c(1994:1996,1998:2008),fdir="",sites=1:5)
{
SST Anomalies
if(fdir=="")fdir=system.file(package = "CIPinnipedAnalysis")
anomalies=create.SST.anomalies(average.years,fdir=fdir,store=FALSE)
fpath=file.path(fdir,"environmental.data.mdb")
connection=odbcConnectAccess(fpath)
SSTAnomalies=t(apply(anomalies[,,sites],c(2,1),mean,na.rm=TRUE))
SSTAnomalies[is.nan(SSTAnomalies)]=NA
nyears=nrow(SSTAnomalies)
OcttoJuneSSTAnomalies=rowMeans(cbind(SSTAnomalies[1:(nyears-1),c("Oct","Nov","Dec")],SSTAnomalies[2:nyears,c("Jan","Feb","Mar","Apr","May","June")]),na.rm=TRUE)
ApriltoJuneSSTAnomalies=rowMeans(SSTAnomalies[,c("Apr","May","June")],na.rm=TRUE)
names(ApriltoJuneSSTAnomalies)=as.character(as.numeric(names(ApriltoJuneSSTAnomalies))-1)
JulytoJuneSSTAnomalies=rowMeans(cbind(SSTAnomalies[1:(nyears-1),c("July","Aug","Sept","Oct","Nov","Dec")],SSTAnomalies[2:nyears,c("Jan","Feb","Mar","Apr","May","June")]),na.rm=TRUE)
UpwellingIndex for 33N & 36N
UWI=sqlFetch(connection,"UWIAnomaly")
UWI=UWI[order(UWI$Year,UWI$Month),]
UWI=tapply(UWI$UWI,list(UWI$Year,UWI$Month,UWI$Location),unique)
minyear=min(as.numeric(dimnames(UWI)[[1]]))
maxyear=max(as.numeric(dimnames(UWI)[[1]]))
nyears=maxyear-minyear+1
OcttoJuneUWI33Anomalies=rowMeans(cbind(UWI[1:(nyears-1),as.character(10:12),1],UWI[2:nyears,as.character(1:6),1]),na.rm=TRUE)
ApriltoJuneUWI33Anomalies=rowMeans(UWI[,as.character(4:6),1],na.rm=TRUE)[1:nyears]
names(ApriltoJuneUWI33Anomalies)=as.character(as.numeric(names(ApriltoJuneUWI33Anomalies))-1)
JulytoJuneUWI33Anomalies=rowMeans(cbind(UWI[1:(nyears-1),as.character(7:12),1],UWI[2:nyears,as.character(1:6),1]),na.rm=TRUE)
OcttoJuneUWI36Anomalies=rowMeans(cbind(UWI[1:(nyears-1),as.character(10:12),2],UWI[2:nyears,as.character(1:6),2]),na.rm=TRUE)
ApriltoJuneUWI36Anomalies=rowMeans(UWI[,as.character(4:6),2],na.rm=TRUE)
names(ApriltoJuneUWI36Anomalies)=as.character(as.numeric(names(ApriltoJuneUWI36Anomalies))-1)
JulytoJuneUWI36Anomalies=rowMeans(cbind(UWI[1:(nyears-1),as.character(7:12),2],UWI[2:nyears,as.character(1:6),2]),na.rm=TRUE)
Multivariate ENSO Index - lagged by 3 months
MEI=sqlFetch(connection,"MEI")
minyear=min(MEI$Year)
maxyear=max(MEI$Year)
nyears=maxyear-minyear+1
MEI=tapply(MEI$MEI,list(MEI$Year,MEI$Month),unique)
OcttoJuneMEI=rowMeans(cbind(MEI[1:(nyears-1),as.character(7:12)],MEI[2:nyears,as.character(1:3)]),na.rm=TRUE)
ApriltoJuneMEI=rowMeans(MEI[,as.character(1:3)],na.rm=TRUE)
names(ApriltoJuneMEI)=as.character(as.numeric(names(ApriltoJuneMEI))-1)
JulytoJuneMEI=rowMeans(cbind(MEI[1:(nyears-1),as.character(4:12)],MEI[2:nyears,as.character(1:3)]),na.rm=TRUE)
Create dataframe with values from 1987:2009
maxyear=max(as.numeric(names(JulytoJuneMEI)))
time is meant to match the beginning year of a survival interval from time to time+1; that is why the
April-to-June is set as the previous year to model survival of pup cohort born in the previous year
envcovdf=data.frame(time=1987:maxyear,
OcttoJuneSSTAnomalies=OcttoJuneSSTAnomalies[as.character(1987:maxyear)],
ApriltoJuneSSTAnomalies=ApriltoJuneSSTAnomalies[as.character(1987:maxyear)],
JulytoJuneSSTAnomalies=JulytoJuneSSTAnomalies[as.character(1987:maxyear)],
OcttoJuneUWI33Anomalies=OcttoJuneUWI33Anomalies[as.character(1987:maxyear)],
ApriltoJuneUWI33Anomalies=ApriltoJuneUWI33Anomalies[as.character(1987:maxyear)],
JulytoJuneUWI33Anomalies=JulytoJuneUWI33Anomalies[as.character(1987:maxyear)],
OcttoJuneUWI36Anomalies=OcttoJuneUWI36Anomalies[as.character(1987:maxyear)],
ApriltoJuneUWI36Anomalies=ApriltoJuneUWI36Anomalies[as.character(1987:maxyear)],
JulytoJuneUWI36Anomalies=JulytoJuneUWI36Anomalies[as.character(1987:maxyear)],
OcttoJuneMEI=OcttoJuneMEI[as.character(1987:maxyear)],
ApriltoJuneMEI=ApriltoJuneMEI[as.character(1987:maxyear)],
JulytoJuneMEI=JulytoJuneMEI[as.character(1987:maxyear)]
)
odbcClose(connection)
return(envcovdf)
}
\name{EnvironCovariates}
\alias{EnvironCovariates}
\title{Extracts environmental covariate data for SMI Zc analysis
: by extracting data from ACCESS database and creating a series of
anomaly summaries for sea surface temperature(SST), upwelling index (UWI) and
multivariate ENSO index (MEI).}
\usage{
EnvironCovariates(average.years = c(1994:1996, 1998:2008),
fdir = "", sites = 1:5)
}
\arguments{
\item{average.years}{years to use for average for anomaly
creation}
\item{fdir}{directory containing environmental.data.mdb}
\item{sites}{SST sites to be used in SST averaging (from
create.SST.anomalies) 1) ESB, 2)WSB, 3)PtArg, 4)PtSM,
5)PtSL, 6)CSM, 7)MB, 8)PtReyes}
}
\value{
dataframe with rows as years from 1987 to last year in
data and the columns are:
time,OcttoJuneSSTAnomalies,ApriltoJuneSSTAnomalies,JulytoJuneSSTAnomalies,
OcttoJuneUWI33Anomalies, ApriltoJuneUWI33Anomalies,
JulytoJuneUWI33Anomalies, OcttoJuneUWI36Anomalies,
ApriltoJuneUWI36Anomalies, JulytoJuneUWI36Anomalies,
OcttoJuneMEI, ApriltoJuneMEI, JulytoJuneMEI
}
\description{
Extracts environmental covariate data for SMI Zc analysis
: by extracting data from ACCESS database and creating a
series of anomaly summaries for sea surface
temperature(SST), upwelling index (UWI) and multivariate
ENSO index (MEI).
}
\author{
Jeff Laake
}
from roxygen.
What's the odd character?
from roxygen.
On 10/25/2011 2:04 PM, hadley wickham wrote:
What's the odd character?
A capital A with a hat. You should be able to see it in the file I
attached to last message. I retyped the line in the function and it is
still there.
from roxygen.
Where is it? I wonder if it's an encoding problem, or if I'm just missing it.
from roxygen.
On 10/25/2011 2:15 PM, hadley wickham wrote:
Where is it? I wonder if it's an encoding problem, or if I'm just missing it.
average.years = c(1994:1996, 1998:2008),
from roxygen.
On 10/25/2011 2:15 PM, hadley wickham wrote:
Where is it? I wonder if it's an encoding problem, or if I'm just missing it.
It has something to do with the comma in c(1994:1996, 1998:2008). When I
take out the comma and text before or after, it works fine. It is not a
weird character in that part because if I retype it it is still there.
--jeff
from roxygen.
I think it's probably a non-breaking space that shouldn't be there - I've been adding them to get the usage wrapping correctly, but somehow I must be failing to remove it. I'll take a look in the next couple of days.
from roxygen.
On 10/26/2011 2:02 PM, hadley wickham wrote:
I think it's probably a non-breaking space that shouldn't be there - I've been adding them to get the usage wrapping correctly, but somehow I must be failing to remove it. I'll take a look in the next couple of days.
No hurry. Just thought I'd try a few things to see if it helped you
debug. --jeff
from roxygen.
Related Issues (20)
- Checking for missing S3 method exports hangs "forever" if you have large data objects in the package HOT 2
- @include tag does not handle line breaks
- Support for inheriting S4 slots
- The definition of multiple @field field_1,field_2 in R6 object shows a warning.
- Adding "#' @inheritDotParams system" to roxygen comments causes devtools::document() to fail
- R-CMD Check Warning - Missing link or links in documentation object
- roxygenise() has side-effect of attaching the package HOT 1
- uninformative error message if comments within a function are #' rather than #
- `reexports.Rd` re-writes `lubridate` functions re-exported HOT 1
- If no public methods provided and cloneable is `FALSE`, roxygen2 will failed
- Always resolve to "anchored" Rd xrefs
- @export generates a wrong NAMESPACE directive for S3 methods of generics imported from a different package
- Allow for width/height setting when specifying an external image via markdown
- Unnecessary escaping of `%` inside multi-line character in R
- Improve indentation/wrapping for named vectors/lists in `\usage{}` blocks
- FR: add `is_md` to `parse_file()`
- The language is not respected when running inline code
- Homegrown `local_reproducible_output()` should set `cli.hyperlink = FALSE`
- `\usage()` length
- Markdown support for definition lists?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from roxygen.