similar to: unable to update the matrix values within a function

Displaying 20 results from an estimated 20000 matches similar to: "unable to update the matrix values within a function"

2002 Oct 29
1
strange locks
Hi, I added these lines to smb.conf: kernel op locks = false op locks = false strict locking = true so I could see some locks from the unix level. It worked sorta, I see the locks for big files (but not the locks I was expecting), but for little files it shows nothing: # ./lock_list /opt/testsambashare/mattest.doc # ./lock_list /opt/testsambashare/contents.doc 0 22086 W
2012 Nov 15
1
Extracting list names within a looped function
Hello all, I have the following problem: 1) A list was defined as 'a' a <- list("var1"=c(100:1), "var2"=c(1:100), "var3"=rnorm(100)) 2) a function 'foo' was defined that extracts the variable name assigned to x using the deparse(substitute()) functionality. This name will then be used within the function to generate specific output files, etc.
2004 Sep 20
2
Getting the real names of variables within functions
Greetings. These days I find myself writing a lot of functions to handle routine things. One of these is a function to create a scatterplot of variables and draw a lowessed line so I can get some idea if there's any relationship between them. lowessed.plot <- function(x, y) { plot(x, y) lines(lowess(x, y)) } However, there's a slight problem: the plot axes come out labeled
2009 Sep 28
4
How to assess object names within a function in lapply or l_ply?
Dear All, to produce output of several columns of a data frame, I tried to use lapply and also l_ply. In both cases, I would like to print a header line containing also the name of the respective column in the data frame. For example, I would like the following lapply(data.frame(a=1:3, b=2:4), function(x) print(deparse(substitute(x)))) to produce: [1] "a" [1] "b" and
2007 Mar 08
2
Removing duplicated rows within a matrix, with missing data as wildcards
I'd like to remove duplicated rows within a matrix, with missing data being treated as wildcards. For example > x <- matrix((1:3), 5, 3) > x[4,2] = NA > x[3,3] = NA > x [,1] [,2] [,3] [1,] 1 3 2 [2,] 2 1 3 [3,] 3 2 NA [4,] 1 NA 2 [5,] 2 1 3 I would like to obtain [,1] [,2] [,3] [1,] 1 3 2 [2,] 2 1 3
2010 Mar 12
4
Getting multiple matrix-values using a single command
Dear all! I'm trying to get multiple values from a matrix by using a single command. Given a matrix A A <- matrix(seq(1,9),nrow=3,ncol=3) How can I get e.g. the values A[1,2] = 4 and A[3,3] = 9 with a single command and without using any loop? My first idea was to generate a row- and a column vector for the indices, i.e. c(1,3) indicating row number 1 (for A[1,2]) and row number
2005 Jul 19
2
using argument names (of indeterminate number) within a function
Although I tried to find an answer in the manuals and archives, I cannot solve this (please excuse that my English and/or R programming skills are not good enough to state my problem more clearly): I want to write a function with an indeterminate (not pre-defined) number of arguments and think that I should use the "..." construct and the match.call() function. The goal is to write
2010 Feb 14
3
evaluate variable within expression - how?
Ein eingebundener Text mit undefiniertem Zeichensatz wurde abgetrennt. Name: nicht verf?gbar URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100214/4b41a017/attachment.pl>
2005 Apr 28
2
Reconstruction of a "valid" expression within a function
Hello all, I have some trouble in reconstructing a valid expression within a function, here is my question. I am building a function : SUB<-function(DF,subset=TRUE) { #where DF is a data frame, with Var1, Var2, Fact1, Fact2, Fact3 #and subset would be an expression, eg. Fact3 == 1 #in a first time I want to build a subset from DF #I managed to, with an expression like eg. DF$Fact3, # but I
2005 Jul 19
2
Obtaining argument name within a function
Dear all How can I obtain the name of the argument passed in a function? Here is a simplistic example of what I would like to obtain: myfunction= function(name) { print(paste("The parameter name was",unknownFunction(name)) } myfunction(myobject) [1] "The parameter name was myobject" Thanks Francisco
2010 Dec 29
2
Referring to an object name from within a function
Can anyone show me how to refer to an object name that is passed to a function, from within the function? For example: MyModel <- 1 test <- function(x) { if(x == 1) {cat("x is a valid object.\n")} } test(x) What I would like this to do is pass MyModel to function test, and if it passes a test, be able to print "MyModel is a valid object." Thanks. -- View this
2011 Aug 04
1
Tinn-R problem: unable to send code to R
The problem mentioned in the 06 Dec 2010 email below still occurs with Tinn-R (v.2.3.7.1) when highlighting a string of code, copying to the clipboard, and trying to send to Rgui via Shift+Ctrl+Q. I can copy 1 line of code to the clipboard and send it to Rgui with Shift+CTRL+Q. This fails with 2 or more lines of code, generating the error: Error in source(.trPaths[5], echo = TRUE,
2009 Jun 16
1
overshoot of formula line in summary output of Sweave
Hi, In the Sweave output for summary for several types of model objects and also for the comparison of models with anova, I find that that the display of the call(s) or formula does not obey the width option, even with keep.source=TRUE set, so that a long formula will overshoot the margins in the document. I would like to know if there is a good way to correct that. Looking at the print.summary
2013 Apr 05
2
model.frame: object is not a matrix
Over a decade ago there was a problem with model.frame when the variable names were long: https://stat.ethz.ch/pipermail/r-help/2002-August/024492.html I have similar symptoms with R 2.15.3 on Windows 7: Browse[2]> x <- model.matrix(formula(myform), p$data) Error in model.frame.default(object, data, xlev = xlev) (from mice.R#601) : object is not a matrix My attempt at a work-around
2018 Apr 23
4
R 3.5.0 fails its regression test suite on Linux/x86_64
Hi, I just tried to upgrade Nixpkgs to R 3.5.0, but unfortunately the new version fails its regression test suite. We configure the build using the flags "--without-recommended-packages", in case that's relevant. You can see a complete build log with all relevant information at [1]. Anyway, the test failures look like this: | make[3]: Entering directory
2003 Nov 11
1
+= assignment operator
The thread "Finding the name ob an object" gave me an idea about how to write an assignment operator like C's "+=": "%+=%" <- function(a, b) { as <- deparse(substitute(a)) bs <- deparse(substitute(b)) st <- paste(as, "<-", as, "+", bs) eval.parent(parse(text=st), 2) } R> xx <- matrix(1:9, 3,3) R> xx[2,
2004 May 12
1
Change default values of a function
Dear R-helpers, I would like to change the default value of a functions that is call by a package. The function deparse() is called by a set of functions from a library and because I don't think is appropriate to change the library, I am trying to change the default value in deparse(). At the moment the only solution I have come across is to place a function in my working environment like
2008 Mar 05
1
coxme - fitting random treatment effect nested within centre
Dear all, I am using "coxme" function in Kinship library to fit random treatment effect nested within centre. I got 3 treatments (0,1,2) and 3 centres. I used following commands, but got an error. > ugroup=paste(rep(1:3,each=3),rep(0:2,3),sep='/') > mat1=bdsmatrix(rep(c(1,1,1,1,1,1,1,1,1),3),blocksize=rep(3,3),dimnames=list(ugroup,ugroup)) >
2012 Mar 03
3
Using ddply within a function by argument transfer
An embedded and charset-unspecified text was scrubbed... Name: inte tillg?nglig URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120303/a62e41f2/attachment.pl>
2000 Jan 26
1
paste with a matrix
Hi, below is a function which pastes a matrix, but uses parsing (deparse(substitute()) and eval()). Does anyone know a more standard solution to pasting a matrix? Best Jens > paste.matrix(dd, sep=" ", collapse=NULL) [1] "1 a" "2 b" "3 c" > paste.matrix <- function(mtext, sep=" ", collapse=NULL){ + rcode <- paste( +