Displaying 20 results from an estimated 300 matches similar to: "programming question"
2012 Jul 27
1
C code validation
Dear R-devel,
I'm trying to validate the results from a C function, against a (trial
and tested) older R function. For reasons unknown to me, the C
function seems to give different result sometimes at each trial, even
with the very same data.
These are the relevant outputs from R:
> library(QCA)
Loading required package: lpSolve
> benchmark <- function(x, y) {
+ index <- 0
2007 Jan 30
6
jump in sequence
Dear list,
This should be a simple one, I just cannot see it.
I need to generate a sequence of the form:
4 5 6 13 14 15 22 23 24
That is: starting with 4, make a 3 numbers sequence, jump 6, then another 3
and so on.
I can create a whole vector with:
myvec <- rep(rep(c(F, T, F), rep(3, 3)), 3)
Then see which are TRUE:
which(myvec)
[1] 4 5 6 13 14 15 22 23 24
I'd like to avoid
2011 Aug 31
1
formatting a 6 million row data set; creating a censoring variable
List,
Consider the following data.
gender mygroup id
1 F A 1
2 F B 2
3 F B 2
4 F B 2
5 F C 2
6 F C 2
7 F C 2
8 F D 2
9 F D 2
10 F D 2
11 F D 2
12 F D 2
13 F D 2
14 M A 3
15 M A 3
16 M A 3
17
2015 May 04
2
[LLVMdev] Incorrect code generated for arm64
Hi all,
I’ve narrowed down a problem in my code to the following test case:
- - - -
typedef struct {float v[2];} vec2;
typedef struct {float v[3];} vec3;
vec2 getVec2();
vec3 getVec3()
{
vec2 myVec = getVec2();
vec3 res;
res.v[0] = myVec.v[0];
res.v[1] = myVec.v[1];
res.v[2] = 1;
return res;
}
- - - -
Compiling this with any level of optimization for arm64 gives incorrect code,
2015 May 04
2
[LLVMdev] Incorrect code generated for arm64
Thanks Bruce.
> On 4 May 2015, at 13:18, Bruce Hoult <bruce at hoult.org> wrote:
>
> I can confirm that, with Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
>
> Very strange!
Yes, that’s what I thought. I’ve also checked the binary downloads for OS X from llvm.org <http://llvm.org/> and get the same broken code from both the 3.5.2 and 3.6.0 releases.
2008 Jun 23
2
Writing Vector to a File
Dear experts,
I try not to trouble the list again after this question.
I want to print this vector into a file
> myvec
[1] --Control --Control --Control --Control --Control HBA2 HBA1
[8] HBA1 --Control HBB --Control HBB HBA1 MBP
[15] --Control HBA1 HBA2 HBB PTGDS GAPDH UBC
[22] --Control GAPDH TPT1 HUWE1 PRM1 CKM
2012 Oct 31
1
ffdfindexget from package ff
I'm having trouble getting ffdfindexget to work right in Windows. Even the
most trivial of examples gives me problems.
> myVec = ff(1:5)
> another = ff(10:14)
> littleFrame = ffdf(myVec, another)
> posVec = ff(c(2, 4), vmode = 'integer')
> ffdfindexget(littleFrame, posVec)
Error in if (any(B < 1)) stop("B too small") :
missing value where TRUE/FALSE
2011 Apr 05
1
do not execute newline command
Hi R-users,
To automate the creation of scripts, I converted the code (example below) into a character string and wrote the object to a file:
Repeat <- "
myvec <- c(1:12)
cat('vector= ', myvec, '\n')
"
write (Repeat, 'yourpath/test.R')
the problem is that one line of the code is a "cat" command. In the output file (i.e. test.R), the newline
2007 Jan 21
2
multiple bases to decimal (was: comparing two matrices)
Hi again,
I was contemplating the solution using base 3:
set.seed(3)
mat2 <- matrix(sample(0:2, 15, replace=T), 5, 3)
Extracting the line numbers is simple:
bases <- c(3, 3, 3)^(2:0) # or just 3^(2:0)
colSums(apply(mat2, 1, function(x) x*bases)) + 1
[1] 7 23 25 8 1
The problem is sometimes the columns have different number of levels, as in:
mat1 <- expand.grid(0:2, 0:2,
2009 Dec 20
1
How to put text outside an xyplot?
Dear R-users,
I have a plot created with the code below. I tried to put some text to the right of the color key. I worked with grid.text and also viewport(), but couldn't achieve this. I know this should be simple, but I just couldn't figure out how to do it. How does this work?
Cheers,
Marius
library(lattice)
library(grid)
myvec=1:10
data=data.frame(x=myvec,y=myvec)
2011 Jan 19
1
Printing "pretty' vectors in Sweave
I am trying to print a nice looking vector in Sweave.
c <- 1:4
I want to see (1, 2, 3, 4) in TeX. .
If I use
paste(c, ",", sep="")
I get
"1," "2," "3," "4,"
If use cat(c, sep=",")
I can't seem to assign it to an object,
1,2,3,4> myvec <- cat(c, sep=",")
1,2,3,4> myvec
NULL
and if I bypass the
2013 Nov 21
1
[PATCH] suggestions for R-lang manual
Attached is a patch with suggestions for the R-lang manual at r64277.
Below are a few comments (some are implemented in the patch):
In the section "Objects", there is a table introduced by "The
following table describes the possible values returned by typeof". One
of the results is "any". Can "any" be returned by "typeof()" ?
Regarding the
2003 Feb 11
0
samba 2.2.7a and multiple logins...
Hello
I use a new samba server with LDAP support as PDC for some Windows2000
and WindowsXP machines.
All is working nice. The useer can login with a user/password in the
domain, we have remote profiles, the user can access the samba shares
and print etc.
But after some time (< 1 day) we get a smbstatus output like the
attached file. Users are connected multiple times with the same share
2013 Oct 15
2
A 'good' way to build a matrix from a sequence of integers?
# I understand that a good way to build a vector from a sequence of integers,
# is to use syntax like this:
myvec = c(1:99)
# Here is the 'short' version of my question:
# I want to understand a 'good' way to build a matrix from a sequence of integers.
# If that question is not clear, here is a longer version:
# Here is what I did for a 1D-matrix:
# I pick the sequence 1:3
# I
2011 Dec 21
2
unique combinations
Hi there,
I have a vector and would like to create a data frame, which contains
all unique combination of two elements, regardless of order.
myVec <- c(1,2,3)
what expand.grid does:
1,1
1,2
1,3
2,1
2,2
2,3
3,1
3,2
3,3
what I would like to have
1,1
1,2
1,3
2,2
2,3
3,3
Can anybody help?
2003 May 09
1
Bug report: deletion of files only on remote system is not logged.
I was told that my earlier submission of this report contained a
user-hostile attachment (courtesy of Outlook), so here it is again, with
the log included below.
The problem: Files that exist only on the remote system are deleted
silently (i.e. not logged), rather than noisily as implied by the
recommendation of --dry-run in the rsync man page definition of --delete
to see what would be
2024 Apr 21
1
x[0]: Can '0' be made an allowed index in R?
?s 08:55 de 21/04/2024, Hans W escreveu:
> As we all know, in R indices for vectors start with 1, i.e, x[0] is not a
> correct expression. Some algorithms, e.g. in graph theory or combinatorics,
> are much easier to formulate and code if 0 is an allowed index pointing to
> the first element of the vector.
>
> Some programming languages, for instance Julia (where the index for
2007 Mar 16
1
Rownames are always character?
Gurus,
Can I rely on the rownames() function, when applied to a matrix,
always returning either NULL or an object of type character? It
seems that row names can be entered as integers, but as of now
(R 2.4.1 on Windows) the function returns character vectors, not
numbers (which is my desired result).
I am using elements of the returned vector to index the matrix.
e.g.,
nams <-
2003 Feb 20
3
outliers/interval data extraction
Dear R-users,
I have two outliers related questions.
I.
I have a vector consisting of 69 values.
mean = 0.00086
SD = 0.02152
The shape of EDA graphics (boxplots, density plots) is heavily distorted
due to outliers. How to define the interval for outliers exception? Is
<2SD - mean + 2SD> interval a correct approach?
Or should I define 95% (or 99%) limit of agreement for data interval,
2020 Sep 01
2
[RFC] Framework for Finding and Using Similarity at the IR Level
Hello,
I’m Andrew Litteken, and I am working on a framework for defining, detecting, and deduplicating similar code sections at the IR level.
Programmers can introduce sections of code that perform nearly the same operation. By copying and pasting code throughout a code base, or using a piece of code as a reference to create a new piece of code that has nearly the same structure redundancies