Re: [Rd] rbind on data.frame that contains a column that is also a data.frame

2010-08-06 Thread Nicholas L Crookston
OK...I'll put in my 2 cents worth. 

It seems to me that the problem is with this line:

b$a=a , where "s" is something other than a vector with
length equal to nrow(b).

I had no idea that a dataframe could hold a dataframe. It is not just
rbind(b,b) that fails, apply(b,1,sum) fails and so does plot(b). I'll 
bet other R commands fail as well.

My point of view is that a dataframe is a list of vectors
of equal length and various types (this is not exactly what the help
page says, but it is what it suggests to me). 

Hum, I wonder how much code is based on the idea that a dataframe can hold 
a
dataframe. 15 years of using R just isn't enough! But, I can say that not 
one
line of code I've written expects a dataframe to hold a dataframe.

> Hi,

> The following was already a topic on r-help, but after understanding 
what is
> going on, I think it fits better in r-devel.

> The problem is this:
> When a data.frame has another data.frame in it, rbind doesn't work well.
> Here is an example:
> --
> > a=data.frame(x=1:10,y=1:10)
> > b=data.frame(z=1:10)
> > b$a=a
> > b
> z a.x a.y
> 1   1   1   1
> 2   2   2   2
> 3   3   3   3
> 4   4   4   4
> 5   5   5   5
> 6   6   6   6
> 7   7   7   7
> 8   8   8   8
> 9   9   9   9
> 10 10  10  10
> > rbind(b,b)
> Error in `row.names<-.data.frame`(`*tmp*`, value = c("1", "2", "3", "4", 
 :
> duplicate 'row.names' are not allowed
> In addition: Warning message:
> non-unique values when setting 'row.names': ?1?, ?10?, ?2?, ?3?, ?4?, 
?5?,
> ?6?, ?7?, ?8?, ?9?
> --

> 
> Looking at the code of rbind.data.frame, the error comes from the
> lines:
> --
> xij <- xi[[j]]
> if (has.dim[jj]) {
> value[[jj]][ri, ] <- xij
> rownames(value[[jj]])[ri] <- rownames(xij)   # <--  problem is here
> }
> --
> if the rownames() line is dropped, all works well. What this line
> tries to do is to join the rownames of internal elements of the
> data.frames I try to rbind. So the result, in my case should have a
> column 'a', whose rownames are the rownames of the original column 'a'. 
It
> isn't totally clear to me why this is needed. When would a data.frame
> have different rownames on the inside vs. the outside?

> Notice also that rbind takes into account whether the rownames of the
> data.frames to be joined are simply 1:n, or they are something else.
> If they are 1:n, then the result will have rownames 1:(n+m). If not,
> then the rownames might be kept.

> I think, more consistent would be to replace the lines above with
> something like:
> if (has.dim[jj]) {
> value[[jj]][ri, ] <- xij
> rnj = rownames(value[[jj]])
> rnj[ri] = rownames(xij)
> rnj = make.unique(as.character(unlist(rnj)), sep = "")
> rownames(value[[jj]]) <- rnj
> }

> In this case, the rownames of inside elements will also be joined, but
> in case they overlap, they will be made unique - just as they are for
> the overall result of rbind. A side effect here would be that the
> rownames of matrices will also be made unique, which till now didn't
> happen, and which also doesn't happen when one rbinds matrices that
> have rownames. So it would be better to test above if we are dealing
> with a matrix or a data.frame.

> But most people don't have different rownames inside and outside.
> Maybe it would be best to add a flag as to whether you care or don't
> care about the rownames of internal data.frames...

> But maybe data.frames aren't meant to contain other data.frames?

> If instead I do
> b=data.frame( z=1:10, a=a)
> then rbind(b,b) works well. In this case the data.frame was converted to 
its
> columns. Maybe
> b$a = a
> should do the same?

> Michael
> --
> View this message in context: http://r.789695.n4.nabble.com/rbind-
> on-data-frame-that-contains-a-column-that-is-also-a-data-frame-
> tp2315682p2315682.html
> Sent from the R devel mailing list archive at Nabble.com.

> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Link to documentation in another package

2009-07-22 Thread Nicholas L Crookston
Try this:  \code{\link[ggplot2]{ggsave}}


Nicholas L. Crookston, Operations Research Analyst
Rocky Mountain Research Station
USDA Forest Service
1221 South Main, Moscow, ID 83843
Office: (208) 883-2317, FAX: (208) 883-2318
EMail: ncrooks...@fs.fed.us



"ONKELINX, Thierry"  
Sent by: r-devel-boun...@r-project.org
07/22/2009 06:55 AM

To

cc

Subject
[Rd] Link to documentation in another package





Dear all,

One of the functions that I wrote (ggsave.latex) extents the
functionality of a function (ggsave) in another package (ggplot2).
Instead of copying all the information I would like to create a link in
the helpfile of ggsave.latex to the helpfile of ggsave. I tried
\code{\link{ggsave}} and \code{\link{ggplot2::ggsave}}, but neither
worked. Both cases gave a 'missing link' warning.

Any suggestions?

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey


Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver 
weer
en binden het INBO onder geen enkel beding, zolang dit bericht niet 
bevestigd is
door een geldig ondertekend document. The views expressed in  this message
and any annex are purely those of the writer and may not be regarded as 
stating
an official position of INBO, as long as the message is not confirmed by a 
duly
signed document.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] In Rd: \describe \itemize and \item

2009-01-29 Thread Nicholas L Crookston
I rebuilt a test version of my yaImpute package using Uwe Ligges' windows 
build service. 
I got this reply: Check result: OK
R version 2.9.0 Under development (unstable) (2009-01-27 r47756)

Here is the issue: I have the following construct in help files (this 
example relates to "data"):

\format{
  A data frame with 847 rows and 29 columns: \cr\cr
  Ground based measurements of trees (Y-variables):
  \itemize{
 \item{TopHt}{Height of tallest trees (ft)}
 \item{LnVolL}{Log of the volume \eqn{(ft^3/acre)} of western larch}
 .. many lines deleted ..
 \item{LnVolPP}{Log of the volume \eqn{(ft^3/acre)} of ponderosa pine}
 \item{CCover}{Canopy cover (percent)}
  }
  Geographic Location, Slope, and Aspect (X-variables):
  \itemize{
\item{utmx}{UTM easting at plot center}
\item{utmy}{UTM northing at plot center}
.. many lines deleted ..
\item{elevm}{Mean elevation (ft) above sea level over plot}
\item{slpsinaspm}{Mean of slope (proportion) times the sine of aspect}
  }
.. many lines deleted ..
}

What I get in the help file is:
=
Format  
A data frame with 847 rows and 29 columns: 

Ground based measurements of trees (Y-variables): 

   TopHt 
  Height of tallest trees (ft) 
   LnVolL 
  Log of the volume (ft^3/acre) of western larch 
= ..and so on
[I've inserted 3 spaces to mimic tabs in this illustration]

I would expect (and I used to get) something like this:
=
Ground based measurements of trees (Y-variables): 

   TopHt   Height of tallest trees (ft) 
   LnVolL  Log of the volume (ft^3/acre) of western larch 
=

Note that in version 2.6.2 (under SuSE 10.3) this code fails the check, 
but my original code worked. 

The entire issue came up in reference to Kurt Hornik's recent mail that we 
get our help files ready for the next release of R. 

My current production help files work, but do not comply with the 
instructions as I understand them and fail the check on the development 
versions. I'm not sure I have fixed them correctly, but I'm trying!

Suggestions?  Comments?

Thanks, Nick.

PS: If this Email is not simple text, please let me know.

Nicholas L. Crookston, Operations Research Analyst
Rocky Mountain Research Station
USDA Forest Service
1221 South Main, Moscow, ID 83843
Office: (208) 883-2317, FAX: (208) 883-2318
EMail: ncrooks...@fs.fed.us

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] In Rd: \describe \itemize and \item

2009-01-30 Thread Nicholas L Crookston
Duncan Murdoch  wrote on 01/29/2009 07:14:11 PM:

> On 29/01/2009 5:22 PM, Nicholas L Crookston wrote:
> > I rebuilt a test version of my yaImpute package using Uwe Ligges' 
windows
> > build service.
> > I got this reply: Check result: OK
> > R version 2.9.0 Under development (unstable) (2009-01-27 r47756)
> >
> > Here is the issue: I have the following construct in help files (this
> > example relates to "data"):
> >
> > \format{
> >   A data frame with 847 rows and 29 columns: \cr\cr
> >   Ground based measurements of trees (Y-variables):
> >   \itemize{
> >  \item{TopHt}{Height of tallest trees (ft)}
> >  \item{LnVolL}{Log of the volume \eqn{(ft^3/acre)} of western 
larch}
> >  .. many lines deleted ..
> >  \item{LnVolPP}{Log of the volume \eqn{(ft^3/acre)} of ponderosa 
pine}
> >  \item{CCover}{Canopy cover (percent)}
> >   }
> >   Geographic Location, Slope, and Aspect (X-variables):
> >   \itemize{
> > \item{utmx}{UTM easting at plot center}
> > \item{utmy}{UTM northing at plot center}
> > .. many lines deleted ..
> > \item{elevm}{Mean elevation (ft) above sea level over plot}
> > \item{slpsinaspm}{Mean of slope (proportion) times the sine of 
aspect}
> >   }
> > .. many lines deleted ..
> > }
> >
> > What I get in the help file is:
> > =
> > Format  
> > A data frame with 847 rows and 29 columns:
> >
> > Ground based measurements of trees (Y-variables):
> >
> >TopHt
> >   Height of tallest trees (ft)
> >LnVolL
> >   Log of the volume (ft^3/acre) of western larch
> > = ..and so on
> > [I've inserted 3 spaces to mimic tabs in this illustration]
> >
> > I would expect (and I used to get) something like this:
> > =
> > Ground based measurements of trees (Y-variables):
> >
> >TopHt   Height of tallest trees (ft)
> >LnVolL  Log of the volume (ft^3/acre) of western larch
> > =
> >

> I think we need more info to comment on.  Is this file one of the ones
> in the yaImpute package on CRAN, or is it unreleased?  Is the Rd file
> available for us to look at?  Does the man page look different in 2.8.1
> from what you expect (there haven't been serious changes there), or only
> in R-devel (2.9.0)?  2.6.2 is pretty old, but I don't think any of the
> requested changes should be incompatible with it.

> Duncan Murdoch

The problem is in an unreleased version built in the development 
environment.
The entire unreleased package can be found at this temporary location: 
http://forest.moscowfsl.wsu.edu/gems/yaImpute_1.0-8.tar.gz

The original is on CRAN (version 1.0-7). It worked under the old parser, 
but
not using parser 2 (the warnings on CRAN point to the problem). 
You can see the difference by looking at TallyLake.Rd 
in the two versions. I would be happy to send you just these files if 
you'd 
like me to.

Note that text version of the help file builds as I expect it to. 
The problem is in the htlm version.

PS: I tried two versions of \items 
\item{utmx}{UTM easting at plot center}
and 
\item{utmx   }{UTM easting at plot center}
(note added spaces, added for readability of the Rd file 
this difference does not seem to matter.)

Thanks, Nick

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] In Rd: \describe \itemize and \item

2009-01-30 Thread Nicholas L Crookston
Duncan Murdoch  wrote on 01/30/2009 12:04:56 PM:


> 
> Okay, I think I see now.  I installed your package version 1.0-8 in
> R-devel (to be 2.9.0), and the ?TallyLake man page looks fine to me in
> text mode, looks slightly funny in HTML (with the labels one line above
> the thing they're describing).  But to me it looks better in the new
> HTML than version 1.0-7 looked in 2.8.1:  in that version, there was no
> attempt to line up the descriptions to a common left margin, so they
> tended to be confused with the thing they were describing.

> So I'm not sure what you'd really like to see in the output.  Can you
> describe it again?

Reading from the R-exts.pdf, section 2.4:

"The \itemize and \enumerate commands take a single argument, within which 
there may be
one or more \item commands. The text following each \item is formatted as 
one or more paragraphs,
suitably indented and with the first paragraph marked with a bullet point 
(\itemize)
or a number (\enumerate)."

I'm using \itemize so I expect to see a bullet point making the first 
paragraph of each item.

What I'm getting is what you would expect with the \describe command, as 
described here:

"The \describe command is similar to \itemize but allows initial labels to 
be specified.
The \items take two arguments, the label and the body of the item, in 
exactly the same way
as argument and value \items. \describe commands are mapped to  lists 
in HTML and
\description lists in LATEX."

> Duncan Murdoch

Nick Crookston

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R thread safe

2009-03-18 Thread Nicholas L Crookston
> Is there any official effort underway to make R thread-safe? If so,
> are they looking for volunteers. 

I'm looking forward to the answer to this question!

> Would making R fully thread-safe
> really make that much sense given you can parallelize vector/matrix
> operations now (as you noted) which probably provides the most bang
> for the buck.

There are applications that could benefit from running several threads, 
yet not to accomplish the vector/matrix operations using blas. I thought
about working on this and have picked up several important comments from
this discussion. I have wondered, for example, if there is an option that 
a user can set to limit the number of threads (package multicore uses
an option to set the number of cores). It seems that we need to agree
on a few basic rules. If there are some already outlined, I would like 
to have a reference to them. If not, perhaps there is an 
on-going discussion on the topic someone could point me to.

> Thanks,

Nick.

Nicholas L. Crookston, Operations Research Analyst
Rocky Mountain Research Station
USDA Forest Service
1221 South Main, Moscow, ID 83843
Office: (208) 883-2317, FAX: (208) 883-2318
EMail: ncrooks...@fs.fed.us

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel