similar to: Making a Subset Assignment function ("[<-")

Displaying 20 results from an estimated 10000 matches similar to: "Making a Subset Assignment function ("[<-")"

2011 Jul 08
2
Selecting subset of a given vector
Hi there, given a numeric vector, I can select numbers within a specific range. However presently, I have something related but different problem. Suppose I have a numeric vector. Now take an arbitrary number. Goal to to chose a specific subset with a given length, from that given vector, so that those chosen numbers are centered around that given constant. Here is one example: ### My original
2008 May 03
2
help with subset
Dear list: I have a problem using the subset function: dat<- data.frame(treatment=c("A", "B", "A", "C", "C", "D", "A", "D", "C", "D"), response=rnorm(10)) I am interested in treatments "A", "B" and "D" vec<- c("A", "B", "D") But I
2012 Jul 31
11
A lot of kernel martian source messages in /var/log/messages
Hi all: I see a lot of the errors below in /var/log/messages on my firewall: Aug 1 00:47:44 munin kernel: [109008.257109] martian source 192.168.1.5 from 127.0.0.1, on dev eth1 Aug 1 00:48:44 munin kernel: [109068.257384] martian source 192.168.1.5 from 127.0.0.1, on dev eth1 Aug 1 00:49:44 munin kernel: [109128.257509] martian source 192.168.1.5 from 127.0.0.1, on dev eth1 Aug 1 00:50:44
2009 Nov 30
1
updating subset of data.frame
i have a data frame and a numeric vector indexed as a subset of the rows in the data.frame. what command can i use to assign the values in the vector to the appropriate rows of the data.frame? here's my failed attempt. what i would want is data[1,'z'] == 2, data[5,'z'] == -4, data[8,'z'] == -5, data[9,'z'] == 5, and for the other values of 'z' to
2014 Jun 17
2
No es un problema de tm tienes doc.corpus vacío
No es un problema de tm ni de SnowfallC ni de mcapply (por el path utilizas linux, en windows mcapply según el manual no va bien) No defines bien los objetos que pasas. Pasas doc.corpus en lugar de corpus ( o asignas a corpus en lugar de a doc.corpus) . Depura los programas cuando salga un error de objeto, como te pone en el Error que pasas . Temporalmente lo tienes arreglado en
2006 Mar 02
1
Curious subsetting behavior
I have a simple vector, called tmp that I want to subset based on another vector called vec. Everything works as expected except for below where the subsetting returns something other than the original data. Any ideas? > vec <- c(1,2,3,4,5,59,60,27,32,21) > tmp [1] 1.0 1.1 2.0 2.1 2.2 3.0 3.1 4.0 5.0 5.1 6.0 7.0 8.0 8.1 9.0 [16] 9.1 9.2 10.0 10.1 11.0 12.0 13.0 14.0
2011 Jun 04
1
S4 class, passing argument names to function, modify original
Hello, an S4 class "Foo" is defined with a setter, $. For several reasons, the setter calls a function, .foo.update(). However, bypassing the argument names of the setter does not work. Question 1: Why not and how can I fix this? Question 2: What is the way to define either the function or the setter to modify the original object (not returning the modified copy of it an overwrite the
2010 May 12
1
slot assignment in S4 classes
Hi R friends,   I'm still studying S4 classes and I have a question about slot assignment. Why would I have to use a special setter method [example 2 below] if I can assign data to a slot directly when I call new() [example 1 below]?   ## first way to do it (the idiosyncratic way?) setClass(Class = "TestClass", representation = representation(myDf = "data.frame"))
2007 Nov 13
5
How to overload the assignment operator?
Dear all, what is the proper way to make the assignment operator generic and define methods depending on the class of the assigned value? Best regards Jens Oehlschl?gel P.S. I vaguely remember that this was possible in S+. In R I tried to no avail: # using this like h<-1:3 gives Error: in `<-.default`(h, 1:3) : invalid (do_set) left-hand side to assignment
2013 Nov 17
1
order() function, decreasing=TRUE unexpected behaviour
There appears to be an issue with the decreasing=TRUE option on the order() function that indicates either a bug or perhaps a design flaw (potentially flawed because I would suggest the majority of users would expect different behaviour). # demonstration of problem: x <- c(2,1,3,4,5) order(x) order(x, decreasing=TRUE) order(x) correctly reports the order as: 2 1 3 4 5 I expected the result
2006 Apr 21
2
Using before_create and conflicting setter method...
Hi, I am having trouble using before_create when I have an specialized setter method: before_save :set_campaign_start #----------------------------------------------------------------------- ------- def set_campaign_start self.campaign_start = Time.now end # We want the date to always start at midnight
2005 Mar 07
2
Setting up asterisk with current PBX?
We currently have a Toshiba Perception EX and I would like to start moving toward VOIP. Is there anyway we can run these two systems in parrallel? Better yet, is there anyway we can run fully on asterisk using the current PBX hardware? The current PBX has a mix of analog, digital and electronic cards in it. I tried to google for advice but I didn't find anything that pertained to this.
2014 Jun 18
2
No es un problema de tm tienes doc.corpus vacío
Creo que lo que quieres hacer necesita esta línea de código justo después de cargar el paquete tm: inmortal = unlist(strsplit(inmortal, " ", fixed = T)) De esta forma, trabajas con palabras, y NO con las frases enteras... Un saludo Isidro Hidalgo Arellano Observatorio Regional de Empleo Consejería de Empleo y Economía http://www.jccm.es > -----Mensaje original----- > De:
2012 Sep 09
2
mattr_accessor inside a class
Rails extends Ruby with mattr_accessor (Module accessor). As Ruby''s attr_accessor generates getter/setter methods for instances, mattr_accessor provide getter/setter methods at the module level. In below example, you see that mattr_accessor declared in the class context of LookupContext. It''s declared in class, not module. However, modules are defined in LookupContext, for
2019 May 31
2
[patch] add sanity checks to quantile()
The attached patch adds some sanity checks to the "type" argument of quantile(). Output from the following commands show the change of behavior with the current patch: vec <- 1:10 quantile(vec, type = c(1, 2)) quantile(vec, type = 10) quantile(vec, type = "aaa") quantile(vec, type = NA_real_) quantile(vec, type = 4.3) quantile(vec, type = -1) Current behavior
2010 Jan 02
2
help with for loop
Dear useRs, I want to write a function that generates all the possible combinations of diff(). Example: If my vector has length 5, I need the diff() until lag=4 -> c(diff(my.vec), diff(my.vec, lag=2), diff(my.vec, lag=3), diff(my.vec, lag=4)) If it has length 4, I need until lag=3 -> c(diff(my.vec), diff(my.vec, lag=2), diff(my.vec, lag=3)) So, it must be until lag=(length(my.vec)-1).
2008 Dec 16
0
[LLVMdev] Another compiler shootout
On Tuesday 16 December 2008 01:03:36 Evan Cheng wrote: > FYI. http://leonardo-m.livejournal.com/73732.html > > If anyone is motivated, please file bugs for the losing cases. Also, > it might make sense to incorporate the tests into our nightly tester > test suite. FWIW, I just ported my ray tracer benchmark to C and found that llvm-gcc gives much worse performance than gcc on x86
2010 Feb 17
1
side-effects in functions that replace object values and attributes
Hello list, I encountered some surprising behavior in R and wanted to check to see if I was imagining things. Previously, I thought that replacement/setter operators in prefix notation (e.g., `[<-`(x,1,y) rather than x[1] <- y) did not produce side effects (i.e., left 'x' unchanged), but just realized that this is not the case anymore (or has it always been this way? - I don't
2008 May 18
4
[LLVMdev] Opaque type usage to represent foreign types
In my project I have a group of foreign types (C++ classes) that I want to use, but don't want to represent as structs within LLVM. For example, for each field in each C++ class I have a setter and getter function that I'd like to use. The setters and getters are "extern C" functions to avoid problems with C++'s name mangling. After going over the documentation it
2008 Mar 13
3
fast way to compare two matrices of combinations
I have a list (length 750), each element containing a vector of unique strings (unique gene ids), with length up to ~40 (median 15). I want to compile a matrix of all possible triplets and their frequency within gene elements. Using combn and a lot of looping, I am accomplishing this but it is VERY slow. I've tried to figure out a way to vectorize this, using "match" and