Displaying 20 results from an estimated 20000 matches similar to: "data frames with non-unique row.names (PR#98)"
1999 Jan 20
1
data frames with non-unique row.names
In R and S, the general idea is that data.frames
must have unique row.names (aka dimnames(.)[[1]]).
Several observations / problems (in R *and* S !).
[Example code at the end]
1)
Both in S and R,
data.frame(..)
(and e.g., also cbind(<data.frame>, ..) which dispatches to data.frame())
silently drops the whole row.names and replaces it by "1" "2" ...
2014 Apr 02
0
special handling of row.names
Hello,
I think there is an inconsistency in the handling of the compact form of the row.names attributes.
When n is the number of rows of a data.frame, the compact form is c(NA_integer_,-n), as in:
> d <- data.frame(x=1:10)
> .Internal(inspect(d))
@104f174a8 19 VECSXP g0c1 [OBJ,NAM(2),ATT] (len=1, tl=0)
@103a7dc60 13 INTSXP g0c4 [] (len=10, tl=0) 1,2,3,4,5,...
ATTRIB:
@104959380
2010 May 25
1
Non-unique Values
I might be missing something really obvious, but is there an easy way to locate all non-unique values in a data frame?
Example
mydata <- numeric()
mydata$id <- 0:8
mydata$unique <- c(1:5, 1:4)
mydata$result <- c(1:3, 1:3, 1:3)
> mydata
$id
[1] 0 1 2 3 4 5 6 7 8
$unique
[1] 1 2 3 4 5 1 2 3 4
$result
[1] 1 2 3 1 2 3 1 2 3
What I want to to be able to get some form of data output
2012 Mar 06
2
Why aren't row names in a data frame unique?
I expected the row names to be unique but a data frame appears to be able to hold duplicate row names. This makes me thing that there must be circumstances when it is necessary. However, I cannot think of any. Please enlighten me.
[[alternative HTML version deleted]]
2001 Feb 06
1
AW: Proposal: Generalizing unique() and duplicated()
On Tuesday 06 February 2001 12:36, Dr. Jens Oehlschlägel wrote:
> I like the idea. Why don't you call duplicated.matrix() directly in
> unique.matrix() and duplicated.data.frame() in unique.data.frame() ?
>
> Jens Oehlschlägel
Good point. I guess I got carried away with using methods (having just gotten
the hang of the concept). :-)
Anyway, here's a corrected version:
1997 May 02
0
R-beta: Splus vs R
> If I were Mathsoft I would be less than pleased
> at the development of R and would try to stop it if I could.
I would not assume that Mathsoft must have such a negative view towards R.
The reasons are roughly summarized by the analogy that a smaller part of a
big pie is often better than a bigger part of a small pie.
Mathsoft's limited success in addressing the student market has
2007 May 29
2
summing up colum values for unique IDs when multiple ID's exist in data frame
I have data.frame's with IDs and multiple columns. B/c some of IDs showed up
more than once, I need sum up colum values to creat a new dataframe with
unique ids.
I hope there are some cheaper ways of doing it... Because the dataframe is
huge, it takes almost an hour to do the task. Thanks so much in advance!
Young
# ------------------------- examples are here and sum.dup.r is at the
2000 Jul 12
1
getAttrib() and setAttrib()
Hello:
I am looking at "Writing R Extensions", subsection 3.6.4, using R 1.1.0,
under NT4.0, with VC++ 6.0. Under these conditions I can use the first
method given for coding the out() function, but not the second, which uses
getAttrib() and setAttrib(). I hope that someone will tell me how this
second method can also be made to work. Details follow, for anyone kind
enough to help.
2005 Mar 16
1
.Call - applying setAttrib(x, R_DimSymbol, s) to a matrix being an element of a list
Dear R developers,
I am writing some C code that loads multiple images into a list of R
matrices. The whole R object is created within the C code. To simplify
coding, elements of the list are first created as vectors and then
converted to corresponding matrices using setAttrib(x, R_DimSymbol, s).
Generally the code works fine except for one detail. Applying setAttrib
sets ALL elements
2013 Nov 04
1
ggplot2: Add '+' operator for aes (uneval) objects
Dear all,
Is there a reason, why there is no +-operator for aes (i.e. uneval) objects (as there is for themes and gg objects)? I had a couple of cases where such an operator would be useful, for instance to combine the result of aes and aes_string in functions. Any flaws with the following proposition:
`+.uneval` <- function(e1, e2) {
dup <- names(e1) %in% names(e2)
if (any(dup)) {
2014 Jun 24
2
using C code to create data frame but always return as list
there is my code, expect return value is a data frame but R say it is list:
SEXP Julia_R_MD_NA_DataFrame(jl_value_t* Var)
{
SEXP ans,names,rownames;
char evalcmd[4096];
int i;
const char* dfname="DataFrameName0tmp";
jl_set_global(jl_main_module, jl_symbol(dfname), (jl_value_t*)Var);
//Get Frame cols
sprintf(evalcmd,"size(%s,2)",dfname);
jl_value_t*
2007 Mar 13
4
selecting rows with more than x occurrences in a given column (data type is names)
Despite a long search on the archives, I couldn't find how to do this.
Thanks in advance for what is likely a simple issue.
I have a data set where the first column is name (i.e., 'Joe Smith',
'Jane Doe', etc). The following columns are data associated with that
person. I have many people with multiple rows. What I want is to get a
new data frame out with only the people who
2009 Mar 30
1
Setting the names attribute of a list?
Hello,
I have created a vector with 2 elements(see code below)
I am calling this function many thousands of times (hundreds of
thousands) after some time
i get
*** caught segfault ***
address 0x5, cause 'memory not mapped'
However, if i dont set the R_NamesSymbol, I do not get any such error.
Am I doing this correctly?
Thank you
Saptarshi
==CODE===
// kxp and usar are two SEXP's
1998 Nov 12
0
[COL/ROW]NAMES -> [col/row]names with new arg..
R-devel subscribers: this came from R-core,
but may interest you....
>>>>> "MM" == Martin Maechler <maechler@stat.math.ethz.ch> writes:
>>>>> "Ross" == Ross Ihaka <ihaka@stat.auckland.ac.nz> writes:
Ross> Martin Maechler writes:
>>> Actually, I've been thinking (and asking Kurt) if we shouldn't use
2006 Mar 27
1
Safe to UNPROTECT() when object is assigned to a list?
Hi,
I'm troubleshooting some native code on Windows that very occationally
(and semi-randomly) crashes R. Already looked at "everything", I just
want to double check that it is safe to UNPROTECT() allocated
variables as soon as they are assigned to, say, a PROTECTed list.
>From (R v2.3.0) Section 5.7.1 "Handling the effects of garbage
collection" in "Writing R
2012 Dec 10
1
Changing arguments inside .Call. Wise to encourage "const" on all arguments?
I'm continuing my work on finding speedups in generalized inverse
calculations in some simulations. It leads me back to .C and .Call,
and some questions I've never been able to answer for myself. It may
be I can push some calculations to LAPACK in or C BLAS, that's why I
realized again I don't understand the call by reference or value
semantics of .Call
Why aren't users of
2006 Sep 19
0
inconsistent rows in a data frame
I need to identify repeated items in p$a with
different s and d entries on the same row, given that
the "0" items should not be considered in the
comparison. Here is an example:
1. Items 3 and 5 in p$a are repeated with different
entries of s and d, should be removed.
2. Item 2 was repeated twice but with a 0 once for s
on row 2 and a second time for d on row 6, hence 2
should be
2005 Jul 15
0
[R] Passing character strings from C code to R
Thanks,
That fixed the problem.
Jarek
-----Original Message-----
From: ripley at stats.ox.ac.uk [mailto:ripley at stats.ox.ac.uk]
Sent: Friday, July 15, 2005 11:11 AM
To: Tuszynski, Jaroslaw W.
Cc: r-devel at stat.math.ethz.ch
Subject: Re: [R] Passing character strings from C code to R
Reading the posting guide would have shown you that R-help was quite
inappropriate, so I have moved this to
2019 Jul 15
0
Convert STRSXP or INTSXP to factor
Hi Morgan,
So if the goal is output identical to calling factor, one thing youc an
do is construct and evaluate a call to the R-level factor function. That
would work and be guaranteed to meet your requirement.
The factor function is implemented with R code, without even any direct
calls down to C code, so there isn't any C level functionality already
there that you could try to hit
2004 Feb 11
1
.Call setAttrib(ans,R_DimSymbol,dim); Crashes.
Hi!
I want to return a matrix.
The code does the R interfacing.
This version does it fine.
SEXP ans,dim;
PROTECT(ans = NEW_NUMERIC(count*2));
memcpy(NUMERIC_POINTER(ans),result,count*sizeof(double));
memcpy(&(NUMERIC_POINTER(ans)[count]),occur,count*sizeof(double));
/** PROTECT(dim=NEW_INTEGER(2));
INTEGER_POINTER(dim)[0]=2;
INTEGER_POINTER(dim)[1]=count;