similar to: difference between assignment syntax <- vs =

Displaying 20 results from an estimated 20000 matches similar to: "difference between assignment syntax <- vs ="

2009 May 16
3
converting numeric to integer
Hello, Suppose I have x, which is a variable of class numeric. The calculations performed to yield x imply that mathematically it should be an integer , but due to round-off errors, it might not be (and so in either direction). The error is however small, so round(x) will yield the appropriate integer value. Moreover, this integer values is guaranteed to be representable by an
2009 Jan 09
5
The R Inferno
"The R Inferno" is now on the Burns Statistics website at http://www.burns-stat.com/pages/Tutor/R_inferno.pdf Abstract: If you are using R and you think you're in hell, this is a map for you. Also, I've expanded the outline concerning R on the Burns Statistics 'Links' page. Suggestions (off-list) for additional items are encouraged. Patrick Burns patrick at
2009 Mar 13
2
changing function argument
Hi, I wonder if the following is possible in R: Suppose a function takes an argument, and wants to modify this argument so that the change is visible _at the call side_. It would be what is for example known as pass-by-reference-to-non-const in C++. test <- function(x) { x <- 10 ... return (somethingElse) # I do NOT want having to return x } number = 5 test(number)
2009 Sep 17
2
r-inferno.pdf with detailed table of contents and bookmarks
Hi, I don't find a r-inferno.pdf that has detailed table of contents and bookmarks. If it is possible, can somebody help generated one and post it on line? Regards, Peng
2009 Apr 01
4
Variable Wildcard Value
Is there a wildcard value for vector values in r? For instance: > M <- *wildcard > (M==1) TRUE >(M=="peanut butter") TRUE >is.na(M) FALSE thanks, Francis -- Francis Smart (406) 223-8108 cell
2009 Jan 12
2
assign a list using expression?
Dear R-users, I would like to assign elements to a list in the following manner: mylist <- list(a = a, b = b, c = c) To do this I tried myexpr <- expression(a = a, b = b, c = c) mylist <- list( eval(myexpr) ) It ends up by overwriting a when b is assigned and b when c is assigned. Additionally the element of the list does not have a name. Could you tell me why this is the case? Thank
2009 Jul 01
2
'singularity' between fixed effect and random factor in mixed model
Hi, I just came across the following issue regarding mixed effects models: In a longitudinal study individuals (variable ind) are observed for some response variable. One explanatory variable, f, entering the model as fixed effect, is a (2-level) factor. The expression of that factor is constant for each individual across time (say, the sex of the individual). ind enters the model as grouping
2009 Feb 11
2
generalized mixed model + mcmcsamp
Hi, I have fitted a generalized linear mixed effects model using lmer (library lme4), and the family = quasibinomial. I have tried to obtain a MCMC sample, but on calling mcmcsamp(model1, 1000) I get the following error which I don't understand at all: Error in .local(object, n, verbose, ...) : Update not yet written traceback() delivers: 4: .Call(mer_MCMCsamp, ans, object) 3:
2009 Jun 04
4
order() with randomised order in ties?
Hi I want to use order() to get the order of a vector. But I would need a different behavior when ties occur: similar to the parameter ties.method = "random" in the rank() function, I would need to randomise the ties. Is this possible? Example: x <- rep(1:10, 2) order(x) [1] 1 11 2 12 3 13 4 14 5 15 6 16 7 17 8 18 9 19 10 20 order(x) [1] 1 11 2 12 3 13 4 14 5 15
2009 Jun 16
3
The most straightfoward way to write a function that sums over the rows of a matrix
Hello! I am trying to write a function with vector and data.frame parameters that uses the sum() function and values from the rows of the data.frame. I need to pass this function as a parameter to optim(). My starting point is: observs <- data.frame(y, x1, x2, x3) Fn <- function(par, observs) { sum( (y - (par[1] * (x1 + 1) * x2^(-par[2]) * x3^par[3])^2 ) }
2009 Mar 27
3
nls, convergence and starting values
"in non linear modelling finding appropriate starting values is something like an art"... (maybe from somewhere in Crawley , 2007) Here a colleague and I just want to compare different response models to a null model. This has worked OK for almost all the other data sets except that one (dumped below). Whatever our trials and algorithms, even subsetting data (to check if some singular
2009 Aug 05
3
how import Excel data into R?
Hi I want to import Excel data into R I have used this code data<-read.table("C:\Total_Art_Policies.xls",header=TRUE,sep=";") i have an error msg: Erreur dans file(file, "r") : impossible d'ouvrir la connexion De plus : Warning message: In file(file, "r") : impossible d'ouvrir le fichierĀ 'C:\Total_Art_Policies.xls' : No such file or
2009 Nov 16
4
Where are usages like "== 2L" documented?
Gurus: I keep seeing other people?s code that contain ideas like If (x == 2L) X[-1L] X - 1L I have some idea of what?s going on, but where is the use of concepts like ?2L? documented? Thanks, Bryan ************* Bryan Hanson Acting Chair Professor of Chemistry & Biochemistry DePauw University, Greencastle IN USA
2009 Aug 03
2
Variable names as inputs...
Hi, I have been using R for a bit, but never came across this simple issue... So, I wonder if anyone could give me a hint on it. I have calculated a bunch o models and now need to compare them using AIC(). The issue seem to be that I have placed each output in a list object. So, the question is how to convert a string into variable names. Lets say I have all my models in a variables called :
2009 Jan 28
2
length of POSIXlt object (PR#13482)
The length() of a POSIXlt object is given as 9 regardless of the actual length. For example: > make.date.time function (year=c(2006,2006),month=c(8,8),day=2:5,hour=13,minute=45) {# convert year, etc., into POSIXlt object # d=as.character(make.date(year,month,day)) t=paste(hour,minute,sep=":") as.POSIXlt(paste(d,t)) } > t=make.date.time() > t [1] "2006-08-02 13:45:00"
2009 Mar 05
3
character string as object name
Can someone please tell me why the following (last line) doesn't work (as I expect it to :-) library(quantmod) a = getSymbols("MSFT",from="2009-3-01") a MSFT eval(as.name(a)) MSFT$MSFT.Adjusted b=paste(a,'$MSFT.Adjusted',sep='') b eval(as.name(b)) Why does this last line not work the way the earlier eval does? Thanks.
2009 May 07
2
for loop vectorization
Hi, I am still not familiar with vectorization. Could you help with making this for loop more efficient? The code is trying to make a Q matrix for a multidimensional state space with specific conditions. thanks Mira tmp = 0:(maxvals[1]) for(i in 2:nchars) { tmp <- outer(tmp, 0:(maxvals[i]), FUN="paste", sep=".") } states = tmp stateidx = array(1:length(states),
2023 Nov 08
1
Problem in R code
Good afternoon, I have been working on my thesis project on the topic "Urban Heat Island Pattern in India". To achieve the results I am applying a* two-dimensional Gaussian fit* on an LST raster of 1 km spatial resolution but I am facing two errors in the following code. library(raster) LST <- raster("D:/Celsius_Day/MOD_01.tif") gaussian2d <- function(x, y, mu_x, mu_y,
2011 Dec 11
3
how to assign a value?
Hi there, I hope to modify values in a vector or matrix in the following code: for (i in 1:9) { assign(paste("a.", i, sep = ""), 1:i) get(paste("a.", i, sep = ""))[i] <- i+50 } I get the following error message: Error in get(paste("a.", i, sep = ""))[i] <- i + 50 : target of assignment expands to non-language object
2009 Jan 29
2
tab characters
Hi all, Working at the R command line, how do I get strings to display e.g. tab or newline characters as they should be displayed, rather than as e.g. \n or \t? e.g.: > x="\t" > x="\t" > x [1] "\t" > print(x) [1] "\t" -- ==================================================== Nicholas J. Matzke Ph.D. student, Graduate Student Researcher