similar to: save an object by dynamicly created name

Displaying 20 results from an estimated 3000 matches similar to: "save an object by dynamicly created name"

2008 Nov 17
5
how to calculate another vector based on the data from a combination of two factors
Hi, I have a data set similar to the following State Gender Quantity TX Male 1 NY Female 2 TX Male 3 NY Female 4 I need to calculate cumulative sum of the quantity by State and Gender. The expected output is State Gender Quantity CumQuantity TX Male 1 1 TX Male 3 4 NY Female 2 2 NY Female 4 6 I highly appreciate if someone can give me some hints on solving that in R. Hao -- View this
2009 Nov 16
8
extracting the last row of each group in a data frame
Hi, I would like to extract the last row of each group in a data frame. The data frame is as follows Name Value A 1 A 2 A 3 B 4 B 8 C 2 D 3 I would like to get a data frame as Name Value A 3 B 8 C 2 D 3 Thank you for your suggestions in advance Jeff
2009 Dec 11
4
get the enclosing function name
Hi, Is there a way to get the enclosing function name within a function? For example, I would like to have a function getEnclosingFunctionName(). It works like below f = function(){ print(getEnclosingFunctionName()) } f() # will print "f" Thanks Jeff
2008 Nov 20
2
how to replace NA with previous numbers
Hi, I have a vector with lots of NAs. e.g. vec = c(NA, NA, 2, NA, NA, 5, NA, 6, NA) > vec [1] NA NA 2 NA NA 5 NA 6 NA I would like to replace NAs with their immediately previous non NA number. After replacement, the above vector will become > vec [1] 0 0 2 2 2 5 5 6 6. I understand how to do that with a loop but the actual vector is very long and the loop takes too much time in R.
2009 Dec 02
4
sort a data frame by a vector
Hi, I have a a vector and a data frame with two columns vec = c("C", "A", "B") dataDF = data.frame(A1 = c("B", "A", "C"), A2 = c(1,2,3)) I would like to sort the data frame by column A1 such that the order of elements in A1 is as the same as in vec. After the ordering, the data frame would be A1 A2 C
2012 May 22
2
Best way to locate R executable from within R?
Hi, I'd like to spawn of a new R process from within R using system(), e.g. system("R -f myScript.R"). However, just specifying "R" as in that example is not guaranteed to work, because "R" may not be on the OS's search path. What is the best way, from within a running R, to infer the command (basename or full path) for launching R in way that it works on
2009 Dec 29
1
(no subject)
Hi, I wonder how to pass several functions and their arguments as arguments to a function. For example, the main function is f = function(X ) { process(X) ... process(X) } I have a few functions that operate on X, e.g. g1(X, par1), g2(X, par2), g3(X, par3). par1, par2 and par3 are parameters and of different types.
2009 Dec 29
2
pass functions and arguments to function
Hi, I wonder how to pass several functions and their arguments as arguments to a function. For example, the main function is f = function(X ) { process1(X) ... process2(X) } I have a few functions that operate on X, e.g. g1(X, par1), g2(X, par2), g3(X, par3). par1, par2 and par3 are parameters and of different types. I would like to pass g1, g2, g3 and their arguments to f and g1,
2009 Nov 24
1
ow to have R automatically print traceback upon errors
Hi, I wonder how to have R automatically print stack trace produced by traceback upon errors during interactive uses. I tried the suggestions on http://old.nabble.com/Automatically-execute-traceback-when-execution-of-script-causes-error--td22368483.html#a22368775 and used options(error = recover) options(showErrorCalls = T) It just produces an extra message like "recover called
2009 Dec 29
1
how to append new data to saved data on disk efficiently
Hi, I currently combine multiple processed data (data frame) into a list and save the list as ".rda" using the save command. When new data come, I load the rda file, process the new data into a data frame, append the data frame to the end of the list, and save the whole list to the disk. The loading and saving steps are quite time consuming. Since I don't need to change the old data
2012 Aug 23
3
Concatenating data frames in R versus SAS
I am trying to concatenate 2 datasets that don't have exactly the same column. In SAS I did: data summary; set agency prop; run; No problem in R I get error message summary <-rbind(agency,prop) Error in match.names(clabs, names(xi)) : names do not match previous names But when I use rbin.fill, that overwrites the second file w/ first one. Is there a way to replicate the sas process
2004 Nov 23
1
Batch
Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Received-SPF: none (hypatia: domain of claudiapaladini at web.de does not designate permitted sender hosts) X-Virus-Scanned: by amavisd-new at stat.math.ethz.ch X-Spam-Checker-Version: SpamAssassin 3.0.1 (2004-10-22) on hypatia.math.ethz.ch X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0
2020 Jun 29
2
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld woes
In the rgdal package, configure.ac has had : ${LDFLAGS=`"${RBIN}" CMD config LDFLAGS`} at least since 2012, so picking up LDFLAGS known to the R version installed. Very recently, users installing rgdal from source with R installed from RPM are seeing problems, such as those reported in this thread: https://stat.ethz.ch/pipermail/r-sig-geo/2020-June/028251.html The diagnosis by
2007 Feb 06
3
RPM support for package installation?
Hello, Tech question, I hope this has not been addressed before. I searched help archives and looked for online help but came up empty-handed. My question is: (short version) Is there a RPM-supported version of update.packages() for use with updating package libraries on managed multi-user Linux networks? Details: I put in a request for updating the version of R on one of the hosts on my
2010 Jan 08
2
how to organize a lot of R source files
Hi, I wonder what is a better way to organize a lot of R source files. I have a lot of utility functions written and store them in several source files (e.g util1.R, util2.R,..utilN.R). I also have a master file in which the source command is used to load all the util.R files. When I need to use the utility functions in a new project, I create a new R file (e.g main.R) in which I
2009 Nov 25
3
questions on the ff package
Hi, I have two questions on using the ff package and wonder if anyone who used ff can share some thoughts. I need to save a matrix as a memory-mapped file and load it back later. To save the matrix, I use mat = matrix(1:20, 4, 5) matFF = ff(mat, dim=dim(mat), filename="~/a.mat", overwrite=TRUE, dimnames = dimnames(mat)) To load it back, I use matFF2 = ff(vmode = "double",
2007 Feb 11
3
merge words=data name
I would like to merge two parts of words to get a name of the data. First M3$N (invariable) and second is a number from 0001 to 3003 - M3$N0001,M3$N0002,...,M3$N3003. For example if I do it like this: my.data <- paste("M3$N",2456,sep="") I get > my.data [1] "M3$N2456" But I want to get something equivalent to my.data<- M3$N2456 Is there any way to do it?
2007 Jul 26
3
substituting dots in the names of the columns (sub, gsub, regexpr)
Dear R users, I have the following two problems, related to the function sub, grep, regexpr and similia. The header of the file(s) I have to import is like this. c("y (m)", "BD (g/cm3)", "PR (Mpa)", "Ks (m/s)", "SP g./g.", "P (m3/m3)", "theta1 (g/g)", "theta2 (g/g)", "AWC (g/g)") To get rid of spaces and
2012 Nov 09
6
(sin asunto)
Saludos, tengo un problema que no puedo resolver dentro del R Estoy creando una funcion que a partir de un objeto compuesto por diferentes matrices como el que esta a continuacion: [[1]] M1 M2 M3 M4 sp1 2 0 1 8 sp2 4 5 2 4 sp3 0 0 4 0 sp4 5 7 5 0 sp5 0 4 0 0 [[2]] M3 M2 M4 M1 sp1 1 0 8 2 sp2 2 5 4 4 sp3 4 0 0 0 sp4 5 7 0 5 sp5 0 4 0 0 [[3]]
2012 Sep 25
1
REML - quasipoisson
hi I'm puzzled as to the relation between the REML score computed by gam and the formula (4) on p.4 here: http://opus.bath.ac.uk/22707/1/Wood_JRSSB_2011_73_1_3.pdf I'm ok with this for poisson, or for quasipoisson when phi=1. However, when phi differs from 1, I'm stuck. #simulate some data library(mgcv) set.seed(1) x1<-runif(500) x2<-rnorm(500)