Re: [R] skip for loop

2010-04-05 Thread Etienne Bellemare Racine
you can use break :
for(i in 1:5) {
 #e.g.
 a <- sample(1:10, 1)
 # important part :
 if(a==3) break
}
a

or while :
a <- 0
while(a != 3){
 # an operation that change a :
a <- sample(1:10, 1)
}

Etienne

Le 2010-04-05 10:46, Ravi S. Shankar a écrit :
> Hi R,
>
>
>
> I am running a for loop in which I am doing a certain calculation. As an
> outcome of calculation I get an out put say "a". Now in my for loop "I"
> needs to be initiated to "a".
>
>
>
> Based the below example if the output "a"=3 then the second iteration
> needs to be skipped. Is there a way to do this?
>
> for(i in 1:5)
>
> {
>
> ##Calculation##
>
> a=3 ## outcome of calculation
>
> }
>
>
>
> Any help appreciated. Thanks in advance for the time!
>
>
>
> Regards
>
> Ravi
>
>
>
> This e-mail may contain confidential and/or privileged i...{{dropped:13}}
>
> __
> 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.


Re: [R] Unrealistic dispersion parameter for quasibinomial

2010-03-04 Thread Etienne Bellemare Racine

Ben Bolker wrote :

The dispersion parameter depends on the Pearson residuals,
not the deviance residuals (i.e., scaled by expected variance).
I haven't checked into this in great detail, but the Pearson
residual of your first data set is huge, probably because
the fitted value is tiny (and hence the expected variance is
tiny) and the observed value is 0.2.


dfr <- df.residual(model2)
deviance(model2)/dfr
d2 <- sum(residuals(model2,"pearson")^2) 
(disp2 <- d2/dfr) 
fitted(model2)

residuals(model2,"pearson")
Sorry to dig that one from one year ago, but it seems it is still 
interesting (at least to me).
From summary.glm, it looks like the deviance is obtained by the working 
type deviance, which gave close results to pearson type (when working 
residuals are multiplied by the weights). I couldn't find a lot of 
information on the working type.  How is it computed (from ?glm, I know 
that these are «the residuals in the final iteration of the IWLS fit») ?


sum(model2$weights * residuals(model2, type="working")^2)
sum(residuals(model2, type="pearson")^2)

Maybe I'm wrong, but could someone clarify that (which type is used and 
what difference it makes) ?


Thank you in advance,
Etienne

__
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] choose.files limit?

2009-12-09 Thread Etienne Bellemare Racine
Gunnar,

Did you find a solution, I'm facing the same problem (would like to load 
2868 files in one go). Is it a bug, or just something that should be 
documented in the help. Also, the error message is misleading, as it say 
it «cannot find» a certain file (the name given here is truncated in my 
case), instead of «too much files selected».

