similar to: How to stop execution

Displaying 20 results from an estimated 10000 matches similar to: "How to stop execution"

2007 Dec 03
1
Fwd: source('clipboard')
In the code below the first source command works fine, but the second does not, as can be seen from the error message. Is there a way to have the second command work? I am using R 2.6.1 on Windows Vista. (The command that is in the clipboard is just "x <- 3") > source("clipboard", echo = F) > source("clipboard", echo = T) Error in file(srcfile$filename,
2005 Apr 27
3
Time series indexes
I tried to assign values to specific elements of a time series and got in trouble. The code below should be almost self-explanatory. I wanted to assign 0 to the first element of x, but instead I assigned zero to the second element of x, which is not what I wanted. Is there a function that will allow me to do this without going into index arithmetic (which would be prone to errors)? FS >
2006 Feb 02
2
How to get the namespace of a function?
I declared the environment of the function myfun to be NULL as follows: environment(myfun) <- NULL Later on I called that myfun and got an error message because the function index() in the zoo package was called inside myfun and was not visible: Error in myfun(args) : couldn't find function "index" I tried to use zoo::index() instead of index(), but that did not work. In fact,
2006 May 20
3
sapply and Date objects
This is probably a dumb question, but I cannot figure it out. Why does this happen? dt <- as.Date("1954-02-01") > as.character(dt) [1] "1954-02-01" > sapply(c(dt), as.character) [1] "-5813" Thanks. FS
2005 Apr 27
3
assign to an element of a vector
I am trying to find a way to assign values to elements of a vector that will be defined by a user. So I don't have the name of the vector and cannot hard code the assignment in advance. In the example below I have to get() the vector using its name. When I try to assign to an element I get an error: > a <- c(1,2,3) > get('a')[1] <- 0 Error: Target of assignment expands to
2005 Apr 26
2
Extending time series
I noticed that when one tries to extend a time series (ts) object by a single period using window() actually two observations (NAs) are added. See below for an example. Does anyone know the reason for this behavior and how to avoid it? Thanks. FS > x<-ts(c(1,2,3)) > x1<- window(x, start(x), end(x) + 1, extend = TRUE) > x1 Time Series: Start = 1 End = 5 Frequency = 1 [1] 1 2
2005 Apr 15
2
Define "local" function
I discovered a bug in a program I am writing which was due to the program using a global variable within a function. For example, myfunc <- function(x) { y} That is, I made a mistake when defining the function and wrote "y" when I should have written "x". However, there was a variable y in the global environment and the function "worked" but gave the wrong
2008 Oct 21
3
R command line
Hi! Is there a Gui for R with improvements in the command line? I'm not looking for buttons, menus and etc, but (more) colored syntax, auto-complete commands and etc? Best regards, Raphael Saldanha saldanha.plangeo@gmail.com [[alternative HTML version deleted]]
2003 Apr 18
2
Keyboard problem using RWin 1.7.0
I just installed RWin 1.7.0 on an Intel box running Win2000 Pro. If I try to paste from the clipboard to the console command line, the command(s) are executed, but the console then stops responding to the keyboard. The only way I have found to continue is to use the mouse to shut down R. Typing in the console works just fine; commands are executed, command-line editing is ok, source-ing
2009 Jul 03
2
R on flash
Hi! Is there some R version for flashdisk, pendrive etc ? -- Regards, Raphael Saldanha saldanha.plangeo@gmail.com [[alternative HTML version deleted]]
2011 Nov 29
1
Read TXT file with variable separation
Hi! I have to import some TXT files into R, but the separation between the columns are made with different blank spaces, but each file use the same separation. Example: 31 104 5 0 11RUA SAO SEBASTIAO 25 BAIRRO FILETO 01
2008 Jan 16
3
Rprofile.site not executed?
It seems that my Rprofile.site file is not executed when I start R. To test this I included the following code in that file: .First <- function(){ cat("\nWelcome at", date(), "\n") flush.console() } When I start R the message above is not displayed. I am running R 2.6.1 (rgui.exe) under Vista Home Premium. The Rprofile.site is in the etc folder and the R_PROFILE
2008 Dec 02
4
Variables inside a for
Hi! I had a database with some variables in sequence. Let me say: TX01, TX02, TX03 and TX04. But I need to run some regressions changing the variables... so: variable <- paste("TX0", 1:4, sep="") for(i in 1:4){ test[i] <- lm(variable[i] ~ INCOME, data=database) } But doesn't work... lm tries to find a variable inside database named variable[i] ... Suggestions?
2005 Apr 26
1
Time alignment of time series
One thing that has given me trouble is the fact that the time series implementation in the class ts relies on the concept of a "start" to the time series. For example, if I have ts1 <- ts(c(1,2,3)) dts1 <- diff(ts1) then dts1 will be a vector c(1,1) but with the attribute start = 2. Similarly, when one takes lags the "start" is moved around and the underlying vector
2008 Mar 22
1
Geting names of variables
I wanted to create a list with the names of variables and their values. So I wrote the following function. add.to.list.names.vars.1 <- function(lnv, vnv) { i <- 1 while (i < length(vnv)) { z <- as.character(eval(substitute(quote(vnv[i+1])))[[2]][[i + 2]]) lnv[[vnv[i]]] <- list(Name = z, Value = vnv[i+1]) i <- i + 2 } lnv } It works, but it is very
2008 Apr 27
1
system.time()
I thought system.time() would return three numbers, the first two adding up to the third one. However, this does not hold in my system running Windows Vista Home Premium, with an Intel Core 2 Duo processor. For example, using the code in the help for system.time() (with one zero added), I got: > system.time(for(i in 1:100) mad(runif(10000))) user system elapsed 0.27 0.00 0.25 Is
2008 Jul 26
2
Sample
Hi! I have a data.frame, like this one: > data 0-100 100-250 250+ a 9 18 16 b 33 25 27 c 21 19 17 d 25 22 19 e 40 39 19 f 77 45 29 If I request a sample of 2, I have the following: > sample(data, 2) 0-100 250+ a 9 16 b 33 27 c 21 17 d 25 19 e 40 19 f 77 29 How can I request a sample from the
2009 Jul 02
1
Box Plot outliers label
Hi! How can I add labels in the outliers inside a boxplot. Here is my code, at now: mun <- as.data.frame(read.csv2("consolidada_v3.csv")) micro <- mun$nmicro medprop <- mun$medprop mimedprop <- split(medprop, micro) boxplot(mimedprop, col="chartreuse3", main="Área média das propriedades rurais", xlab="Microrregiões", ylab="ha") I
2008 May 17
1
Recode
Hi! Using recode in cars package, I tryed to use the following: recode(data$nrcomp, "lo:5='0 to 5'; 5:hi='bigger than 5'") I got: Erro em parse(text = strsplit(term, "=")[[1]][2]) : unexpected end of input in "'0 to 5" When I try only numbers, or only text, it's ok, but when I try to combine numbers and text, I got a error... Any help?
2008 Jul 26
2
Spatial Sample
Hi! How can I make a spatial sample? Can someone recommend theorical books and materials for this? -- Raphael Saldanha UFJF - Brazil [[alternative HTML version deleted]]