Displaying 20 results from an estimated 10000 matches similar to: "Sorting"
2005 Mar 16
8
Summing up matrices in a list
Dear all,
I think that my question is very simple but I failed to solve it.
I have a list which elements are matrices like this:
>mylist
[[1]]
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6
[[2]]
[,1] [,2] [,3]
[1,] 7 9 11
[2,] 8 10 12
I'd like to create a matrix M<-mylist[[1]]+mylist[[2]]
[,1] [,2] [,3]
[1,] 8 12 16
[2,] 10 14 18
2004 Apr 14
2
attaching data.frame/list within a function
I'm trying to find a good way of attaching a list within a function such
that the attached variables (the list's members) precede the global
environment (.GlobalEnv) in the search list. Here is a non-working example
using attach(), which hopefully explains better what I'm trying to do:
> foo <- function(x=0, input=list(a=10)) {
+ attach(input)
+ on.exit(detach(input))
+
2003 Feb 21
2
how to chage values in data frame to NA iside a function
Dear all
I have a function in which I would like to change some values to NA according to
some condition.
dropout<-function(y, nahr=FALSE,...) {
<some stuff for computing an index>
if (nahr) y[index]<<-NA
invisible(index)
}
in case y is a vector all works OK but if it is a part of data frame by calling
dropout(df$y) or dropout(df[,number]) no change is done.
Please can you
2013 Apr 29
3
rbinding some elements from a list and obtain another list
Hi everybody,
I have a list, where every element of this list is a data frame.
An example:
Mylist<-list(A=data.frame, B=data.frame, C=data.frame, D=data.frame)
I want to rbind some elements of this list.
As an example:
Output<-list(AB=data.frame, CD=data.frame)
Where
AB=rbind(A,B)
CD=rbind(C,D)
I’ve tried:
f<-function(x){
for (i in
2013 Apr 12
1
Problem with handling of attributes in xmlToList in XML package
Hello all,
I have a problem with the way attributes are dealt with in the
function xmlToList(), and I haven't been able to figure it out for
days now.
Say I have a document (produced by nmap) like this:
> mydoc <- '<host starttime="1365204834" endtime="1365205860"><status state="up" reason="echo-reply"
2007 Mar 24
1
frequency tables and sorting by rowSum
Dear list,
I have some trouble generating a frequency table over a number of vectors.
Creating these tables over simple numbers is no problem with table()
> table(c(1,1,1,3,4,5))
1 3 4 5
3 1 1 1
, but how can i for example turn:
0 1 0
0 0 1
0 1 0
1 0 0
0 1 0
1 0 0
into
0 0 1 1
1 0 0 2
0 1 0 3
My second problem is, sorting rows and columns of a matrix by the rowSums/colSums.
I did it
2006 Mar 01
4
linear lists, creation, insertion, deletion, traversal *someone?*
Hi,
In a second try I will ask this list to give me some useful pointers.
Linear lists, as described e.g. by N.Wirth in "Algorithms and Data
Structures", seem not to be implemented in S/R, although in lisp we have
cons, car, cdr.
Nevertheless I want to implement an algorithm using such linear lists,
porting a trusted program to R (S). I need:
(from Modula/Oberon)
pSC* = POINTER TO
2011 May 25
3
Accessing elements of a list
I have a list that is made of lists of varying length. I wish to create a
new vector that contains the last element of each list. So far I have used
sapply to determine the length of each list, but I'm stymied at the part
where I index the list to make a new vector containing only the last item
of each list
mylist =
2018 Jan 27
2
Newbie wants to compare 2 huge RDSs row by row.
If your two objects have class "data.frame" (look at class(objectName)) and
they
both have the same number of columns and the same order of columns and the
column types match closely enough (use all.equal(x1, x2) for that), then
you can try
which( rowSums( x1 != x2 ) > 0)
E.g.,
> x1 <- data.frame(X=1:5, Y=rep(c("A","B"),c(3,2)))
> x2 <-
2009 Jul 05
3
allocation/initialization of arrays/lists
Dear list,
I have a question regarding how to allocate or initialize the proper type of
the arrays or lists.
I have a for loop, each iteration, I want it to assign a subset of a data
frame to an element of an array or list.
However, I am wondering how I should initialize or allocate the empty array
or list so that it has the same number of the elements as the subsets I am
going to assign and
2018 Jan 27
3
Newbie wants to compare 2 huge RDSs row by row.
Also, it will be easier to provide helpful information if you'd describe
what in your data you want to compare and what you hope to get out of the
comparison.
Best wishes,
Ulrik
Eric Berger <ericjberger at gmail.com> schrieb am Sa., 27. Jan. 2018, 08:18:
> Hi Marsh,
> An RDS is not a data structure such as a data.frame. It can be anything.
> For example if I want to save my
2018 Jan 27
0
Newbie wants to compare 2 huge RDSs row by row.
Hi Guys, I apologize for my rank & utter newness at R.
I used summary() and found about 95 variables, both character and numeric, all with "Length:368842" I assume is the # of records.
I'd like to know the record number (row #?) of any record where the data doesn't match in the 2 files of what should be the same output.
Thanks in advance, M.
//
2018 Jan 28
2
Newbie wants to compare 2 huge RDSs row by row.
The anti_join from the package dplyr might also be handy.
install.package("dplyr")
library(dplyr)
anti_join (x1, x2)
You can get help on the different functions by ?function.name(), so
?anti_join() will bring you help - and examples - on the anti_join
function.
It might be worth testing your approach on a small subset of the data. That
makes it easier for you to follow what happens
2009 Apr 01
1
Vector of Vectors
I have a matrix of data. I need to scan the matrix and find every
sequence from maxima to maxima across a row. I can write a loop to do
this easily. Problem is, I can't figure out how to store the results.
Each result is a vector of widely varying lengths. Ideally I'd like a
vector of these, i.e. a vector of vectors, so I can quickly iterate
through them and compute correlation
2002 Dec 12
4
sum a list of vectors
In Mathematica there is a neat feature, where you can change the head of a list from "list" to say "+" and obtain a sum of the list elements.
I can't find a way to sum a list of vectors of same length or list of matrices of the same dimension and was curious if something like that exists in R. do.call("+",list) doesn't work because "+" accepts only
2009 Jun 07
1
Must be a better way to collate sequenced data
I have data that looks like this
time_stamp (seconds) user_id
The data is (partial) ordered by time - in that sometimes transactions occur at the same timestamp. The output I want is collated by transaction time on a per user basis, normalized by the maximum number of transactions per user, and aggregated over each day. So, if the users have 50 transactions in the first day and 20 transactions
2007 Oct 04
5
combining vectors on unequal length
If I have two vectors
X<-1:10
Y<-1:5
When I combine them using cbind, the shorter one is repeated and both are made of the same length. Is there a methods that does this without duplicating the shorter one. I want to use this to store the data back to a file.
Thanks ../Murli
[[alternative HTML version deleted]]
2007 May 17
4
using lm() with variable formula
New to R; please excuse me if this is a dumb question. I tried to RTFM;
didn't help.
I want to do a series of regressions over the columns in a data.frame,
systematically varying the response variable and the the terms; and not
necessarily including all the non-response columns. In my case, the
columns are time series. I don't know if that makes a difference; it
does mean I have to call
2018 Jan 28
0
Newbie wants to compare 2 huge RDSs row by row.
Cool, looks like that'd do it, almost as if converting an entire record to a character string and comparing strings.
-- M. B. Hardy, statistician
work: Applied Research Associates, S. E. Div.
8537 Six Forks Rd., # 6000 / Raleigh, NC 27615-2963
(919) 582-3329, fax: 582-3301
home: 1020 W. South St. / Raleigh, NC 27603-2162
(919) 834-1245
2009 Jul 23
2
alternative to rbind within a loop
Hi,
I often have to do this:
select a folder (directory) containing a few hundred data files in csv
format (up to 1000 files, in fact)
open each file, transform some character variables in date-tiime format
make into a dataframe (involves getting rid of a few variables I don't
need
concatenate to the master dataframe that will eventually contain the
data from all the files in the