[R] weird behavior with the 3rd root....

2008-10-26 Thread Juan Manuel Barreneche
Well, this is what i got...

> -0.084121928394^(1/3)
[1] -0.438163696867656
> (-0.084121928394)^(1/3)
[1] NaN

and i don't have a clue of why this happens or how to avoid it, any suggestions?

thank you,
Juan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] address (nil), cause 'memory not mapped'

2008-08-19 Thread Juan Manuel Barreneche
just to mention that the loop was already running for about 20 hours...

Juan

On Tue, Aug 19, 2008 at 6:31 PM, Juan Manuel Barreneche
<[EMAIL PROTECTED]>wrote:

> Dear users,
> I got this problem and i don't have a clue of what it could be happening...
>
> The context: i'm running a loop in which i extract information from a
> raster map (I work with GRASS and R, using spgrass6 package), and rearrange
> it to create a matrix. I've tried it with small maps and it works smoothly,
> but in large maps I have to resort to saving data in the hard disk regularly
> in order to avoid the "cannot allocate vector of size..." problem (builted
> in the loop itself).
>
> Even so, the message "address (nil), cause 'memory not mapped'" appeared,
> and i really don't have a clue of what it means.
>
> I run R 2.7.0 on openSUSE 10.2
>
> If anyone can be of any help, it'll be greatly appreciated... below I'm
> writing the output i got (and the R.Version() output...)
>
> thank you,
>
> Juan
>
> 
> Null cells excluded from cost evaluation.
> Source map is: Floating point (double) cell type
> 189 rows, 178 cols
> Creating some temporary files
> Reading riosypondas3000
>  100%
> Initializing output
>  100%
> Finding cost path
> Writing nombre
> Double cell type.
> Writing...
>  100%
> Peak cost value: 13.614127
> Creating BIL support files...
> Header File =
> /home/mastermind/GRASSDATA//yacare1/jmb/.tmp/SpongeBob/nombre.hdr
> World File =
> /home/mastermind/GRASSDATA//yacare1/jmb/.tmp/SpongeBob/nombre.wld
> Exporting raster as double values (bytes=8)
> Using the current region settings...
> north=6681799.617727
> south=6115500.667945
> east=756812.903880
> west=223200.856418
> r=189
> c=178
>  100%
> 
>
>  *** caught segfault ***
> address (nil), cause 'memory not mapped'
>
> Traceback:
>  1: system("g.proj -j -f", intern = TRUE, ignore.stderr = ignore.stderr)
>  2: ifelse(.Platform$OS.type == "windows", projstr <- system("g.proj -j
> -f", intern = TRUE), projstr <- system("g.proj -j -f", intern =
> TRUE, ignore.stderr = ignore.stderr))
>  3: getLocationProj()
>  4: nchar(projargs)
>  5: CRS(getLocationProj())
>  6: readRAST6("nombre")
>  7: dist.grass(matrizPaisaje.riosypondas3000, "riosypondas3000", direct
> = "/home/mastermind/r/distancias", division = 17)
>  8: eval(expr, envir, enclos)
>  9: eval(parse(text = sprintf("dist.%s <<- dist.grass(matrizPaisaje.%s,
> '%s', direct='%s', division=%s)", i, i, i, direct, division)))
> 10: dist.grass.loop(c("riosypondas3000", "maxent3000",
> "alturas3000.2"), direct = "/home/mastermind/r/distancias", division =
> 17)
> 11: eval(expr, envir, enclos)
> 12: eval(expr, envir = loc.frame)
> 13: system.time(dist.grass.loop(c("riosypondas3000", "maxent3000",
> "alturas3000.2"), direct = "/home/mastermind/r/distancias", division =
> 17))
>
> Possible actions:
> 1: abort (with core dump, if enabled)
> 2: normal R exit
> 3: exit R without saving workspace
> 4: exit R saving workspace
>
> > R.Version()
> $platform
> [1] "i686-pc-linux-gnu"
>
> $arch
> [1] "i686"
>
> $os
> [1] "linux-gnu"
>
> $system
> [1] "i686, linux-gnu"
>
> $status
> [1] ""
>
> $major
> [1] "2"
>
> $minor
> [1] "7.0"
>
> $year
> [1] "2008"
>
> $month
> [1] "04"
>
> $day
> [1] "22"
>
> $`svn rev`
> [1] "45424"
>
> $language
> [1] "R"
>
> $version.string
> [1] "R version 2.7.0 (2008-04-22)"
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] address (nil), cause 'memory not mapped'

2008-08-19 Thread Juan Manuel Barreneche
Dear users,
I got this problem and i don't have a clue of what it could be happening...

The context: i'm running a loop in which i extract information from a raster
map (I work with GRASS and R, using spgrass6 package), and rearrange it to
create a matrix. I've tried it with small maps and it works smoothly, but in
large maps I have to resort to saving data in the hard disk regularly in
order to avoid the "cannot allocate vector of size..." problem (builted in
the loop itself).

Even so, the message "address (nil), cause 'memory not mapped'" appeared,
and i really don't have a clue of what it means.

I run R 2.7.0 on openSUSE 10.2

If anyone can be of any help, it'll be greatly appreciated... below I'm
writing the output i got (and the R.Version() output...)

thank you,

Juan


Null cells excluded from cost evaluation.
Source map is: Floating point (double) cell type
189 rows, 178 cols
Creating some temporary files
Reading riosypondas3000
 100%
Initializing output
 100%
Finding cost path
Writing nombre
Double cell type.
Writing...
 100%
Peak cost value: 13.614127
Creating BIL support files...
Header File =
/home/mastermind/GRASSDATA//yacare1/jmb/.tmp/SpongeBob/nombre.hdr
World File =
/home/mastermind/GRASSDATA//yacare1/jmb/.tmp/SpongeBob/nombre.wld
Exporting raster as double values (bytes=8)
Using the current region settings...
north=6681799.617727
south=6115500.667945
east=756812.903880
west=223200.856418
r=189
c=178
 100%


 *** caught segfault ***
address (nil), cause 'memory not mapped'

Traceback:
 1: system("g.proj -j -f", intern = TRUE, ignore.stderr = ignore.stderr)
 2: ifelse(.Platform$OS.type == "windows", projstr <- system("g.proj -j
-f", intern = TRUE), projstr <- system("g.proj -j -f", intern =
TRUE, ignore.stderr = ignore.stderr))
 3: getLocationProj()
 4: nchar(projargs)
 5: CRS(getLocationProj())
 6: readRAST6("nombre")
 7: dist.grass(matrizPaisaje.riosypondas3000, "riosypondas3000", direct
= "/home/mastermind/r/distancias", division = 17)
 8: eval(expr, envir, enclos)
 9: eval(parse(text = sprintf("dist.%s <<- dist.grass(matrizPaisaje.%s,
'%s', direct='%s', division=%s)", i, i, i, direct, division)))
10: dist.grass.loop(c("riosypondas3000", "maxent3000", "alturas3000.2"),
direct = "/home/mastermind/r/distancias", division = 17)
11: eval(expr, envir, enclos)
12: eval(expr, envir = loc.frame)
13: system.time(dist.grass.loop(c("riosypondas3000", "maxent3000",
"alturas3000.2"), direct = "/home/mastermind/r/distancias", division =
17))

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

> R.Version()
$platform
[1] "i686-pc-linux-gnu"

$arch
[1] "i686"

$os
[1] "linux-gnu"

$system
[1] "i686, linux-gnu"

$status
[1] ""

$major
[1] "2"

$minor
[1] "7.0"

$year
[1] "2008"

$month
[1] "04"

$day
[1] "22"

$`svn rev`
[1] "45424"

$language
[1] "R"

$version.string
[1] "R version 2.7.0 (2008-04-22)"

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] problem with save function

2008-08-18 Thread Juan Manuel Barreneche
well i see i've been really foolish, sorry & thank you!

Juan

On Mon, Aug 18, 2008 at 9:09 PM, Henrik Bengtsson <[EMAIL PROTECTED]>wrote:

> ...and see saveObject() and loadObject() in R.utils, which might do
> what you expected, e.g.
>
> > x <- stats::runif(20)
> > y <- list(a=1, b=TRUE, c="oops")
> > saveObject(list(foo=x,bar=y), "xy.Rdata")
> > xy <- loadObject("xy.Rdata")
> > str(xy)
> List of 2
>  $ foo: num [1:20] 0.1154 0.6534 0.0876 0.5977 0.6841 ...
>  $ bar:List of 3
>  ..$ a: num 1
>  ..$ b: logi TRUE
>  ..$ c: chr "oops"
>
> /Henrik
>
> On Mon, Aug 18, 2008 at 5:02 PM, Rolf Turner <[EMAIL PROTECTED]>
> wrote:
> >
> > Read the help for load(); note the ``Value'' section.
> >
> >cheers,
> >
> >Rolf Turner
> >
> > On 19/08/2008, at 11:51 AM, Juan Manuel Barreneche wrote:
> >
> >> Hello list! i write because i'm having a strange problem with the "save"
> >> function, here an example:
> >>
> >>> x <- stats::runif(20)
> >>> y <- list(a = 1, b = TRUE, c = "oops")
> >>> save(x, y, file = "xy.Rdata")
> >>> xy <- load("xy.Rdata")
> >>> xy
> >>
> >> [1] "x" "y"
> >>
> >> why does this happens, when:
> >>>
> >>> x
> >>
> >>  [1] 0.96586833 0.60340508 0.23465887 0.01415043 0.57691296 0.13302310
> >>  [7] 0.01874176 0.59097297 0.41550847 0.76732502 0.01802066 0.11413294
> >> [13] 0.93441672 0.70013043 0.10277732 0.43738180 0.96744498 0.45388743
> >> [19] 0.84598918 0.96785481
> >>>
> >>> y
> >>
> >> $a
> >> [1] 1
> >>
> >> $b
> >> [1] TRUE
> >>
> >> $c
> >> [1] "oops"
> >>
> >> I run R in openSUSE 10.2, in KDE with Konsole, my version and OS
> >> information
> >> is:
> >>>
> >>> R.Version()
> >>
> >> $platform
> >> [1] "i686-pc-linux-gnu"
> >> $arch
> >> [1] "i686"
> >> $os
> >> [1] "linux-gnu"
> >> $system
> >> [1] "i686, linux-gnu"
> >> $status
> >> [1] ""
> >> $major
> >> [1] "2"
> >> $minor
> >> [1] "7.0"
> >> $year
> >> [1] "2008"
> >> $month
> >> [1] "04"
> >> $day
> >> [1] "22"
> >> $`svn rev`
> >> [1] "45424"
> >> $language
> >> [1] "R"
> >> $version.string
> >> [1] "R version 2.7.0 (2008-04-22)"
> >>
> >> many thanks in advance,
> >>
> >> Juan
> >>
> >>[[alternative HTML version deleted]]
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >
> >
> > ##
> > Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] problem with save function

2008-08-18 Thread Juan Manuel Barreneche
Hello list! i write because i'm having a strange problem with the "save"
function, here an example:

> x <- stats::runif(20)
> y <- list(a = 1, b = TRUE, c = "oops")
> save(x, y, file = "xy.Rdata")
> xy <- load("xy.Rdata")
> xy
[1] "x" "y"

why does this happens, when:
> x
 [1] 0.96586833 0.60340508 0.23465887 0.01415043 0.57691296 0.13302310
 [7] 0.01874176 0.59097297 0.41550847 0.76732502 0.01802066 0.11413294
[13] 0.93441672 0.70013043 0.10277732 0.43738180 0.96744498 0.45388743
[19] 0.84598918 0.96785481
> y
$a
[1] 1

$b
[1] TRUE

$c
[1] "oops"

I run R in openSUSE 10.2, in KDE with Konsole, my version and OS information
is:
> R.Version()
$platform
[1] "i686-pc-linux-gnu"
$arch
[1] "i686"
$os
[1] "linux-gnu"
$system
[1] "i686, linux-gnu"
$status
[1] ""
$major
[1] "2"
$minor
[1] "7.0"
$year
[1] "2008"
$month
[1] "04"
$day
[1] "22"
$`svn rev`
[1] "45424"
$language
[1] "R"
$version.string
[1] "R version 2.7.0 (2008-04-22)"

many thanks in advance,

Juan

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fit a sine to data

2008-05-23 Thread Juan Manuel Barreneche
i guess nls or gnls should work

JM

El Viernes, 23 de Mayo de 2008 10:47, Zroutik Zroutik escribió:
> Dear R-users,
>
> I'd like to fit a sine function to my data. The result should have a format
> (and thus the formula, too)
>
> y ~ a + sin(x+b)
>
> where y and x are vectors, and a and b are (yet) unknown values.
>
> The data sets (vectors x and y) are OK, and I can do a simple lm fitting
> lm(y~x), or lm(y~I(sin(2*pi*x/360))), succesfully  My issue is that I'm not
> able to do the optional linear shift in x (e.g. x+b). What other
> possibilities should I use instead of lm? I looked searched the R-seek for
> terms: fit, sine, lm, and combinations, but I could not find anything
> useful. Anybody would be so kind and point me to the right direction where
> I can find other fitting possibilities?
>
> Thank you for listening and kind answers upfront.
>
> Regards,
> Milan
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html and provide commented, minimal,
> self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Plotting 3 Time Series

2008-05-22 Thread Juan Manuel Barreneche
Hi ngupta:
i didn't get what you mean with "If B than
xts..If T yts..."
i suppose that you want to plot the prices of type A, then the prices of type 
B and so on...

# well, to extract prices of tipe A, you can use 
A <- which(table[,1] == "A")
# and then
A.prices <- table[,2][A]

hope that helps,

JM

El Jueves, 22 de Mayo de 2008 11:29, ngupta escribió:
> Hi, I am fairly new to R so this may be easy for some.
> I have one column that is the Type="A, B' T"
> and I have another column that lists Price='894, 895, 896'
>
> I wanted to plot three different series based upon the Type...If B than
> xts..If T yts...
>
> How exactly do I do this?
>
> Thanks in advance

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R for loop question

2008-05-20 Thread Juan Manuel Barreneche
I had to do the same thing many times, i usually use a combination of the 
functions "eval", "parse" and "sprinf", as below:

k <- 1
for (i in 1:length(stats$hour)) {
   eval(parse(text=sprintf("x%s <- dataset[%s,(3:15)]", i, k)))
   k <- k+1
}

what it does is:
eval(parse(text=STRING)) is a way to execute what is written on STRING
and 
sprintf("TEXT%sTEXT", VARIABLE) substitutes the %s part of the text in the 
first argument for whatever is on the second argument (you can extend this to 
many %s parts)

Note: i've changed the "=" for the "<-" because someone told me that it was 
more correct (don't ask me why though!). 

JM

El Martes, 20 de Mayo de 2008 13:58, Douglas M. Hultstrand escribió:
> Hello,
>
> I am trying to assign a variable name (x1,x2,x3...) in a loop statement
> that is based on a counter (counter is based on the number of hours
> within the datafile).  The x1,x2 data will later be called for plotting
> the data.  Below is a clip of the for loop I am using, any suggestions?
>
> k = 1
> for (i in 1:length(stats$hour)) {
>   "x(i)" = dataset[k,(3:15)]
>   k = k+1
>  }
>
> Thanks,
> Doug

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Importing data

2008-05-07 Thread Juan Manuel Barreneche
i usually import data from exel, using read.table or read.csv (which implies 
that i have to save exel files as .txt or .csv)

JM

El Miércoles, 7 de Mayo de 2008 11:25, John Kane escribió:
> First step would be to read the manual on the R site
> "R Data Import/Export" describes the import and export
> facilities available either in R itself or via
> packages which are available from CRAN
>
> Then if that does not solve the problem you need to
> explain in detail what the problems are, preferably
> with the code that you are using.  See the
> instructions at the bottom of the post.
>
> --- Yemi Oyeyemi <[EMAIL PROTECTED]> wrote:
> > Hi everyone, please I'm having problem importing
> > data from Stata and excel. Help me out.
> >   Thanks
> >
> >
> > -
> > [[elided Yahoo spam]]
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained,
> > reproducible code.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html and provide commented, minimal,
> self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] duplicate rows in a matrix

2007-11-02 Thread Juan Manuel Barreneche
My sugestion (for an alphabetically ordered output)

AA <- rbind(A,A)
AA <- AA[order(AA[,1]), ] ## so your matrix gets alphabetically ordered

JM


On Fri, 2007-11-02 at 09:04 -0700, Silvia Lipski wrote:
> Hi!
> 
> Is there a fast way to duplicate rows in a matrix?
> I would like to do the following:
> 
> change a matrix A like:
>  [,1] [,2] 
>  [1,] Kevin 1
>  [2,] Alf 2
> 
> into :
>  [,1] [,2] 
>  [1,] Kevin 1
>  [2,] Kevin 1
>  [3,] Alf 2
>  [4,] Alf 2
> 
> i.e. double all rows. The only way I could think off
> was: rbind(A[1,],A[1,],A[2,],A[2,]) - which is really
> impractible, of course.
> 
> Can anyone help, please?
> Thank you,
> Silvia
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] find overlap between intervals - Correction

2007-10-31 Thread Juan Manuel Barreneche
I'm not sure if i got the idea of what you want. At fist i thought that
you wanted this output:

Output:
  290  380
  380  440
  440  443
  443  468

to get it, you can use the following function:

intervals <- function(Input)
{
all <- c(Input$Start, Input$End)
numbers <- sort(all[-which(duplicated(all))])
Output <- NULL
for(i in 1:(length(numbers) - 1))
{
Output <- rbind(Output, c(numbers[i], numbers[i+1]))
}
Output
}
## then write:
intervals(Input)


but your output it's a little diferent:

CORRECTED Desired output:
> Start End
> 290   380
> 380   440
> 443   468

and i noticed too late... ¿maybe you missed one interval (440 to 443) in
the desired Output?

JM

On Wed, 2007-10-31 at 15:01 +0100, João Fadista wrote:
> Dear all,
> Sorry for the previous email. I had a wrong example output:
>  
> 
> Input:
> Start End
> 440   443 
> 380   443 
> 290   468
>  
> CORRECTED Desired output:
> Start End
> 290   380
> 380   440
> 443   468
>  
> 
> Best regards,
> Joo Fadista
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.