Displaying 20 results from an estimated 100000 matches similar to: "Does a data frame have indexes for columns?"
2011 Mar 15
5
Does R have a "const object"?
Hi, all,
Does R have a "const object" concept like which is in C++ language? I want to set some data frames as constant to avoid being modified unintentionally. Thanks!
xiagao1982
2011-03-15
[[alternative HTML version deleted]]
2012 Apr 05
2
indexing data.frame columns
Consider the data.frame:
df <- data.frame(A = c(1,4,2,6,7,3,6), B= c(3,7,2,7,3,5,4), C =
c(2,7,5,2,7,4,5), index = c("A","B","A","C","B","B","C"))
I want to select the column specified in 'index' for every row of 'df', to
get
goal <- c(1, 7, 2, 2, 3, 5, 5)
This sounds a lot like the indexing-by-a-matrix
2011 May 02
1
How to pass objects from local() to GlobalEnv
Hi all,
I create some objects in local(), and want to pass them to GlobalEnv. How can I do this? Thanks!
xiagao1982
2011-05-02
[[alternative HTML version deleted]]
2011 Apr 30
2
create namespace without creating a package?
Hi all,
I am a C++/C# programmer who is new to R. I would like to use something like "namespace" to organize my functions without creating a package. How can I do this? Thanks!
xiagao1982
2011-04-30
[[alternative HTML version deleted]]
2007 Oct 25
1
Indexes on dataframe columns?
Hi --
I'm working with some data frames with fairly high nrows (call it 8
columns, by 20,000 rows). Are there any indexes on these columns?
When I do a df[df$foo == 42,] [which I think is idiomatic], am I doing a linear
search or something better? If the column contents is ordered, I'd like
to at least be doing a naive binary search.
Thanks!
Ranjan
2006 Jun 19
9
index columns in postgres
I am in a holding pattern while client decides upon changes and so I am
working some things out internally so it seems to me that indexing
frequently searched table fields might be useful.
I am using postgres and via postgres, I have added an index to one of my
tables whose index is the same name as the column name. The ''find''
screen I am using this to judge populates a number
2008 Jan 10
2
`[.data.frame`(df3, , -2) and NA columns
Dear baseRs,
I recently made a mistake when renaming data frame columns, accidentally
creating an NA column. I found the following strange behavior when negative
indexes are used.
Can anyone explain what happens here. No "workarounds" required, just curious.
Dieter
Version: Windows, R version 2.6.1 (2007-11-26)
#-----------------------------
df = data.frame(a=0:10,b=10:20)
df[,-2]
2011 Nov 03
1
Select columns of a data.frame by name OR index in a function
Dear all,
Sometimes I have the situation where a function takes a data.frame and
an additional argument describing come columns. For greater flexibility
I want to allow for either column names or column indices. What I
usually do then is something like the following:
-------------8<-------------
f <- function(datf, cols) {
nc <- seq_along(datf)
cn <- colnames(datf)
colOK <-
2023 Dec 13
1
Partial matching performance in data frame rownames using [
Dear Ivan,
thanks a lot, that is helpful.
Still, I feel that default partial matching cripples the functionality
of data.frame for larger tables.
Thanks again and best regards
Hilmar
On 12.12.23 13:55, Ivan Krylov wrote:
> ? Mon, 11 Dec 2023 21:11:48 +0100
> Hilmar Berger via R-devel <r-devel at r-project.org> ?????:
>
>> What was unexpected is that in this case was that
2023 Dec 19
1
Partial matching performance in data frame rownames using [
Hi Hilmar and Ivan,
I have used your code examples to write a blog post about this topic,
which has figures that show the asymptotic time complexity of the
various approaches,
https://tdhock.github.io/blog/2023/df-partial-match/
The asymptotic complexity of partial matching appears to be quadratic
O(N^2) whereas the other approaches are asymptotically faster: linear
O(N) or log-linear O(N log N).
2023 Dec 16
2
Partial matching performance in data frame rownames using [
On Wed, 13 Dec 2023 09:04:18 +0100
Hilmar Berger via R-devel <r-devel at r-project.org> wrote:
> Still, I feel that default partial matching cripples the functionality
> of data.frame for larger tables.
Changing the default now would require a long deprecation cycle to give
everyone who uses `[.data.frame` and relies on partial matching
(whether they know it or not) enough time to
2005 Jul 08
3
How do you sort a data frame on a selection of columns?
This is what to start with:
Data Frame A B C D
c1 4 y 5
c3 6 d 7
c1 5 t 6
Now sort on A then C
This is what to end with:
Data Frame A B C D
c1 5 t 6
c1 4 y 5
c3 6 d 7
I assume it is something like this:
attach(DF)
sort(DF,partial=c(A,C))
Thanks in advance.
Meredith
[[alternative HTML version deleted]]
2009 Sep 17
1
How to extract data.frame columns using regex?
Hi,
data.frame(x1=1:11,x2=2:12,x3=3:13,y=4:14)
I want to extract all the columns that with the name 'x?'. Is there a
general way to do this in R?
Regards,
Peng
2002 Oct 08
2
data.frame merge matching several columns
Greetings,
Is it possible to match several columns in a merge statement? Here is my
problem:
data1 looks like this...
SUBID TARGID ITEM RATING
1 1 1 4
1 1 2 5
1 1 3 3
1 1 4 2
1 1 5 5
......
SUBID is the ID for the raters, TARGID is the ID for the targets being
rated, ITEM ranges from 1 to 64 crossed
2007 Oct 12
1
Addition operation based on specific columns and rows of two data frames
#Hello,
# I have a question about the addition of values in specific columns and
rows of a Data frame.
# Below I have created two data frames, X.df and "Y.df".
## creation of X.df data frame
X<- matrix(0,16,3)
X.df<-data.frame(X)
X.df[,1] <- c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4)
X.df[,2] <- c(1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4)
names(X.df)[1]<-"L(A)a(i)"
2009 May 07
2
Matching multiple columns in a data frame
Hello,
I am trying to extract a subset of a dataframe A (2 columns) by
extracting all entries in A (several repeated entries) that match
dataframe B in both columns. For example, part of A and B are shown
below.
The following does not seem to work correctly. This only seems to select
on the first component and all instances of the second.
ind <- A$C1 %in% B[,1] & A$C2 %in% B[,2]
2011 Nov 09
2
algorithm that iteratively drops columns of a data-frame
Dear R-Users,
I have a problem with an algorithm that iteratively goes over a data.frame and exclude n-columns each step based on a statistical criterion.
So that the 'column-space' gets smaller and smaller with each iteration (like when you do stepwise regression).
The problem is that in every round I use a new subset of my data.frame.
However, as soon as I "generate" this
2010 May 31
1
Removing columns from data frame referenced by column index
Can you suggest me any way to remove a column of a data frame by the column
number,not by the column name.
Thanks,
Suman Dhara
[[alternative HTML version deleted]]
2017 Oct 19
0
Select part of character row name in a data frame
(Re-)read the discussion of indexing (both `[` and `[[`) and be sure to get clear on the difference between matrices and data frames in the Introduction to R document that comes with R. There are many ways to create numeric vectors, character vectors, and logical vectors that can then be used as indexes, including the straightforward way:
df[ c(
"Unique to strat ",
"Unique
2023 Dec 11
1
Partial matching performance in data frame rownames using [
Dear all,
I have seen that others have discussed the partial matching behaviour of
data.frame[idx,] in the past, in particular with respect to unexpected
results sets.
I am aware of the fact that one can work around this using either
match() or switching to tibble/data.table or similar altogether.
I have a different issue with the partial matching, in particular its
performance when used on