Displaying 20 results from an estimated 9000 matches similar to: "custom sort?"
2009 Aug 05
7
why is 0 not an integer?
Why when I assign 0 to an element of an integer vector does the type change
to numeric?
Here is a particularly perplexing example:
> v <- 0:10
> v
[1] 0 1 2 3 4 5 6 7 8 9 10
> class(v)
[1] "integer"
> v[1] <- 0
> class(v)
[1] "numeric" #!!
>
--
View this message in context:
2009 Aug 05
7
why is 0 not an integer?
Why when I assign 0 to an element of an integer vector does the type change
to numeric?
Here is a particularly perplexing example:
> v <- 0:10
> v
[1] 0 1 2 3 4 5 6 7 8 9 10
> class(v)
[1] "integer"
> v[1] <- 0
> class(v)
[1] "numeric" #!!
>
--
View this message in context:
2009 Jul 08
2
print() to file?
I'd like to write some objects (eg arrays) to a log file. cat() flattens them
out. I'd like them formatted as in 'print' but print only writes to stdout.
Is there a simple way to achieve this result?
Thanks
--
View this message in context: http://www.nabble.com/print%28%29-to-file--tp24397445p24397445.html
Sent from the R help mailing list archive at Nabble.com.
2009 Aug 04
4
array slice notation?
Suppose I have an n-diml array A and I want to extract the first "row" -- ie
all elements A[1, ...]
Interactively if I know 'n' I can write A[1,,,,,] with (n-1) commas.
How do I do the same more generally, eg in a script?
(I can think of doing this by converting A to a vector then extracting the
approp elements then reshaping it to an array, but I wonder if there isn't a
2009 Jul 01
2
sorting question
I've asked about custom sorting before and it appears that -- in terms of a
user-defined order -- it can only be done either by defining a custom class
or using various tricks with "order"
Just wondering if anyone has a clever way to order "vintages" of the form
2002, 2003H1, 2003H2, 2004, 2005Q1, 2005Q2, etc
some have H1 or H2, some have Q1,Q2,Q3,Q4, some are just plain
2009 Jun 23
1
X-window graphics -- preventing window coming to front?
When I do dev.new(), the resulting window comes to the front and grabs the
focus. Is there a way to prevent this so I can continue working in other
windows while the graphics are being produced?
Thanks
--
View this message in context: http://www.nabble.com/X-window-graphics----preventing-window-coming-to-front--tp24167763p24167763.html
Sent from the R help mailing list archive at Nabble.com.
2009 May 30
2
degraded performance with rank()
Hi.
I'm maintaining a package that creates an object that is essentially a
classed version of numeric. I updated recently from 2.7.1 to 2.9.0,
and merges involving my class suddenly took a huge performance hit.
I've traced the problem to something near rank(). From NEWS, it seems
rank() etc. changed in 2.8.0. Methods for xtfrm() are supposed to
help, but I've had no success. There
2009 May 27
3
Sort matrix by column 1 ascending then by column 2 decending
I've got a matrix with 2 columns and n rows. I need to sort it first
by the values in column 1 ascending. Then for values which are the
same in column 1, sort by column 2 decending. For example:
2 .5
1 .3
1 .5
3 .2
Goes to:
1 .5
1 .3
2 .5
3 .2
This is easy to do in spreadsheet programs but I can't seem to work
out how to do it in R and haven't been able to find a solution
anywhere.
2012 Mar 10
2
Window on a vector
Dear all,
I have a large vector (lets call it myVector) and I want to plot its value with the logic below
yaxis<-myVector[1]
yaxis<-c(xaxis,mean(myvector[2:3])
yaxis<-c(xaxis,mean(myvector[4:8])
yaxis<c(xaxis,mean(myvector[9:16])
yaxis<c(xaxis,mean(myvector[17:32])
this has to stop when the new ..... yaxis<c(xaxis,mean(myvector[1024:2048]) will not find the correspondent number
2013 Aug 27
1
R Language Newbie
Hi,
set.seed(29)
myVector<- rnorm(100)
?seq(1,100,by=2)
# [1]? 1? 3? 5? 7? 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49
#[26] 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99
myVector[seq(1,100,by=2)]
rev(myVector)
?sum(myVector>0)
#[1] 46
#or
?table(myVector>0)
#
#FALSE? TRUE
?#? 54??? 46
A.K.
Hey guys, this is my first week
2007 Dec 18
6
All anchored series from a vector?
>From: Johannes Graumann <johannes_graumann at web.de>
>Date: 2007/12/18 Tue PM 04:40:37 CST
>To: r-help at stat.math.ethz.ch
>Subject: [R] All anchored series from a vector?
lapply(1:length(myvector) function(.length) {
c(myvector[1}:myvector[.length])
})
but test it because i didn't.
>Hi all,
>
>What may be a smart, efficient way to get the following result:
2012 Feb 26
6
loop for a large database
Yes, I am a newbie.
I have a data.frame (MyTable) of 1445846 rows and 15 columns with
character data.
And a character vector (MyVector) of 473491 elements.
I want simply to get a data.frame with the count of how many times each
element of MyVector appears in MyTable.
I've tried a loop with : for (i in 1 : length (myvector)) sum (MyTable== i)
but it crashes my computer.
I've also
2024 Jul 14
2
xftrm is more than 100x slower for AsIs than for character vectors
? Fri, 12 Jul 2024 17:35:19 +0200
Hilmar Berger via R-devel <r-devel at r-project.org> ?????:
> This can be finally traced to base::rank() (called from
> xtfrm.default), where I found that
>
> "NB: rank is not itself generic but xtfrm is, and rank(xtfrm(x), ....)
> will have the desired result if there is a xtfrm method. Otherwise,
> rank will make use of ==, >,
2024 Jul 12
1
xftrm is more than 100x slower for AsIs than for character vectors
Good evening,
I recently have observed slow merges when combining multiple data frames
derived from DataFrame and base::data.frame. I observed that the index
column of intermediate tables was of class <AsIs> (automatically
converted from character). The problem occurred mainly when using the
sorted = T option in base::merge.
This can be traced to xtfrm.AsIs being more than 100 times slower
2008 Nov 06
2
Fwd: SWIG with R and C++ STL
Hi, all
I didn't get any response from swig for my question.
see if I can get some help here
Thanks
---------- Forwarded message ----------
From: charlie <charlie.xia.fdu@gmail.com>
Date: Tue, Nov 4, 2008 at 1:55 PM
Subject: SWIG with R and C++ STL
To: swig-user@lists.sourceforge.net
Hi all,
I am new to SWIG. I encountered some problem when I try to SWIG to R some
C++ modules.
Here
2006 Apr 04
2
Selecting out certain values from a MATRIX
I have two objects, one matrix and one vector.
I want to use my vector to subset certain values out of my matrix.
For example:
I want to tell R, to select out all rows in myMatrix into a new myMatrix2 IF
that corresponding row is less than a 0.5 in myVector.
So:
myMatrix = a matrix of 8000 by 20
myVector = vector of 8000
myMatrix2 = a matrix of < 8000 by 20 (based on selection criteria in
2006 Mar 06
4
Contingency table and zeros
Hello,
Let's assume I have a vector of integers :
> myvector <- c(1, 2, 3, 2, 1, 3, 5)
My purpose is to obtain the cumulative distribution of these numerical
data, i.e. something like :
value nb_occur.
<=1 2
<=2 4
<=3 6
<=4 6
<=5 7
For this, I create a table with ;
> mytable <- table(myvector)
1 2 3 5
2 2 2 1
However, table() returns an array
2009 Feb 15
1
Overloading in R
I have been trying to write a new class that reimplements the vector
class. As a test of my overloading I decided to try and and call
t.test on two vectors which were objects of my class rather than the
default class.
The overloaded length I wrote seems to work correctly. I used
setMethod("length", "myvector", ...)
setMethod("mean", "myvector", ...)
2011 Sep 30
3
is member
Dear all,
I have a vector with number that some of them are part of the
seq(1,800,4). How can I check which of the numbers belong to the seq(1,800,4)
LEt's say that is called myvector the vector with the numbers.
Is there in R something like this?
is.member(myvector,seq(1,800,4))
I would like to thank you in advance for your help
B.R
Alex
[[alternative HTML version deleted]]
2008 Aug 22
1
grep, gsub and metacharacters
Hello,
I have an expression that I want to substitute for something else.
myvector<-c("ajkhfkiuwe","Variable(kg/min)")
if I use the following code to extract "variable(kg/min)" and substitute it for "va"
gsub(myvector[grep("var", myvector, ignore=T)], "va", myvector)
grep identifies the element of the vector that matches my