similar to: dynamically creating functions in r

Displaying 20 results from an estimated 300 matches similar to: "dynamically creating functions in r"

2011 Oct 14
4
using do.call to call a list of functions
I am having trouble figuring out how to use do.call to call and run a list of functions. for example: make.draw = function(i){i;function()runif(i)} function.list = list() for (i in 1:3) function.list[[i]] = make.draw(i) will result in > function.list[[1]]() [1] 0.2996515 > function.list[[2]]() [1] 0.7276203 0.4704813 > function.list[[3]]() [1] 0.9092999 0.7307774 0.4647443 what I
2009 May 20
3
qbinom (PR#13711)
Full_Name: Wolfgang Resch Version: R 2.8.1 GUI 1.27 OS: OS X 10.4.11 Submission from: (NULL) (137.187.89.14) Strange behavior of qbinom: > qbinom(0.01, 5016279, 1e-07) [1] 0 > qbinom(0.01, 5016279, 2e-07) [1] 16 > qbinom(0.01, 5016279, 3e-07) [1] 16 > qbinom(0.01, 5016279, 4e-07) [1] 16 > qbinom(0.01, 5016279, 5e-07) [1] 0
2013 Apr 12
1
A strange behaviour in the graphical function "curve"
I thought the curve function was a very flexible way to draw functions. So I could plot funtions like the following: # I created a function to produce functions, for instance: fp <- function(m,b) function(x) sin(x) + m*x + b # So I can produce a function like this ff <- fp(-0.08, 0.2) ff(1.5) # Is the same as executing sin(1.5) - 0.08*1.5 + 0.2 # Let's plot this
2003 Dec 09
1
How to append to a data.frame?
Hi, I have a data.frame that I need to construct iteratively. At the moment, I'm doing: d<-data.frame(x=c(),y=c(),z=()); # {and, within some loop} d<-rbind(d,data.frame(x=newx,y=newy,z=newz); While this works, it is horribly verbose and probably not efficient, either. My real data.frame has, of course, many more columns, which can be of different modes. I vaguely recall that
2011 Apr 01
3
programming: telling a function where to look for the entered variables
Hi there, Could someone help me with the following programming problem..? I have written a function that works for my intended purpose, but it is quite closely tied to a particular dataframe and the names of the variables in this dataframe. However, I'd like to use the same function for different dataframes and variables. My problem is that I'm not quite sure how to tell my function in
2012 Apr 05
4
Appropriate method for sharing data across functions
In trying to streamline various optimization functions, I would like to have a scratch pad of working data that is shared across a number of functions. These can be called from different levels within some wrapper functions for maximum likelihood and other such computations. I'm sure there are other applications that could benefit from this. Below are two approaches. One uses the <<-
2016 Apr 23
2
Data Frame Column Name Attribute
I am attempting to add a calculated column to a data frame. Basically, adding a column called "newcol2" which are the stock closing prices from 1 day to the next. The one little hang up is the name of the column. There seems to be an additional data column name included in the attributes (dimnames?). So when i run HEAD(DATAFRAMENAME) i get the column name = "Open". but
2018 May 24
2
Problem with adding a raster and a brick
Hi, I seem to be having a problem adding the following two raster objects together - one is a rasterLayer, the other is a rasterBrick. The extent, resolution, and origin are the same, so according to my understand it should work. The objects look like so: > obs.clim class : RasterLayer dimensions : 60, 200, 12000 (nrow, ncol, ncell) resolution : 0.5, 0.5 (x, y) extent : -70,
2011 May 12
1
extract integers from string
I have a vector with a long list of sentences that contain integers. I would like to extract the integers in a manner such that they are separate and manipulatable. for example: x[i] <- "sally has 20 dollars in her pocket and 3 marbles" x[i+1] <- "30 days ago john had a 400k house" all sentences are different and contain a mixture of both integers and characters. i
2013 Jan 18
2
How to re-project ease( Equal Area Scalable Earth) grid with a ~25 km cylindrical projection to WGS84 0.25 degree?
I have nc files for global soil moisture,here is one file https://echange-fichiers.inra.fr/get?k=f9DDllPKdUKs5ZNQwfq from the metadata ,the projection is cylindrical and the resolution is 25 km(it is based on authalic sphere based on International 1924 ellipsoid).As I want to compare with other data, I have to make them identical. - my other data are in WGS84 with 0.25*0.25 degree resolution
2018 Mar 28
2
Fwd: netCDF to GeoTIFF by layer in r
Hi I have a netCDF file of volumetric soil water content at four different soil layers and want to convert each soil layer in the netCDF file to a GeoTIFF layer. This code converts the netCDF file to one GeoTIFF layer, i.e. unclear which soil depth. file.nc <- "C:/Soil_Weather_data/Agro/VMC21/VMC21.nc" file.tiff <- "C:/Soil_Weather_data/Agro /VMC21/VMC21" importnetcdf
2018 Mar 28
0
netCDF to GeoTIFF by layer in r
Hi Ahmed, When reading from a ncdf file you can use the 'varname', 'lvar' and 'level' arguments - see the 'Details' section in the docs https://www.rdocumentation.org/packages/raster/versions/2.6-7/topics/raster <https://www.rdocumentation.org/packages/raster/versions/2.6-7/topics/raster> We can't tell what is in the ncdf file from what you report other
2010 Dec 03
3
recode letters to numbers
Hello, I have a dataframe assigning various scores on around 20 variables to a list of countries. The scores are rated on a scale of (D, C, B, A) and there are also some not rated ones (NR) and others are left blank (NA). I now wanted to transfer the scores into numeric values (such as NR=0, D=25, C=50, B=27, A=100), while also leaving the NA in the dataframe. Can I transform the whole
2013 Feb 13
1
[lattice] display a projected map on a layerplot
summary: I can display a lon-lat map on a lattice::layerplot, and I can display a Lambert conformal conic (LCC) map on a spam::image, but I can't display an LCC map on a lattice::layerplot. Example follows. What am I doing wrong? details: I've been using `lattice` (via `rasterVis`) successfully to display global atmospheric data, which works well enough (though I am definitely intrigued
2004 Apr 07
1
ZIB models
I attempted to contact Drew Tyre, but the email I have for him is no longer in service. Hopefully someone can help. I'm using obs.error in R to model turtle occupancy in wetlands. I have 4 species and 20 possible patch and landscape variables, which I've been testing in smaller groups. > zib.out<-obs.error(y=painted,m=numvis,bp=zvars,pcovar=7) I get the following error
2018 May 24
0
Problem with adding a raster and a brick
On Thu, 24 May 2018 at 18:41 Mark R Payne <markpayneatwork at gmail.com> wrote: Hi, I seem to be having a problem adding the following two raster objects together - one is a rasterLayer, the other is a rasterBrick. The extent, resolution, and origin are the same, so according to my understand it should work. The objects look like so: > obs.clim class : RasterLayer dimensions : 60, 200,
2018 Jun 01
0
Problem with adding a raster and a brick
This is now fixed in development on RForge, you can try it out by installing from there, or from the Github mirror with devtools::install_github("rforge/raster/pkg/raster"). (To get fixes into raster email the maintainer directly - you might not get a response but it'll be addressed). Cheers, Mike. On Thu, 24 May 2018 at 20:08 Michael Sumner <mdsumner at gmail.com> wrote:
2006 Jul 11
1
Dynamically setting the session domain?
Does anyone know a way to dynamically change the session_domain option of ActionController::CgiRequest? I want to have a login section on an index page (www.example.com) that takes a subdomain, username, password, authenticates, then redirects to http://#{subdomain}.mysite.com. I need to set the session_domain option (to the subdomain) dynamically so the cookie can be read when the user arrives
2004 Aug 03
1
adding things dynamically
Another question: If I have a panel that contains a sizer that contains, for example, some number of gauges, and I want to add another gauge on-the-fly, can I do that? Every time I try modifying things at run-time, it just messes everything up. -Kurt
2005 Sep 09
0
cumulativeOffset problem with dynamically loaded elements
I have a page where I am replacing a table element after the page has loaded. I get an error (on ie 6) when prototype.js calls cumulativeOffset. For the new table element, requesting the element.offsetParent property results in an "unspecified error" that brings my whole page to a crashing halt. Does anyone have any ideas or suggestions? Thanks, Cathy -------------- next part