I'm not really familiar with bug filling, could someone with more 
experience tell if it's really a bug ? It's easy to reproduce, just 
select a lot of files (I couldn't find the exact number unlike Gunnar) 
with choose.files().

Etienne

Gunnar W. Schade a écrit :
> Howdy,
>
> When I use the choose.files command to read files a large number of 
> file names to a character vector inside a function, used to access 
> these files one after the other, there appears to be a limit. I do not 
> know whether it is arbitrary, but in this case the limit was 991 
> files. The file names are long. Does that matter? The error message 
> that appears says that it cannot find file #992 (giving the file 
> name), although it is certainly there (I tried changing which file is 
> #992 and it did not matter).
>
> Suggestions?
>
> - Gunnar
>
>
> ---
> Dr. Gunnar W. Schade
> Assistant Professor
> Texas A&M University
> Department of Atmospheric Sciences
> 1104 Eller O&M Building
> 3150 TAMU
> College Station, TX 77843-3150
> USA
>
> ph.: 979 845 0633
> Fax: 979 862 4466
>
> __
> 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.


Re: [R] Separating variables in read.table

2009-04-17 Thread Etienne Bellemare Racine
see ?attach

Etienne

Richardson, Patrick a écrit :
> If I have a table (we'll call it, "test") containing two columns (as below):
>
> i x1  x2  x3  x4  x5  y
> 0 1.125   0.232   7.160   0.0859 8.905 1.5563
> 7 0.920   0.268   8.804   0.0865 7.388 0.8976
> 150.835   0.271   8.108   0.0852 5.348 0.7482
> 221.000   0.237   6.370   0.0838 8.056 0.7160
> 291.150   0.192   6.441   0.0821 6.960 0.3130
> 370.990   0.202   5.154   0.0792 5.690 0.3617
> 440.840   0.184   5.896   0.0812 6.932 0.1139
> 580.650   0.200   5.336   0.0806 5.400 0.1139
>
>
> Is there a simple command to break this table into individual variables 
> without having to code:
>
> i <- test$i
> x1 <- test$x1
> x2 <- test$x2
> .
> .
> .
> And so on. . 
>
> Many Thank for any assistance.
>
> Patrick
> This email message, including any attachments, is for ...{{dropped:12}}

__
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] Get user system name

2009-03-16 Thread Etienne Bellemare Racine
This one is the one working for me. Thanks !

--
Etienne

Gábor Csárdi a écrit :
> Etienne,
>
>   
>> Sys.info()["user"]
>> 
> user
> "csardi"
>
> Best,
> Gabor
>
> On Mon, Mar 16, 2009 at 11:04 PM, Etienne Bellemare Racine
>  wrote:
>   
>> I would like to get the name of the user form the system. Is it possible ?
>> Something like
>>  >system.user()
>> returning something like
>> [1] "etber12"
>>
>> Thanks,
>> Etienne
>>
>>[[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.
>>
>> 
>
>
>
>   

[[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] Get user system name

2009-03-16 Thread Etienne Bellemare Racine
It seems like it is not defined. I get an empty string. Is there a 
workaround or another solution ?

--
Etienne

Sundar Dorai-Raj a écrit :
> Assuming "USER" is defined on your system then
>
> Sys.getenv("USER")
>
> ought to work.
>
> --sundar
>
> On Mon, Mar 16, 2009 at 3:04 PM, Etienne Bellemare Racine
>  wrote:
>   
>> I would like to get the name of the user form the system. Is it possible ?
>> Something like
>>  >system.user()
>> returning something like
>> [1] "etber12"
>>
>> Thanks,
>> Etienne
>>
>>[[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.
>>
>> 

[[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] Get user system name

2009-03-16 Thread Etienne Bellemare Racine
I would like to get the name of the user form the system. Is it possible ?
Something like
 >system.user()
returning something like
[1] "etber12"

Thanks,
Etienne

[[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] ggplot: problem with fill option in stat_smooth()

2009-02-04 Thread Etienne Bellemare Racine
Maybe you could try to open the pdf in Inkscape http://www.inkscape.org/ 
and export it as a .emf or .png ?

Etienne

Ian Fiske a écrit :
> Hi all,
>
> I am using ggplot2 and continuing to find it very useful and pretty. 
> However, I am trying to create some graphics for publication that would be
> included in an MS Word document (not my choice!) in Windows Vista.
>
> The problem is that I want to use stat_smooth() to add an fitted linear
> model line along with its 95% confidence band, but I cannot seem to get the
> confidence band in a format that would import into Word.  I have read the
> documentation and am using the fill="grey50" argument to eliminate
> transparency as a potential problem.  But still, I have tried nearly all
> export formats and the only one that correctly shows the confidence band is
> PDF, which I cannot import into Word as a vector graphic.
>
> This makes me wonder if the fill="grey50" option is working as advertised.
>
> Here is a simple example using the mtcars data set included with ggplot2:
> qplot(wt,mpg,data=mtcars) + stat_smooth(fill="grey50")
>
> I even tried the Cairo library as one R-help post suggested, but to no
> avail.
>
> Any suggestions?
>
> Thanks much,
> Ian Fiske
>   

[[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] Create data frame from header only

2008-08-04 Thread Etienne Bellemare Racine
Hi all,

Given a string list,
> paste("A",1:5,sep="")
[1] "A1" "A2" "A3" "A4" "A5"

I would like to create an empty data frame using that list as the 
header, so I can access my data frame column using,
> df [ list [ i ] ]

Anyone ?

Thanks,
Etienne



[[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] Working with LiDAR .las files

2008-06-15 Thread Etienne Bellemare Racine
Hi,

I am working with airborne LiDAR data and R. Do you know of any package 
or project designed to achieve that goal ? Largely, if you are using R 
and .las files (or lidar data), I would like to hear about your work 
flow. Otherwise, if you know of a package that can help handling x,y,z 
data (i.e., visualisation, sampling, triangulation, etc.) I would also 
like to hear about it.

Currently, I transfer .las files to .dbf and then read them with foreign 
package to a data frame. I take a smaller sample and plot it with rgl or 
scattereplot3d. But I would like to read directly from las to data 
frame, and if it is too large, specify a study area.

[[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.