Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing usage with quotes around function name #41

Closed
jlaake opened this issue Sep 14, 2011 · 11 comments
Closed

Missing usage with quotes around function name #41

jlaake opened this issue Sep 14, 2011 · 11 comments

Comments

@jlaake
Copy link

@jlaake jlaake commented Sep 14, 2011

If your function statement looks something like

"myfunction" <- function(...)

Then roxygen doesn't create a usage section in the .Rd file. Removing the "" solves the problem.

@hadley
Copy link
Member

@hadley hadley commented Oct 25, 2011

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?

@hadley hadley closed this Oct 25, 2011
@jlaake
Copy link
Author

@jlaake jlaake commented Oct 25, 2011

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)

}

@hadley
Copy link
Member

@hadley hadley commented Oct 25, 2011

Ok - should definitely be fixed now.

@jlaake
Copy link
Author

@jlaake jlaake commented Oct 25, 2011

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
}

@hadley
Copy link
Member

@hadley hadley commented Oct 25, 2011

What's the odd character?

@jlaake
Copy link
Author

@jlaake jlaake commented Oct 25, 2011

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.

@hadley
Copy link
Member

@hadley hadley commented Oct 25, 2011

Where is it? I wonder if it's an encoding problem, or if I'm just missing it.

@jlaake
Copy link
Author

@jlaake jlaake commented Oct 25, 2011

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

@jlaake
Copy link
Author

@jlaake jlaake commented Oct 26, 2011

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

@hadley
Copy link
Member

@hadley hadley commented Oct 26, 2011

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.

@jlaake
Copy link
Author

@jlaake jlaake commented Oct 26, 2011

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

renozao pushed a commit to renozao/roxygen that referenced this issue Nov 3, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants