Re: [R] Problems using save to store NAMED R objects

2015-11-12 Thread Julio Sergio Santana
ote: > On 12/11/2015 6:41 PM, Julio Sergio Santana wrote: > >> I have to store (in a file) an R object that was created with is name as >> a string of characters, as follows: >> >> : nn <- "xxx" >> : assign(nn, 5) >> : xxx >>

[R] Problems using save to store NAMED R objects

2015-11-12 Thread Julio Sergio Santana
I have to store (in a file) an R object that was created with is name as a string of characters, as follows: : nn <- "xxx" : assign(nn, 5) : xxx [1] 5 I don't want to store the object nn but the object xxx. I tried the following two expressions but none of them worked: : save(ge

[R] Using split.screen with a definition matrix of the screens seems to be a mess. I don't understand!

2015-03-17 Thread Julio Sergio Santana
I have a particular need to divide the device space to draw different plots and texts, so I decided to use split.screen using a matrix to define the different space partitions. My code and explanation is as follows: # -- START OF R CODE dirGraf <- "TEST/" # A directory to put the resul

[R] legend with math (greek letters) symbols

2014-09-13 Thread Julio Sergio Santana
I need to add a legend with three entries that should contain a greek letter (lambda). I learnt that it is possible using the function expression. So I need to build the expressions from the lambdas vector, and I simply cannot do it. This is the uggly result I got: x <- 0:20 cc <- c("yellow

Re: [R] Curious behaviour of lapply and lists of functions

2014-01-15 Thread Julio Sergio Santana
Julio Sergio Santana gmail.com> writes: > ... > Producer <- function(f) function(x) 1/f(x) > Counsulting a previous post, I got to the solution, I just need to rewrite the function Producer forcing it to eavaluate its argument, as follows Producer <- function(f) {f

[R] Curious behaviour of lapply and lists of functions

2014-01-15 Thread Julio Sergio Santana
Let's say I define a simple list of functions, as follows lf <- list( function(x) x+5, function(x) 2*x ) Then I can take any individual function from the list and use it with any value, as it is shown: lf[[1]](3) [1] 8 lf[[2]](3) [1] 6 this gives me

Re: [R] R strange behaviour when working with fifos

2013-12-29 Thread Julio Sergio Santana
Julio Sergio Santana gmail.com> writes: > > I'm trying to establish a connection to a pair of fifos in R, one represents > the input stream of a process and the other one the output of the same > process. The problem is that R behaves very different when running the &g

[R] R strange behaviour when working with fifos

2013-12-27 Thread Julio Sergio Santana
I'm trying to establish a connection to a pair of fifos in R, one represents the input stream of a process and the other one the output of the same process. The problem is that R behaves very different when running the commands directly in the interpreter than when running via a script file. He

Re: [R] Using assign with mapply

2013-12-19 Thread Julio Sergio Santana
Greg Snow <538280 gmail.com> writes: > > The take home message that you should be learning from your struggles > is to "Not Use The 'assign' Function!" and "Do Not Use Global > Variables Like This". > > R has lists (and environments) that make working with objects that are > associated with eac

Re: [R] Using assign with mapply

2013-12-16 Thread Julio Sergio Santana
Julio Sergio Santana gmail.com> writes: > > I have a data frame whose first colum contains the names of the variables > and whose second colum contains the values to assign to them: > >: kkk <- data.frame(vars=c("var1", "var2", "var

Re: [R] Using assign with mapply

2013-12-10 Thread Julio Sergio Santana
David Winsemius comcast.net> writes: > So what happens if you try this: > > mapply(assign, kkk$vars, kkk$vals, MoreArgs = list(envir = .GlobalEnv) > Yes, it works in certain situations, as well as the equivalent code: kkk <- data.frame(vars=c("var1", "var2", "var3"),

[R] Using assign with mapply

2013-12-06 Thread Julio Sergio Santana
I have a data frame whose first colum contains the names of the variables and whose second colum contains the values to assign to them: : kkk <- data.frame(vars=c("var1", "var2", "var3"), vals=c(10, 20, 30), stringsAsFactors=F) If I do : assign(kkk$vars[1], kkk$vals

[R] Countour for netCDF-like meshes

2013-10-28 Thread Julio Sergio Santana
Hi, A model gives me as output a netCDF file which I read with ncdf package. The output consists of three similar matrices: one contains the variable value, and the other two, the longitude and latitude coordinates. I need to do a contour graph with such information, however, the R contour funct

Re: [R] Trying to use pipes in R

2012-09-12 Thread Julio Sergio Santana
t;uno dos tres", "cuatro cinco", "seis") > #get individual word count within quotes > res1<-unlist(lapply(strsplit(vec1, " "),length)) > res1 > #[1] 3 2 1 > > #get whole word count > length(unlist(strsplit(vec1, " "))) > #[1] 6

[R] Trying to use pipes in R

2012-09-12 Thread Julio Sergio Santana
Hi, I'm trying to use pipes in R. By now, I could launch the linux command "wc" (to count words from a text), but I don't know how to capture the results, say in a vector of chars... Here is the R code I'm trying: :> f <- pipe("wc", open="w") :> writeLines(c("uno dos tres", "cuatro cinco", "seis")

[R] Some kind of inverse of "names"

2012-08-20 Thread Julio Sergio Santana
I wonder if there exists some kind of inverse of the "names" primitive in R. Let me explain what do I mean: If I create a list: -> li <- list(a=1, b=2, c=3, d=4) then I can have: -> names(li) [1] "a" "b" "c" "d" which is, I guess, some kind of vector, since -> typeof(names(li)) [1] "char

[R] Trying to build up a user interface with the R tcltk package

2012-08-07 Thread Julio Sergio Santana
I'm trying to build up a user inteface using the R tcltk component. Since the documentation for this R library is scarce and poor, I have decided to use only the .Tcl function to pass commands to the tcl interpreter. So I wrote my first very simple tcltk program, hoping to run it from inside R a