Re: [R] Optimisation and NaN Errors using clm() and clmm()

2013-04-20 Thread Rune Haubo
On 18 April 2013 18:38, Thomas Foxley  wrote:
> Rune,
>
> Thank you very much for your response.
>
> I don't actually have the models that failed to converge from the first
> (glmulti) part as they were not saved with the confidence set. glmulti
> generates thousands of models so it seems reasonable that a few of these may
> not converge.
>
> The clmm() model I provided was just an example - not all models have 17
> parameters. There were only one or two that produced errors (the example I
> gave being one of them), perhaps overparameterisation is the root of the
> problem.
>
> Regarding incomplete data - there are only 103 (of 314) records where I have
> data for every predictor. The number of observations included will obviously
> vary for different models, models with fewer predictors will include more
> observations. glmulti acts as a wrapper for another function, meaning (in
> this case) na's are treated as they would be in clm(). Is there a way around
> this (apart from filling in the missing data)? I believe its possible to
> limit model complexity in the glmulti call - which may or may not increase
> the number of observations - how would this affect interpretation of the
> results?

Since the likelihood (and hence also AIC-like criteria) depends on the
number of observations, I would make sure that only models with the
same number of observations are compared using model selection
criteria. This means that I would make a data.frame with complete
observations either by just deleting all rows with one or more missing
predictors or by imputing some data points. If one or a couple of
variables  are responsible for most of the missing observations, you
could disregard these variables before deleting rows with NAs.

As I said, I am no expert in model averaging or glmulti usage, so
there might be better approaches or other opinions on this.

Cheers,
Rune

__
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] Spider Plot

2013-04-20 Thread Jim Lemon

On 04/20/2013 06:29 AM, XINLI LI wrote:

Does any one have a sample code for a Spider Plot as attached?


Hi Xing,
Have a look at the third example in the radial.plot function (plotrix).

Jim

__
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] how to set the row name of a specific row

2013-04-20 Thread Simone Gabbriellini
Hello,

I am adding rows to a matrix using rbind() and I would like to also add a
row name to the added row in order to do some sorting after the adding rows
part is finished. is this possible?

Best,
Simone

-- 
Simone Gabbriellini, PhD

PostDoc@DISI, University of Bologna
mobile: +39 340 39 75 626
email: simone.gabbriell...@unibo.it
academia.edu: http://goo.gl/7pq62

DigitalBrains srl
Amministratore
mobile: +39 340 39 75 626
email: simone.gabbriell...@digitalbrains.it
home: www.digitalbrains.it

[[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] MOS-test using package vegan

2013-04-20 Thread Elaine Kuo
Dear all,

I am using MOStest in vegan to examine the hump-shaped of
a quadratic regression model.
In the manual of vegan, it mentions that the value of MOStest include
isHump.
My result showed the quadratic regression is hump-shaped according to the
p-value (nearly 0).
However, the value isHump did not show up.
Please kindly help where to find isHump.

Further, I do not understand the result of the function "plot"
for the MOStested regression model, after reading the manual of vegan.
(There are three graphs in the result, y-x plot, residuals and fitted
regression model, and cook's distance)
Please kindly share any references to interpret the graphs.
Thank you.

Elaine

code
library(vegan)
mos_test  <-  MOStest(BMN,   DIS,  family=gaussian)
plot(mos_test)

[[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] how to set the row name of a specific row

2013-04-20 Thread Rui Barradas

Hello,

It is possible, but do the other rows have names?

x <- matrix(1:12, 4)

x <- rbind(x, c(13:15))
rownames(x)[5] <- "abcd"
x


Hope this helps,

Rui Barradas

Em 20-04-2013 10:58, Simone Gabbriellini escreveu:

Hello,

I am adding rows to a matrix using rbind() and I would like to also add a
row name to the added row in order to do some sorting after the adding rows
part is finished. is this possible?

Best,
Simone



__
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] how to set the row name of a specific row

2013-04-20 Thread Simone Gabbriellini
Hi Rui,

yes, all the other rows have names! Thanks, works perfecty


2013/4/20 Rui Barradas 

> Hello,
>
> It is possible, but do the other rows have names?
>
> x <- matrix(1:12, 4)
>
> x <- rbind(x, c(13:15))
> rownames(x)[5] <- "abcd"
> x
>
>
> Hope this helps,
>
> Rui Barradas
>
> Em 20-04-2013 10:58, Simone Gabbriellini escreveu:
>
>  Hello,
>>
>> I am adding rows to a matrix using rbind() and I would like to also add a
>> row name to the added row in order to do some sorting after the adding
>> rows
>> part is finished. is this possible?
>>
>> Best,
>> Simone
>>
>>


-- 
Simone Gabbriellini, PhD

PostDoc@DISI, University of Bologna
mobile: +39 340 39 75 626
email: simone.gabbriell...@unibo.it
academia.edu: http://goo.gl/7pq62

DigitalBrains srl
Amministratore
mobile: +39 340 39 75 626
email: simone.gabbriell...@digitalbrains.it
home: www.digitalbrains.it

[[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] R CMD build

2013-04-20 Thread Knut Krueger

I have no idea where I must  R CMD build...

I am using Windows 7 wiht pearl installed
http://stat.ethz.ch/R-manual/R-patched/library/utils/html/PkgUtils.html

its completely unclear for me ... sorry

Knut

__
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 CMD build

2013-04-20 Thread Knut Krueger
I was looking for the problem at least two days.. and just after writing 
to the list I found rcmd.exe in the

C:\Program Files\R\R-2.15.2\bin\i386 directory.
install
http://sourceforge.net/projects/mingw/?source=dlp
chage the path variable of windows and set the path in front of the 
others C:\MinGW\msys\1.0\bin\


problems with windows 7 :
Rund the cmd console as administrator and it is working

Maybe anybody can add this to 
http://stat.ethz.ch/R-manual/R-patched/library/utils/html/PkgUtils.html


__
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] Assigning factor to character vector

2013-04-20 Thread Milan Bouchet-Valat
Hi!

Yesterday I accidentally discovered this:
> a <- LETTERS[1:5]
> a
[1] "A" "B" "C" "D" "E"
> 
> a[1] <- factor(a[1])
> a
[1] "1" "B" "C" "D" "E"

BUT:
> b <- factor(LETTERS[1:5])
> b
[1] A B C D E
Levels: A B C D E
> b[1] <- factor(b[1])
> b
[1] A B C D E
Levels: A B C D E
> b[1] <- as.character(b[1])
> b
[1] A B C D E
Levels: A B C D E

I think this would definitely deserve a mention in the R Inferno...

I guess this is documented somewhere (though I could not find anything
in help("[<-"). Would someone be kind enough to give me the explanation
of this behavior? I suspect this has something to do with the coercion
order, but I do not really get why a[1] does not get assigned the result
of as.character(factor(a[1]))... Probably, there is no special-casing of
factors, which are handled as integer vectors?

Wouldn't it be useful to print a warning when this happens, since nobody
reasonable would rely on such a special behavior? I wish R had a "safe
mode" where all these tricky implicit coercion cases would warn... :-/


Regards

__
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] possible loop problem

2013-04-20 Thread MHwk79
Wow - thanks a lot for your help. Sorry it's taken a while to answer, but 
honestly, didn't expect a reply so soon. Sorry I hadn't provided enough 
information at the beginning, but you'd correctly figured it was a csv file 
(actually exported from Excel). I had figured that there was a more streamlined 
way to do what I was trying to do, so will study the code you provided. Thanks 
again,

MH

Date: Sun, 14 Apr 2013 14:06:41 -0700
From: ml-node+s789695n4664202...@n4.nabble.com
To: noyfb...@hotmail.com
Subject: Re: possible loop problem





Hi,

It would be better if you provided the output of dput(dataset).  I am not sure 
about the structure of your dataset.


Just from reading the data as is shown.

dat1<- read.table(text="

separator,tissID

>,>,2

,2,1

,6,5

,11,13

>,>,4

,4,9

,6,2

,7,3

,21,1

,23,58

,25,9

,26,4

>,>,11

,1,12

>,>,21

,4,1

,11,3

",sep=",",header=TRUE,stringsAsFactors=FALSE,row.names=NULL) 

indx<-which(grepl(">",dat1[,1]))

indx1<-diff(c(indx,nrow(dat1)+1))


res1<-do.call(rbind,lapply(seq_along(indx),function(i) 
{x1<-dat1[indx[i]:(indx[i]+(indx1[i]-1)),];x1[-1,1]<- x1[1,3];x1}))

res2<- as.matrix(res1[,-1])

row.names(res2)<- res1[,1] 

 res2

#   separator tissID

#>  ">"   " 2"  

#2  "2"   " 1"  

#2  "6"   " 5"  

#2  "11"  "13"  

#>  ">"   " 4"  

#4  "4"   " 9"  

#4  "6"   " 2"  

#4  "7"   " 3"  

#4  "21"  " 1"  

#4  "23"  "58"  

#4  "25"  " 9"  

#4  "26"  " 4"  

#>  ">"   "11"  

#11 "1"   "12"  

#>  ">"   "21"  

#21 "4"   " 1"  

#21 "11"  " 3"  


A.K.



  



--
View this message in context: 
http://r.789695.n4.nabble.com/possible-loop-problem-tp4664146p4664799.html
Sent from the R help mailing list archive at Nabble.com.
[[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] R CMD build

2013-04-20 Thread Gabor Grothendieck
On Sat, Apr 20, 2013 at 8:09 AM, Knut Krueger  wrote:
> I was looking for the problem at least two days.. and just after writing to
> the list I found rcmd.exe in the
> C:\Program Files\R\R-2.15.2\bin\i386 directory.
> install
> http://sourceforge.net/projects/mingw/?source=dlp
> chage the path variable of windows and set the path in front of the others
> C:\MinGW\msys\1.0\bin\
>
> problems with windows 7 :
> Rund the cmd console as administrator and it is working
>
> Maybe anybody can add this to
> http://stat.ethz.ch/R-manual/R-patched/library/utils/html/PkgUtils.html
>

Note that there is a separate directory for the 64-bit R executables.
Also, downloading MinGW should not be needed.  Rtools already contains
the needed UNIX utilities.

You might want to look into the Windows batch files at
http://batchfiles.googlecode.com .

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

__
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] Editing data sheet issue with write.table append

2013-04-20 Thread Vinny Moriarty
I'm running R 2.15.2 on Max OS X 10.6.8


If I write a simple file

Data1<-1
DF<-data.frame(Data1)
colnames(DF)<-"Col1"

and write to a csv file

write.table(DF,file="Data.csv",sep=",",row.names=FALSE,col.names=TRUE)

I can then append to it no problem

Data2<-2
Data3<-4


DF2<-data.frame(Data2)
DF3<-data.frame(Data3)

write.table(DF2,file="Data.csv",sep=",",row.names=FALSE,col.names=FALSE,append=TRUE)
write.table(DF3,file="Data.csv",sep=",",row.names=FALSE,col.names=FALSE,append=TRUE)


All good so far.

But the problem arises if I then need to edit the data sheet and continue
to append using the above code. If I open up the data sheet in excel and
delete a line, the next time I try and append the data as above the first
new line of data starts at the end of the last row of data (though all
subsequent new lines are appended properly).

I'm sure when I manually delete the line in excel I am removing the
invisible carriage return character, causing the first line of new data to
be added onto where the carriage return used to be.

Is there a way to specify in append=TRUE to always start with a new line of
data in the spreadsheet? Failing that, is there a work around to avoid this
problem?

[[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] Multiple Multivariate regression in R with 50 independentvariables

2013-04-20 Thread Nilesh Gupta
Thanks to all , I solved the problem using William's suggestion.
Peter I agree with the theory issue and I will deal with that subsequently,
but I wanted to run this once .

Regards

The woods are lovely, dark and deep
But I have promises to keep
And miles to go before I sleep
And miles to go before I sleep
-


On Sat, Apr 20, 2013 at 1:41 AM, Daniel Nordlund wrote:

> > -Original Message-
> > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> > On Behalf Of Nilesh Gupta
> > Sent: Friday, April 19, 2013 10:26 AM
> > To: r-h...@stat.math.ethz.ch
> > Subject: Re: [R] Multiple Multivariate regression in R with 50
> > independentvariables
> >
> > Ranjan
> >
> > I have multiple y's(stocks,2300 odd) which i want to run on 3 variables.
> > for 500 months. I assume this is multivariate regression for there are
> > multiple y's and multiple X's
> > as compared to univariate multiple regression wherein there is only one y
> > and there are more than X's. If I were to pool these returns into one big
> > data ( keeping apart the part where that makes sense from the theory
> point
> > of view) then that would be an example of univariate multiple regression
> > As a further clarification my Y matrix is of order 500X2398 whereas my X
> > matrix is of order 500X4. I am expecting a beta matrix of 4X2398,
> assuming
> > Y = X*Beta formulation
> >
> > The woods are lovely, dark and deep
> > But I have promises to keep
> > And miles before I go to sleep
> > And miles before I go to sleep
> > -
> >
>
> Sorry, I don't have any help regarding your regression problem.  But, I
> see your quote of the last stanza of a Robert Frost poem.  Just wanted to
> point out that the correct quote is actually
>
>
> The woods are lovely, dark and deep
> But I have promises to keep
> And miles to go before I sleep
> And miles to go before I sleep
>
>
> Dan
>
> Daniel Nordlund
> Bothell, WA USA
>
>
>

[[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] Assigning factor to character vector

2013-04-20 Thread Bert Gunter
Sorry, I failed to cc: the list.

I also added a slight edit below to clarify my final statement. -- Bert

On Sat, Apr 20, 2013 at 7:17 AM, Bert Gunter  wrote:
> Milan:
>
> 1. The R Inferno was written by Pat Burns and is not in any way an
> "official" R document. So it is a "Pat Burns" not an "R" issue. You
> can contact him directly, if you wish -- though he monitors this list
> and almost surely has seen this.
>
> 2. EVerything works exactly as documented and expected. See the R
> Language definition ... and perhaps the "Intro to R" tutorial..
>
> Inline comments below.
>
> Cheers,
> Bert
>
> On Sat, Apr 20, 2013 at 5:49 AM, Milan Bouchet-Valat  
> wrote:
>> Hi!
>>
>> Yesterday I accidentally discovered this:
>>> a <- LETTERS[1:5]
>>> a
>> [1] "A" "B" "C" "D" "E"
>
> a is a character vector.
>>>
>>> a[1] <- factor(a[1])
> The RHS is an vector of integers with additional attributes that define a 
> factor
> The replacement of the first element of a, a character vector,  by an
> integer causes the integer to be silently coerced to a character. The
> default S3 replacement method is used -- see ?UseMethod. or the R
> Intro for info on S3 methods
>
>>> a
>> [1] "1" "B" "C" "D" "E"
>>
>> BUT:
>>> b <- factor(LETTERS[1:5])
> b is a factor
>
>>> b
>> [1] A B C D E
>> Levels: A B C D E
>>> b[1] <- factor(b[1])
>>> b
>> [1] A B C D E
>> Levels: A B C D E
>>> b[1] <- as.character(b[1])
> The replacement method for a factor is used in
b[1] <- factor(b[1])
See ?"[<-.factor" .
>
> Cheers,
> Bert
>
> The replacement
>>> b
>> [1] A B C D E
>> Levels: A B C D E
>>
>> I think this would definitely deserve a mention in the R Inferno...
>>
>> I guess this is documented somewhere (though I could not find anything
>> in help("[<-"). Would someone be kind enough to give me the explanation
>> of this behavior? I suspect this has something to do with the coercion
>> order, but I do not really get why a[1] does not get assigned the result
>> of as.character(factor(a[1]))... Probably, there is no special-casing of
>> factors, which are handled as integer vectors?
>>
>> Wouldn't it be useful to print a warning when this happens, since nobody
>> reasonable would rely on such a special behavior? I wish R had a "safe
>> mode" where all these tricky implicit coercion cases would warn... :-/
>>
>>
>> Regards
>>
>> __
>> 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.
>
>
>
> --
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
>
> Internal Contact Info:
> Phone: 467-7374
> Website:
> http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

__
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] Editing data sheet issue with write.table append

2013-04-20 Thread Jeff Newmiller
a) Your terminology "data sheet" is foreign to R (and this mailing list). It 
implies a computing model that R does not use.

b) You appear to be complaining about the behavior of software other than R on 
the R-help mailing list, which is pointless.

c) I think the chances of adding code to base R to fix the broken behavior of 
another software package is highly unlikely, particularly when from your 
description you might or might not end up with the missing newline depending on 
whether you choose to modify any particular file outside R. Putting in a 
newline every time would make R just as broken as Excel.

4) You can put in newlines before or after your write.table call using the ?cat 
function. Read the data input and output manual for details... but beware that 
write.table is a high-level function that intentionally tries to generate a 
coherent representation of the data table as a single block of text. If you 
need to tweak within that text then you may need to make your own special 
output function.
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Vinny Moriarty  wrote:

>I'm running R 2.15.2 on Max OS X 10.6.8
>
>
>If I write a simple file
>
>Data1<-1
>DF<-data.frame(Data1)
>colnames(DF)<-"Col1"
>
>and write to a csv file
>
>write.table(DF,file="Data.csv",sep=",",row.names=FALSE,col.names=TRUE)
>
>I can then append to it no problem
>
>Data2<-2
>Data3<-4
>
>
>DF2<-data.frame(Data2)
>DF3<-data.frame(Data3)
>
>write.table(DF2,file="Data.csv",sep=",",row.names=FALSE,col.names=FALSE,append=TRUE)
>write.table(DF3,file="Data.csv",sep=",",row.names=FALSE,col.names=FALSE,append=TRUE)
>
>
>All good so far.
>
>But the problem arises if I then need to edit the data sheet and
>continue
>to append using the above code. If I open up the data sheet in excel
>and
>delete a line, the next time I try and append the data as above the
>first
>new line of data starts at the end of the last row of data (though all
>subsequent new lines are appended properly).
>
>I'm sure when I manually delete the line in excel I am removing the
>invisible carriage return character, causing the first line of new data
>to
>be added onto where the carriage return used to be.
>
>Is there a way to specify in append=TRUE to always start with a new
>line of
>data in the spreadsheet? Failing that, is there a work around to avoid
>this
>problem?
>
>   [[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] Assigning factor to character vector

2013-04-20 Thread Milan Bouchet-Valat
Le samedi 20 avril 2013 à 07:22 -0700, Bert Gunter a écrit :
> Sorry, I failed to cc: the list.
> 
> I also added a slight edit below to clarify my final statement. -- Bert
> 
> On Sat, Apr 20, 2013 at 7:17 AM, Bert Gunter  wrote:
> > Milan:
> >
> > 1. The R Inferno was written by Pat Burns and is not in any way an
> > "official" R document. So it is a "Pat Burns" not an "R" issue. You
> > can contact him directly, if you wish -- though he monitors this list
> > and almost surely has seen this.
Sure, I did not imply that the R Inferno was an official document.

> > 2. EVerything works exactly as documented and expected. See the R
> > Language definition ... and perhaps the "Intro to R" tutorial..
But is there a mention of what happens precisely to assignments from
factors? I could not find it. For example, the R Language Definition
does not mention coercion in the Subset Assignment section [1].

> > Inline comments below.
> >
> > Cheers,
> > Bert
> >
> > On Sat, Apr 20, 2013 at 5:49 AM, Milan Bouchet-Valat  
> > wrote:
> >> Hi!
> >>
> >> Yesterday I accidentally discovered this:
> >>> a <- LETTERS[1:5]
> >>> a
> >> [1] "A" "B" "C" "D" "E"
> >
> > a is a character vector.
> >>>
> >>> a[1] <- factor(a[1])
> > The RHS is an vector of integers with additional attributes that define a 
> > factor
> > The replacement of the first element of a, a character vector,  by an
> > integer causes the integer to be silently coerced to a character. The
> > default S3 replacement method is used -- see ?UseMethod. or the R
> > Intro for info on S3 methods
Thanks, but I already understand this part. My surprise comes from the
fact that the default replacement method coerces a factor to a character
in a way which is different from calling as.character() on it. It acts
as if attributes were dropped _before_ coercion (and thus everything
happens as if the factor was a mere integer).

> >>> a
> >> [1] "1" "B" "C" "D" "E"
> >>
> >> BUT:
> >>> b <- factor(LETTERS[1:5])
> > b is a factor
> >
> >>> b
> >> [1] A B C D E
> >> Levels: A B C D E
> >>> b[1] <- factor(b[1])
> >>> b
> >> [1] A B C D E
> >> Levels: A B C D E
> >>> b[1] <- as.character(b[1])
> > The replacement method for a factor is used in
> b[1] <- factor(b[1])
> See ?"[<-.factor" .
Yeah, this part was here to show the asymmetric character of the
factor <-> character assignments.

Regards


1: http://cran.r-project.org/doc/manuals/R-lang.html#Subset-assignment


> > Cheers,
> > Bert
> >
> > The replacement
> >>> b
> >> [1] A B C D E
> >> Levels: A B C D E
> >>
> >> I think this would definitely deserve a mention in the R Inferno...
> >>
> >> I guess this is documented somewhere (though I could not find anything
> >> in help("[<-"). Would someone be kind enough to give me the explanation
> >> of this behavior? I suspect this has something to do with the coercion
> >> order, but I do not really get why a[1] does not get assigned the result
> >> of as.character(factor(a[1]))... Probably, there is no special-casing of
> >> factors, which are handled as integer vectors?
> >>
> >> Wouldn't it be useful to print a warning when this happens, since nobody
> >> reasonable would rely on such a special behavior? I wish R had a "safe
> >> mode" where all these tricky implicit coercion cases would warn... :-/
> >>
> >>
> >> Regards
> >>
> >> __
> >> 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.
> >
> >
> >
> > --
> >
> > Bert Gunter
> > Genentech Nonclinical Biostatistics
> >
> > Internal Contact Info:
> > Phone: 467-7374
> > Website:
> > http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
> 
> 
>

__
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] Editing data sheet issue with write.table append

2013-04-20 Thread David Winsemius

On Apr 20, 2013, at 1:29 AM, Vinny Moriarty wrote:

> I'm running R 2.15.2 on Max OS X 10.6.8
> 
> 
> If I write a simple file
> 
> Data1<-1
> DF<-data.frame(Data1)
> colnames(DF)<-"Col1"
> 
> and write to a csv file
> 
> write.table(DF,file="Data.csv",sep=",",row.names=FALSE,col.names=TRUE)
> 
> I can then append to it no problem
> 
> Data2<-2
> Data3<-4
> 
> 
> DF2<-data.frame(Data2)
> DF3<-data.frame(Data3)
> 
> write.table(DF2,file="Data.csv",sep=",",row.names=FALSE,col.names=FALSE,append=TRUE)
> write.table(DF3,file="Data.csv",sep=",",row.names=FALSE,col.names=FALSE,append=TRUE)
> 
> 
> All good so far.
> 
> But the problem arises if I then need to edit the data sheet and continue
> to append using the above code. If I open up the data sheet in excel and
> delete a line, the next time I try and append the data as above the first
> new line of data starts at the end of the last row of data (though all
> subsequent new lines are appended properly).
> 
> I'm sure when I manually delete the line in excel I am removing the
> invisible carriage return character, causing the first line of new data to
> be added onto where the carriage return used to be.
> 
> Is there a way to specify in append=TRUE to always start with a new line of
> data in the spreadsheet?

No. 

> Failing that, is there a work around to avoid this
> problem?

You could always execute this before each append effort to restore the 
Excel-induced missing end of line character:

cat"\n", file="Data.csv", append=TRUE)


-- 

David Winsemius
Alameda, CA, USA

__
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] Editing data sheet issue with write.table append

2013-04-20 Thread William Dunlap
R is nice because it can deal with other less flexible software and many people
must use Excel at their jobs.

You can write a function that detects if your file ends with a newline and use 
it
to add a newline exactly when needed.  E.g., the following compares the last
few bytes in the file to the newline pattern that you specify and returns TRUE 
if
the file ends with a newline.  It reads in chunks so it doesn't waste space 
with very
large files.  In your situation you can do
   if (!fileEndsWithNewline(outputFile)) cat("\n", append=TRUE, file=outputFile)
before each call to write.table(append=TRUE).

I suppose the check should be modified to check that the file is not empty, as 
you don't
want a newline before any of your data in that case.

fileEndsWithNewline <- function(file, chunksize=4096, newline=if 
(.Platform$OS.type=="windows") "\r\n" else "\n")
{
rawNewline <- charToRaw(newline)
stopifnot(chunksize >= length(rawNewline))
conn <- file(file, "rb")
on.exit(close(conn))
prevChunk <- raw()
repeat {
thisChunk <- readBin(conn, what="raw", n=chunksize)
if (length(thisChunk) < chunksize) {
# concatenate in case newline is spread over two chunks
lastChunk <- c(prevChunk, thisChunk)
break
}
prevChunk <- thisChunk
}
length(lastChunk) >= length(rawNewline) && all(rawNewline == 
tail(lastChunk, 2))
}

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf
> Of Jeff Newmiller
> Sent: Saturday, April 20, 2013 8:14 AM
> To: Vinny Moriarty; r-help@r-project.org
> Subject: Re: [R] Editing data sheet issue with write.table append
> 
> a) Your terminology "data sheet" is foreign to R (and this mailing list). It 
> implies a
> computing model that R does not use.
> 
> b) You appear to be complaining about the behavior of software other than R 
> on the R-
> help mailing list, which is pointless.
> 
> c) I think the chances of adding code to base R to fix the broken behavior of 
> another
> software package is highly unlikely, particularly when from your description 
> you might or
> might not end up with the missing newline depending on whether you choose to 
> modify
> any particular file outside R. Putting in a newline every time would make R 
> just as broken
> as Excel.
> 
> 4) You can put in newlines before or after your write.table call using the 
> ?cat function.
> Read the data input and output manual for details... but beware that 
> write.table is a
> high-level function that intentionally tries to generate a coherent 
> representation of the
> data table as a single block of text. If you need to tweak within that text 
> then you may
> need to make your own special output function.
> ---
> Jeff NewmillerThe .   .  Go Live...
> DCN:Basics: ##.#.   ##.#.  Live Go...
>   Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
> /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
> ---
> Sent from my phone. Please excuse my brevity.
> 
> Vinny Moriarty  wrote:
> 
> >I'm running R 2.15.2 on Max OS X 10.6.8
> >
> >
> >If I write a simple file
> >
> >Data1<-1
> >DF<-data.frame(Data1)
> >colnames(DF)<-"Col1"
> >
> >and write to a csv file
> >
> >write.table(DF,file="Data.csv",sep=",",row.names=FALSE,col.names=TRUE)
> >
> >I can then append to it no problem
> >
> >Data2<-2
> >Data3<-4
> >
> >
> >DF2<-data.frame(Data2)
> >DF3<-data.frame(Data3)
> >
> >write.table(DF2,file="Data.csv",sep=",",row.names=FALSE,col.names=FALSE,append=T
> RUE)
> >write.table(DF3,file="Data.csv",sep=",",row.names=FALSE,col.names=FALSE,append=T
> RUE)
> >
> >
> >All good so far.
> >
> >But the problem arises if I then need to edit the data sheet and
> >continue
> >to append using the above code. If I open up the data sheet in excel
> >and
> >delete a line, the next time I try and append the data as above the
> >first
> >new line of data starts at the end of the last row of data (though all
> >subsequent new lines are appended properly).
> >
> >I'm sure when I manually delete the line in excel I am removing the
> >invisible carriage return character, causing the first line of new data
> >to
> >be added onto where the carriage return used to be.
> >
> >Is there a way to specify in append=TRUE to always start with a new
> >line of
> >data in the spreadsheet? Failing that, is there a work around to avoid
> >this
> >problem?
> >
> > [[alternative HTML version deleted]]
> >
> >__
> >R-help@r-project.org mailing list
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read

Re: [R] Spider Plot

2013-04-20 Thread Hall, Mark
Check the archives.  About 4 years ago, I asked on help with doing
spider-plots used in geologic literature and got a bunch of helpful results.

Best, Mark Hall
Winnemucca BLM


On Fri, Apr 19, 2013 at 1:41 PM, Janesh Devkota wrote:

> Xing,
> I cannot open the attachment. Can you attach the "png" file or pdf or any
> other format ?
>
>
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On
> Behalf Of XINLI LI
> Sent: Friday, April 19, 2013 3:30 PM
> To: r-help
> Subject: [R] Spider Plot
>
> Does any one have a sample code for a Spider Plot as attached?
>
> Thanks,
>
> Xing
>
> __
> 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] Reshape or Plyr?

2013-04-20 Thread Bruce Miller
H all,

I have relative abundance data from >100 sites.  This is from acoustic 
monitoring and usually the data is for 2-3 nights but in some cases my 
be longer like months or years for each location..
The data output from my management data base is proved by species by 
night for each location so data frame would look like this below. What I 
need to do is sum the Survey_time by Spec_Code for each location name 
and divide summed AI values for each Spec_code by the summed Survey time 
to adjust for unit effort then standardize it all by *10 to represent 
the relative abundance by survey hour to 10 hours. How best to do this?  
Using Plyr or reshape?

Location name   SPEC_CODE   Start_Day   Survey_Time AI  Std AI
079-f2p1-AcetunaBuzz2/14/2012   12.11   0.8264463
079-f2p1-AcetunaBuzz2/14/2012   12.11   0.8264463
079-f2p1-AcetunaEumspp  2/14/2012   12.11   0.8264463
079-f2p1-AcetunaFrag2/14/2012   12.118  14.87603
079-f2p1-AcetunaMolspp  2/14/2012   12.15   4.132231
079-f2p1-AcetunaMolspp  2/14/2012   12.15   4.132231
079-f2p1-AcetunaPhyllo  2/14/2012   12.12   1.652893
079-f2p1-AcetunaPtedav  2/14/2012   12.11   0.8264463
079-f2p1-AcetunaPtegym  2/14/2012   12.11   0.8264463
079-f2p1-AcetunaPtepar  2/14/2012   12.12   1.652893
079-f2p1-AcetunaRhotum  2/14/2012   12.16   4.958678
079-f2p1-AcetunaSacbil  2/14/2012   12.16   4.958678
079-f2p1-AcetunaSaclep  2/14/2012   12.111  9.090909
079-f2p1-AcetunaBuzz2/15/2012   12.12   1.652893
079-f2p1-AcetunaBuzz2/15/2012   12.12   1.652893
079-f2p1-AcetunaMolmol  2/15/2012   12.11   0.8264463
079-f2p1-AcetunaMolspp  2/15/2012   12.17   5.785124
079-f2p1-AcetunaMolspp  2/15/2012   12.17   5.785124
079-f2p1-AcetunaNocalb  2/15/2012   12.16   4.958678
079-f2p1-AcetunaPhyllo  2/15/2012   12.11   0.8264463
079-f2p1-AcetunaPtedav  2/15/2012   12.11   0.8264463
079-f2p1-AcetunaPtegym  2/15/2012   12.14   3.305785
079-f2p1-AcetunaPtepar  2/15/2012   12.14   3.305785
079-f2p1-AcetunaPteper  2/15/2012   12.13   2.479339
079-f2p1-AcetunaRhotum  2/15/2012   12.17   5.785124
079-f2p1-AcetunaSacbil  2/15/2012   12.12   1.652893
079-f2p1-AcetunaSaclep  2/15/2012   12.16   4.958678
079-f2p1-AcetunaBuzz2/16/2012   12.21   0.8196721
079-f2p1-AcetunaBuzz2/16/2012   12.21   0.8196721
079-f2p1-AcetunaEumspp  2/16/2012   12.24   3.278688
079-f2p1-AcetunaMolspp  2/16/2012   12.22   1.639344
079-f2p1-AcetunaMolspp  2/16/2012   12.22   1.639344
079-f2p1-AcetunaMyokea  2/16/2012   12.21   0.8196721
079-f2p1-AcetunaNocalb  2/16/2012   12.24   3.278688
079-f2p1-AcetunaPhyllo  2/16/2012   12.21   0.8196721
079-f2p1-AcetunaPtedav  2/16/2012   12.21   0.8196721
079-f2p1-AcetunaPtegym  2/16/2012   12.21   0.8196721
079-f2p1-AcetunaPtepar  2/16/2012   12.23   2.459016
079-f2p1-AcetunaPteper  2/16/2012   12.21   0.8196721
079-f2p1-AcetunaRhotum  2/16/2012   12.217  13.93443
079-f2p1-AcetunaSacbil  2/16/2012   12.23   2.459016
079-f2p1-AcetunaSaclep  2/16/2012   12.215  12.29508


Thanks for any suggestions.  Excel will be a mess to try to do that.

Bruce

[[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] Editing data sheet issue with write.table append

2013-04-20 Thread Vinny Moriarty
Thanks Bill , that works great.

It occurred to me upon reading the other responses that rather than try and
work around this issue with excel, another option would be to just always
append to the top line of the data sheet (1 line below the header). That
way I would be assured a proper carriage return, and a reverse
chronological order is fine with me

Thanks again to all


On Sat, Apr 20, 2013 at 7:21 AM, William Dunlap  wrote:

> R is nice because it can deal with other less flexible software and many
> people
> must use Excel at their jobs.
>
> You can write a function that detects if your file ends with a newline and
> use it
> to add a newline exactly when needed.  E.g., the following compares the
> last
> few bytes in the file to the newline pattern that you specify and returns
> TRUE if
> the file ends with a newline.  It reads in chunks so it doesn't waste
> space with very
> large files.  In your situation you can do
>if (!fileEndsWithNewline(outputFile)) cat("\n", append=TRUE,
> file=outputFile)
> before each call to write.table(append=TRUE).
>
> I suppose the check should be modified to check that the file is not
> empty, as you don't
> want a newline before any of your data in that case.
>
> fileEndsWithNewline <- function(file, chunksize=4096, newline=if
> (.Platform$OS.type=="windows") "\r\n" else "\n")
> {
> rawNewline <- charToRaw(newline)
> stopifnot(chunksize >= length(rawNewline))
> conn <- file(file, "rb")
> on.exit(close(conn))
> prevChunk <- raw()
> repeat {
> thisChunk <- readBin(conn, what="raw", n=chunksize)
> if (length(thisChunk) < chunksize) {
> # concatenate in case newline is spread over two chunks
> lastChunk <- c(prevChunk, thisChunk)
> break
> }
> prevChunk <- thisChunk
> }
> length(lastChunk) >= length(rawNewline) && all(rawNewline ==
> tail(lastChunk, 2))
> }
>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>
>
> > -Original Message-
> > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf
> > Of Jeff Newmiller
> > Sent: Saturday, April 20, 2013 8:14 AM
> > To: Vinny Moriarty; r-help@r-project.org
> > Subject: Re: [R] Editing data sheet issue with write.table append
> >
> > a) Your terminology "data sheet" is foreign to R (and this mailing
> list). It implies a
> > computing model that R does not use.
> >
> > b) You appear to be complaining about the behavior of software other
> than R on the R-
> > help mailing list, which is pointless.
> >
> > c) I think the chances of adding code to base R to fix the broken
> behavior of another
> > software package is highly unlikely, particularly when from your
> description you might or
> > might not end up with the missing newline depending on whether you
> choose to modify
> > any particular file outside R. Putting in a newline every time would
> make R just as broken
> > as Excel.
> >
> > 4) You can put in newlines before or after your write.table call using
> the ?cat function.
> > Read the data input and output manual for details... but beware that
> write.table is a
> > high-level function that intentionally tries to generate a coherent
> representation of the
> > data table as a single block of text. If you need to tweak within that
> text then you may
> > need to make your own special output function.
> >
> ---
> > Jeff NewmillerThe .   .  Go
> Live...
> > DCN:Basics: ##.#.   ##.#.  Live
> Go...
> >   Live:   OO#.. Dead: OO#..  Playing
> > Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
> > /Software/Embedded Controllers)   .OO#.   .OO#.
>  rocks...1k
> >
> ---
> > Sent from my phone. Please excuse my brevity.
> >
> > Vinny Moriarty  wrote:
> >
> > >I'm running R 2.15.2 on Max OS X 10.6.8
> > >
> > >
> > >If I write a simple file
> > >
> > >Data1<-1
> > >DF<-data.frame(Data1)
> > >colnames(DF)<-"Col1"
> > >
> > >and write to a csv file
> > >
> > >write.table(DF,file="Data.csv",sep=",",row.names=FALSE,col.names=TRUE)
> > >
> > >I can then append to it no problem
> > >
> > >Data2<-2
> > >Data3<-4
> > >
> > >
> > >DF2<-data.frame(Data2)
> > >DF3<-data.frame(Data3)
> > >
> >
> >write.table(DF2,file="Data.csv",sep=",",row.names=FALSE,col.names=FALSE,append=T
> > RUE)
> >
> >write.table(DF3,file="Data.csv",sep=",",row.names=FALSE,col.names=FALSE,append=T
> > RUE)
> > >
> > >
> > >All good so far.
> > >
> > >But the problem arises if I then need to edit the data sheet and
> > >continue
> > >to append using the above code. If I open up the data sheet in excel
> > >and
> > >delete a line, the next time I try and append the data as above the
> > >first
> > >new line of data starts at the end of the last row of dat

[R] Calculate confidence intervals in mgcv for unconditional on the, smoothing parameters

2013-04-20 Thread Alexander März
Dear R-Help members,

I am using Simon Wood`s mgcv package version1.7-22and R version 3.0.0 
(2013-04-03) for fitting a GAM-Model to the LIDAR Data contained in the 
"SemiPar" package. Here is the code for fitting the model and for 
plotting the result:

data("lidar")
attach(lidar)

###
# mgcv fitting
###
gam_fit <- gam(logratio ~ s(range, k = 40, bs = "cr"), gamma = 1.4, 
method = "REML")
plot(gam_fit, res = TRUE, shade = TRUE, pch = "°")

Since the confidence interval in the above plot is pointwise, I would 
like to calculate the critical value needed in order to construct a 
simultaneous confidence band. Here isthe code(it`s a bit lengthy and has 
to be tidied up but I wanted to to some manual calculations on the 
objects afterwards)

###
# Simulate 10 coefficient vectors from the posterior for ß and 
calculate the critical value
###
cov_beta_diff <- vcov(gam_fit)
basis_matrix <- model.matrix(gam_fit)
reml_sigma_squared <- gam.vcomp(gam_fit)
sigma_2_epsilon <- reml_sigma_squared[2,1]^2
smooth_matrix <- 
basis_matrix%*%vcov(gam_fit,dispersion=1)%*%t(basis_matrix)
stdv_f_x <- sqrt(diag(sigma_2_epsilon * smooth_matrix))

set.seed(123)
R_sim <- 10
mean_val <- rep(0, nrow(cov_beta_diff))
coef_diff <- mvrnorm(n = R_sim, mu = mean_val , Sigma = cov_beta_diff)
Xp <- predict(gam_fit, type = "lpmatrix")
sim_bet <- Xp %*% t(coef_diff)
abs_ratio <- abs(sim_bet / stdv_f_x)

ratio_max <- apply(abs_ratio, 2, max)
cv <- quantile(ratio_max, probs = 0.95)

So everything is fine until this point. My problem is:everything has 
been presented conditional on the smoothing parameter estimated in 
gam_fit. How can I "calculate" a critical value for thesimultaneous 
confidence band that is not conditioned on the estimated smoothing 
parameter? Simon Wood seems to offer a solution in his book "Generalized 
Additive Models: An introduction with R". But I couldn`t figure where to 
look for it and out how to implement it using R.

Any help is appreciated

Best
Alex


[[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] creating dummy variables

2013-04-20 Thread shyam basnet
Hello R-users,
  
The below is a snippet of my data:
 
  
fid  crop  year  value   
5_1_1  SWHE  1995  171   
5_1_1  SWHE  1997  696   
5_1_1  BARL  1996  114   
5_1_1  BARL  1997  344   
5_2_2  SWHE  1995  120   
5_2_2  SWHE  1996  511   
5_2_2  BARL  1996  239   
5_2_2  BARL  1997  349   
 
Here, I want to create dummy variables with the names of the content of a 
column 'crop' in a way that the new variable 'SWHE' would receive a value of 1 
if the column 'crop' contains 'SWHE' and 0 otherwise. So, I would have two new 
variables SWHE and BARL as below:
 
  
fid  crop  year  value  SWHE  BARL   
5_1_1  SWHE  1995  171  1  0   
5_1_1  SWHE  1997  696  1  0   
5_1_1  BARL  1996  114  0  1   
5_1_1  BARL  1997  344  0  1   
5_2_2  SWHE  1995  120  1  0   
5_2_2  SWHE  1996  511  1  0   
5_2_2  BARL  1996  239  0  1   
5_2_2  BARL  1997  349  0  1   
 
 
Cheers,
Shyam
Nepal
[[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] R copying script code to clipboard

2013-04-20 Thread Thomas Hansen
Hi everyone

I am trying to figure out why, and how to stop R, from copying my
entire script text to the clipboard when I either select the "run all"
option or select the entire script and ctrl+r.

Since my script imports data from the clipboard it is non-functional
when R overwrites the data I saved in the clipboard.

Thanks in advance

Thomas

__
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] how to subtotal by rows

2013-04-20 Thread shyam basnet
Dear All,
 
Thanks for helping me to redress the problem.  
 
Cheers,
 
Shyam Basnet
Nepal


- Original Message -
> From: arun 
> To: Janesh Devkota 
> Cc: R help ; shyam basnet 
> Sent: Saturday, April 20, 2013 12:52 AM
> Subject: Re: [R] how to subtotal by rows
> 
> HI,
> 
> If you wanted to use colSums, may be this works:
> 
> ddply(jd1,.(fid,year),function(x) colSums(x[,-c(1,2)],na.rm=TRUE))
> #  fid year rice wheat maize
> #1   1 1995    5 3 2
> #2   1 1996    4 2 6
> #3   2 1995    3 8 4
> #4   2 1996    7 6 7
> A.K.
> 
> 
> 
> - Original Message -
> From: arun 
> To: Janesh Devkota 
> Cc: R help ; shyam basnet 
> ; Rui Barradas 
> Sent: Friday, April 19, 2013 6:25 PM
> Subject: Re: [R] how to subtotal by rows
> 
> 
> Hi Janesh,
> There is a difference in output between these :
> ddply(jd1,.(fid,year),colSums,na.rm=T)  #especially the first two columns
> #  fid year rice wheat maize
> #1   3 5985    5 3 2
> #2   3 5988    4 2 6
> #3   6 5985    3 8 4
> #4   6 5988    7 6 7
>  ddply(jd1,.(fid,year),colwise(sum,na.rm=T))
> #  fid year rice wheat maize
> #1   1 1995    5 3 2
> #2   1 1996    4 2 6
> #3   2 1995    3 8 4
> #4   2 1996    7 6 7
>  aggregate(jd1[,3:5],by=list(jd1$year,jd1$fid),FUN=sum,na.rm=TRUE)
> #  Group.1 Group.2 rice wheat maize
> #1    1995   1    5 3 2
> #2    1996   1    4 2 6
> #3    1995   2    3 8 4
> #4    1996   2    7 6 7
> 
> A.K.
> 
> 
> 
> 
> From: Janesh Devkota 
> To: shyam basnet  
> Cc: "r-help@R-project.org"  
> Sent: Friday, April 19, 2013 3:32 PM
> Subject: Re: [R] how to subtotal by rows
> 
> 
> You can also use this short command.
> 
> library(plyr)
> ddply(jd1,.(fid,year),colSums,na.rm=T)
> 
> Janesh
> 
> 
> On Fri, Apr 19, 2013 at 2:30 PM, Janesh Devkota 
> wrote:
> 
>>  Hello Shyam,
>> 
>>  This is one way to do it
>> 
>>  jd1 <- read.table(text="
>>  fid      year     rice     wheat      maize
>>  1        1995      5        NA           NA
>>  1        1995      NA        3           NA
>>  1        1995      NA       NA           2
>>  1        1996      4        NA           NA
>>  1        1996      NA        2           NA
>>  1        1996      NA        NA           6
>>  2        1995      3        NA           NA
>>  2        1995      NA        8           NA
>>  2        1995      NA        NA           4
>>  2        1996      7        NA           NA
>>  2        1996      NA        6           NA
>>  2        1996      NA        NA           7
>>  ", sep="", header=T)
>>  jd1
>> 
>>  library(plyr)
>> 
>>  ddply(jd1,.(fid,year),summarise,
>>  rice=sum(rice,na.rm=T),wheat=sum(wheat,na.rm=T),maize=sum(maize,na.rm=T))
>> 
>>  Good luck
>> 
>>  Janesh
>> 
>> 
>>  On Fri, Apr 19, 2013 at 10:59 AM, shyam basnet 
> wrote:
>> 
>>> 
>>> 
>>>  Dear R-users,
>>> 
>>>  I have a dataset as like below, and I want to subtotal the values of
>>>  rice,wheat and maize by year for each fid.
>>> 
>>>  fid      year     rice     wheat      maize
>>>  
>>>  1        1995      5        NA           NA
>>>  1        1995      NA        3           NA
>>>  1        1995      NA       NA           2
>>>  1        1996      4        NA           NA
>>>  1        1996      NA        2           NA
>>>  1        1996      NA        NA           6
>>>  2        1995      3        NA           NA
>>>  2        1995      NA        8           NA
>>>  2        1995      NA        NA           4
>>>  2        1996      7        NA           NA
>>>  2        1996      NA        6           NA
>>>  2        1996      NA        NA
>>>  7---
>>> 
>>>  And, my output should look like below:
>>> 
>>>  fid      year     rice     wheat      maize
>>>  1        1995      5        3           2
>>>  1        1996      4        2           6
>>> 
>>>  2        1995      3        8           4
>>>  2        1996      7        6           7I am looking for some ideas or
>>>  r-codes on resolving my problem.
>>>  I appreciate your kind help,
>>> 
>>> 
>>>  Thanks a lot,
>>> 
>>>  Sincerely yours,
>>>  Shyam
>>>  Nepal
>>>          [[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] creating dummy variables

2013-04-20 Thread Bert Gunter
Dummy variables are not needed in R.

Bert

Sent from my iPhone -- please excuse typos.

On Apr 20, 2013, at 11:23 AM, shyam basnet  wrote:

> Hello R-users,
>   
> The below is a snippet of my data:
>  
> 
> fid  crop  year  value   
> 5_1_1  SWHE  1995  171   
> 5_1_1  SWHE  1997  696   
> 5_1_1  BARL  1996  114   
> 5_1_1  BARL  1997  344   
> 5_2_2  SWHE  1995  120   
> 5_2_2  SWHE  1996  511   
> 5_2_2  BARL  1996  239   
> 5_2_2  BARL  1997  349   
>  
> Here, I want to create dummy variables with the names of the content of a 
> column 'crop' in a way that the new variable 'SWHE' would receive a value of 
> 1 if the column 'crop' contains 'SWHE' and 0 otherwise. So, I would have two 
> new variables SWHE and BARL as below:
>  
> 
> fid  crop  year  value  SWHE  BARL   
> 5_1_1  SWHE  1995  171  1  0   
> 5_1_1  SWHE  1997  696  1  0   
> 5_1_1  BARL  1996  114  0  1   
> 5_1_1  BARL  1997  344  0  1   
> 5_2_2  SWHE  1995  120  1  0   
> 5_2_2  SWHE  1996  511  1  0   
> 5_2_2  BARL  1996  239  0  1   
> 5_2_2  BARL  1997  349  0  1   
>  
>  
> Cheers,
> Shyam
> Nepal
>[[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] matrix of size 30^5

2013-04-20 Thread Benjamin Caldwell
Dear R helpers

Reproducible example:

#warning - this causes a hard freeze on the machines I've tried it on
matrix.holder<- matrix(rnorm(150), nrow=30, ncol=5)

Out=
expand.grid(matrix.holder[,1],matrix.holder[,2],matrix.holder[,3],matrix.holder[,4],
matrix.holder[,5])

Problem:

I'm running an analysis that I would like to do using a matrix containing
all the possible combinations of the elements in a [30,5] matrix. Briefly,
each possible combination is used to index and subset another matrix. I
then run some models on the data in the subsetted matrix and then sometimes
export the model results based on a couple criteria. 24,300,000
combinations seems to be too big for R on my computer (Intel i5, about 2.5
GB RAM free, 4 GB total, Rx64 2.15 ) to handle.

Requests:

1. Can you tell me how I can estimate the amount of memory a matrix will
require before I create it?

2. Do you have recommendations for packages that allow the user to send an
object directly to the hard drive? I guess it would have to be partially
created in RAM and then dumped to the HD, but the point is that there isn't
room for whole thing to be created and then written in pieces to the HD
(which even I think I could do). And then of course if it was written as
one big piece to the HD, I would need to be able to read it in piece by
piece.

3. I also see packages out there to connect R to C. Anyone have ideas for
one designed or containing functions designed for this type of problem?

Background:

When I tried to throw expand.grid() at a matrix of size [30,5] (24,300,000
combinations), my computer choked (I assume due to RAM memory limits, but
it might be that doing that just takes a long time and I wasn't ready to
stare at a frozen computer for very long). I'm currently working around the
problem with five nested loops, with all the drawbacks of and limits
imposed by that approach (the biggest for me is that I'd like to attempt to
multithread with some of the packages that exist for that).

I don't have any formal training in computer science, and the only
programming language I use enough to do something of this complexity is R,
so programming the whole thing in C (which all the remote sensing folks
across the hall said would make creation of this matrix trivial) isn't an
easy alternative for me.

Thanks!

Ben Caldwell

Graduate Fellow
University of California, Berkeley

[[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] creating dummy variables

2013-04-20 Thread Patrick Coulombe
Hello Shyam,

if your data is stored in variable "dataset", for example, the following
code will create the desired dummy-coded variables and attach them to the
dataset:


##

#init vars
SWHE=BARL <- vector(length=nrow(dataset))
SWHE[]=BARL[] <- 0 #initialize dummy-coded vars with all 0s

#fill in variables
SWHE[grep("SWHE", dataset$crop)] <- 1 #grep returns the indices where a
match is found, see ?grep
BARL[grep("BARL", dataset$crop)] <- 1

#attach new dummy codes to dataset
dataset$SWHE <- SWHE
dataset$BARL <- BARL

##



Hope this helps,

Patrick


2013/4/20 shyam basnet 

> Hello R-users,
>
> The below is a snippet of my data:
>
>
> fid  crop  year  value
> 5_1_1  SWHE  1995  171
> 5_1_1  SWHE  1997  696
> 5_1_1  BARL  1996  114
> 5_1_1  BARL  1997  344
> 5_2_2  SWHE  1995  120
> 5_2_2  SWHE  1996  511
> 5_2_2  BARL  1996  239
> 5_2_2  BARL  1997  349
>
> Here, I want to create dummy variables with the names of the content of a
> column 'crop' in a way that the new variable 'SWHE' would receive a value
> of 1 if the column 'crop' contains 'SWHE' and 0 otherwise. So, I would have
> two new variables SWHE and BARL as below:
>
>
> fid  crop  year  value  SWHE  BARL
> 5_1_1  SWHE  1995  171  1  0
> 5_1_1  SWHE  1997  696  1  0
> 5_1_1  BARL  1996  114  0  1
> 5_1_1  BARL  1997  344  0  1
> 5_2_2  SWHE  1995  120  1  0
> 5_2_2  SWHE  1996  511  1  0
> 5_2_2  BARL  1996  239  0  1
> 5_2_2  BARL  1997  349  0  1
>
>
> Cheers,
> Shyam
> Nepal
> [[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] R CMD build

2013-04-20 Thread Knut Krueger

Am 20.04.2013 15:50, schrieb Gabor Grothendieck:
Note that there is a separate directory for the 64-bit R executables. 
Does it make any difference to check and pack the source files iwth 32 
or 64 bit?
Also, downloading MinGW should not be needed. Rtools already contains 
the needed UNIX utilities. 

Yes indeed it works better than MinGW

You might want to look into the Windows batch files at 
http://batchfiles.googlecode.com . 


At least it would be very helpful for windows user to give the hint to 
the executable rcmd.exe build ... instead of R cmd build ...


I already set up an linux system today to solve the problem 

Thank you
Knut

__
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] Source Code

2013-04-20 Thread Eva Prieto Castro
Dear all,

How can I get the source code of text function?

Regards
Eva

[[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] matrix of size 30^5

2013-04-20 Thread David Winsemius

On Apr 20, 2013, at 2:19 PM, Benjamin Caldwell wrote:

> Dear R helpers
> 
> Reproducible example:
> 
> #warning - this causes a hard freeze on the machines I've tried it on
> matrix.holder<- matrix(rnorm(150), nrow=30, ncol=5)
> 
> Out=
> expand.grid(matrix.holder[,1],matrix.holder[,2],matrix.holder[,3],matrix.holder[,4],
> matrix.holder[,5])
> 

On my machine:

object.size(Out)
972014344 bytes

So with proper setup you might be able to work with this on a 4GB machine, but 
not likely to be able to do so on the machine you are describing below.


> Problem:
> 
> I'm running an analysis that I would like to do using a matrix containing
> all the possible combinations of the elements in a [30,5] matrix. Briefly,
> each possible combination is used to index and subset another matrix. I
> then run some models on the data in the subsetted matrix and then sometimes
> export the model results based on a couple criteria. 24,300,000
> combinations seems to be too big for R on my computer (Intel i5, about 2.5
> GB RAM free, 4 GB total, Rx64 2.15 ) to handle.
> 
> Requests:
> 
> 1. Can you tell me how I can estimate the amount of memory a matrix will
> require before I create it?

Roughly:  5* 8* prod(dim(mat))   # 8 bytes per double

> 5*8*(30^5)/972014344
[1] 0.852# so my estimate was accurate on a ratio basis to 5 decimal 
places.

> 
> 2. Do you have recommendations for packages that allow the user to send an
> object directly to the hard drive? I guess it would have to be partially
> created in RAM and then dumped to the HD, but the point is that there isn't
> room for whole thing to be created and then written in pieces to the HD
> (which even I think I could do). And then of course if it was written as
> one big piece to the HD, I would need to be able to read it in piece by
> piece.


> 
> 3. I also see packages out there to connect R to C. Anyone have ideas for
> one designed or containing functions designed for this type of problem?

Are you saying you have facility with C programming? (And you really have not 
described the problem. Perhaps a redesign of the solution could accommodate 
your limited computing resources.

> 
> Background:
> 
> When I tried to throw expand.grid() at a matrix of size [30,5] (24,300,000
> combinations), my computer choked (I assume due to RAM memory limits, but
> it might be that doing that just takes a long time and I wasn't ready to
> stare at a frozen computer for very long).

It took 7 seconds on my 6 year-old MacPro.

> I'm currently working around the
> problem with five nested loops, with all the drawbacks of and limits
> imposed by that approach (the biggest for me is that I'd like to attempt to
> multithread with some of the packages that exist for that).
> 
> I don't have any formal training in computer science, and the only
> programming language I use enough to do something of this complexity is R,
> so programming the whole thing in C (which all the remote sensing folks
> across the hall said would make creation of this matrix trivial) isn't an
> easy alternative for me.

There are many threads on Rhelp and advice in various manuals about how to 
avoid memory limitations.
> 
> Thanks!
> 
> Ben Caldwell
> 
> Graduate Fellow
> University of California, Berkeley

-- 

David Winsemius
Alameda, CA, USA

__
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] Source Code

2013-04-20 Thread R. Michael Weylandt


On Apr 20, 2013, at 6:23 PM, Eva Prieto Castro  wrote:

> Dear all,
> 
> How can I get the source code of text function?
> 

What is the 'text function'?

Try typing the name of the function at the prompt without any parentheses after 
it. If its written in R, then it should be visible. 

Michael

> Regards
> Eva
> 
>[[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] Source Code

2013-04-20 Thread Eva Prieto Castro
This is what I get when typing text:

> text
function (x, ...) 
UseMethod("text")




The text function let you add text in a plot.

How can I obtain the source code?.

Thanks.

Eva


--- El dom, 21/4/13, R. Michael Weylandt  
 escribió:

De: R. Michael Weylandt  

Asunto: Re: [R] Source Code
Para: "Eva Prieto Castro" 
CC: "" 
Fecha: domingo, 21 de abril, 2013 00:34



On Apr 20, 2013, at 6:23 PM, Eva Prieto Castro  wrote:

> Dear all,
> 
> How can I get the source code of text function?
> 

What is the 'text function'?

Try typing the name of the function at the prompt without any parentheses after 
it. If its written in R, then it should be visible. 

Michael

> Regards
> Eva
> 
>    [[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] creating dummy variables

2013-04-20 Thread David Winsemius

On Apr 20, 2013, at 2:03 PM, Bert Gunter wrote:

> Dummy variables are not needed in R.
> 
> Bert
> 

Bert is correct on this point, but if you what to know how the regression 
functions in R do this "behind the scenes" then you could always look at:

?model.matrix # where _some_ of the the automagical stuff happens

> model.matrix( ~ crop, data=dat[,"crop", drop=FALSE])
  (Intercept) cropSWHE
1   11
2   11
3   10
4   10
5   11
6   11
7   10
8   10
attr(,"assign")
[1] 0 1
attr(,"contrasts")
attr(,"contrasts")$crop
[1] "contr.treatment"



> Sent from my iPhone -- please excuse typos.
> 
> On Apr 20, 2013, at 11:23 AM, shyam basnet  wrote:
> 
>> Hello R-users,
>> 
>> The below is a snippet of my data:
>> 
>> 
>> fid  crop  year  value   
>> 5_1_1  SWHE  1995  171   
>> 5_1_1  SWHE  1997  696   
>> 5_1_1  BARL  1996  114   
>> 5_1_1  BARL  1997  344   
>> 5_2_2  SWHE  1995  120   
>> 5_2_2  SWHE  1996  511   
>> 5_2_2  BARL  1996  239   
>> 5_2_2  BARL  1997  349   
>> 
>> Here, I want to create dummy variables with the names of the content of a 
>> column 'crop' in a way that the new variable 'SWHE' would receive a value of 
>> 1 if the column 'crop' contains 'SWHE' and 0 otherwise. So, I would have two 
>> new variables SWHE and BARL as below:
>> 
>> 
>> fid  crop  year  value  SWHE  BARL   
>> 5_1_1  SWHE  1995  171  1  0   
>> 5_1_1  SWHE  1997  696  1  0   
>> 5_1_1  BARL  1996  114  0  1   
>> 5_1_1  BARL  1997  344  0  1   
>> 5_2_2  SWHE  1995  120  1  0   
>> 5_2_2  SWHE  1996  511  1  0   
>> 5_2_2  BARL  1996  239  0  1   
>> 5_2_2  BARL  1997  349  0  1   
>> 
>> 
>> Cheers,
>> Shyam
>> Nepal
>> 

David Winsemius
Alameda, CA, USA

__
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] Source Code

2013-04-20 Thread Rui Barradas

Hello,

The output you got means that text is generic, so you need something 
like text.default



> text.default
function (x, y = NULL, labels = seq_along(x), adj = NULL, pos = NULL,
offset = 0.5, vfont = NULL, cex = 1, col = NULL, font = NULL,
...)
{
if (!missing(y) && (is.character(y) || is.expression(y))) {
labels <- y
y <- NULL
}
labels <- as.graphicsAnnot(labels)
if (!is.null(vfont))
vfont <- c(typeface = pmatch(vfont[1L], Hershey$typeface),
fontindex = pmatch(vfont[2L], Hershey$fontindex))
.External.graphics(C_text, xy.coords(x, y, recycle = TRUE),
labels, adj, pos, offset, vfont, cex, col, font, ...)
invisible()
}




Hope this helps,

Rui Barradas

Em 20-04-2013 23:38, Eva Prieto Castro escreveu:

This is what I get when typing text:


text

function (x, ...)
UseMethod("text")




The text function let you add text in a plot.

How can I obtain the source code?.

Thanks.

Eva


--- El dom, 21/4/13, R. Michael Weylandt  
 escribió:

De: R. Michael Weylandt  

Asunto: Re: [R] Source Code
Para: "Eva Prieto Castro" 
CC: "" 
Fecha: domingo, 21 de abril, 2013 00:34



On Apr 20, 2013, at 6:23 PM, Eva Prieto Castro  wrote:


Dear all,

How can I get the source code of text function?



What is the 'text function'?

Try typing the name of the function at the prompt without any parentheses after 
it. If its written in R, then it should be visible.

Michael


Regards
Eva

 [[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-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] Source Code

2013-04-20 Thread David Winsemius

On Apr 20, 2013, at 3:34 PM, R. Michael Weylandt  
wrote:

> 
> 
> On Apr 20, 2013, at 6:23 PM, Eva Prieto Castro  wrote:
> 
>> Dear all,
>> 
>> How can I get the source code of text function?
>> 
> 
> What is the 'text function'?
> 
> Try typing the name of the function at the prompt without any parentheses 
> after it. If its written in R, then it should be visible. 

(It's not, .. or at least it might not seem so to a newbR.)

>  text
function (x, ...) 
UseMethod("text")




methods(text)
text.default
graphics:::trext.formula

And then  to go further ... I think she may need the added information in 
Uwe Ligges classic R-News article:

http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf


-- 
David Winsemius
Alameda, CA, USA

__
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] creating dummy variables

2013-04-20 Thread Eva Prieto Castro

Hi,

Why do you write that dummy variables are not needed in R?. I would like you 
explain it.

Thanks, 

Eva

--- El dom, 21/4/13, David Winsemius  escribió:

De: David Winsemius 
Asunto: Re: [R] creating dummy variables
Para: "Bert Gunter" 
CC: "r-help@R-project.org" , "shyam basnet" 

Fecha: domingo, 21 de abril, 2013 00:38


On Apr 20, 2013, at 2:03 PM, Bert Gunter wrote:

> Dummy variables are not needed in R.
> 
> Bert
> 

Bert is correct on this point, but if you what to know how the regression 
functions in R do this "behind the scenes" then you could always look at:

?model.matrix     # where _some_ of the the automagical stuff happens

> model.matrix( ~ crop, data=dat[,"crop", drop=FALSE])
  (Intercept) cropSWHE
1           1        1
2           1        1
3           1        0
4           1        0
5           1        1
6           1        1
7           1        0
8           1        0
attr(,"assign")
[1] 0 1
attr(,"contrasts")
attr(,"contrasts")$crop
[1] "contr.treatment"



> Sent from my iPhone -- please excuse typos.
> 
> On Apr 20, 2013, at 11:23 AM, shyam basnet  wrote:
> 
>> Hello R-users,
>> 
>> The below is a snippet of my data:
>> 
>> 
>> fid  crop  year  value   
>> 5_1_1  SWHE  1995  171   
>> 5_1_1  SWHE  1997  696   
>> 5_1_1  BARL  1996  114   
>> 5_1_1  BARL  1997  344   
>> 5_2_2  SWHE  1995  120   
>> 5_2_2  SWHE  1996  511   
>> 5_2_2  BARL  1996  239   
>> 5_2_2  BARL  1997  349   
>> 
>> Here, I want to create dummy variables with the names of the content of a 
>> column 'crop' in a way that the new variable 'SWHE' would receive a value of 
>> 1 if the column 'crop' contains 'SWHE' and 0 otherwise. So, I would have two 
>> new variables SWHE and BARL as below:
>> 
>> 
>> fid  crop  year  value  SWHE  BARL   
>> 5_1_1  SWHE  1995  171  1  0   
>> 5_1_1  SWHE  1997  696  1  0   
>> 5_1_1  BARL  1996  114  0  1   
>> 5_1_1  BARL  1997  344  0  1   
>> 5_2_2  SWHE  1995  120  1  0   
>> 5_2_2  SWHE  1996  511  1  0   
>> 5_2_2  BARL  1996  239  0  1   
>> 5_2_2  BARL  1997  349  0  1   
>> 
>> 
>> Cheers,
>> Shyam
>> Nepal
>> 

David Winsemius
Alameda, CA, USA

__
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] Source Code

2013-04-20 Thread Eva Prieto Castro

Thanks!. The problem is that I can't see the source code in .Internal(txt...


> text.default
function (x, y = NULL, labels = seq_along(x), adj = NULL, pos = NULL, 
    offset = 0.5, vfont = NULL, cex = 1, col = NULL, font = NULL, 
    ...) 
{
    if (!missing(y) && (is.character(y) || is.expression(y))) {
    labels <- y
    y <- NULL
    }
    labels <- as.graphicsAnnot(labels)
    if (!is.null(vfont)) 
    vfont <- c(typeface = pmatch(vfont[1L], Hershey$typeface), 
    fontindex = pmatch(vfont[2L], Hershey$fontindex))
    .Internal(text(xy.coords(x, y, recycle = TRUE), labels, adj, 
    pos, offset, vfont, cex, col, font, ...))
}



Regards,

Eva

--- El dom, 21/4/13, David Winsemius  escribió:

De: David Winsemius 
Asunto: Re: [R] Source Code
Para: "R. Michael Weylandt " 

CC: "Eva Prieto Castro" , "" 

Fecha: domingo, 21 de abril, 2013 00:45


On Apr 20, 2013, at 3:34 PM, R. Michael Weylandt  
wrote:

> 
> 
> On Apr 20, 2013, at 6:23 PM, Eva Prieto Castro  wrote:
> 
>> Dear all,
>> 
>> How can I get the source code of text function?
>> 
> 
> What is the 'text function'?
> 
> Try typing the name of the function at the prompt without any parentheses 
> after it. If its written in R, then it should be visible. 

(It's not, .. or at least it might not seem so to a newbR.)

>  text
function (x, ...) 
UseMethod("text")




methods(text)
text.default
graphics:::trext.formula

And then  to go further ... I think she may need the added information in 
Uwe Ligges classic R-News article:

http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf


-- 
David Winsemius
Alameda, CA, USA


[[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] Source Code

2013-04-20 Thread David Winsemius

On Apr 20, 2013, at 4:05 PM, Eva Prieto Castro wrote:

> 
> Thanks!. The problem is that I can't see the source code in .Internal(txt...

Exactly which was why I provided the link to Ligges' article. (So now you 
_are_ expected to do some self-study.)

-- 
David.
> 
> 
> > text.default
> function (x, y = NULL, labels = seq_along(x), adj = NULL, pos = NULL, 
> offset = 0.5, vfont = NULL, cex = 1, col = NULL, font = NULL, 
> ...) 
> {
> if (!missing(y) && (is.character(y) || is.expression(y))) {
> labels <- y
> y <- NULL
> }
> labels <- as.graphicsAnnot(labels)
> if (!is.null(vfont)) 
> vfont <- c(typeface = pmatch(vfont[1L], Hershey$typeface), 
> fontindex = pmatch(vfont[2L], Hershey$fontindex))
> .Internal(text(xy.coords(x, y, recycle = TRUE), labels, adj, 
> pos, offset, vfont, cex, col, font, ...))
> }
> 
> 
> 
> Regards,
> 
> Eva
> 
> --- El dom, 21/4/13, David Winsemius  escribió:
> 
> De: David Winsemius 
> Asunto: Re: [R] Source Code
> Para: "R. Michael Weylandt " 
> 
> CC: "Eva Prieto Castro" , "" 
> 
> Fecha: domingo, 21 de abril, 2013 00:45
> 
> 
> On Apr 20, 2013, at 3:34 PM, R. Michael Weylandt  
> wrote:
> 
> > 
> > 
> > On Apr 20, 2013, at 6:23 PM, Eva Prieto Castro  wrote:
> > 
> >> Dear all,
> >> 
> >> How can I get the source code of text function?
> >> 
> > 
> > What is the 'text function'?
> > 
> > Try typing the name of the function at the prompt without any parentheses 
> > after it. If its written in R, then it should be visible. 
> 
> (It's not, .. or at least it might not seem so to a newbR.)
> 
> >  text
> function (x, ...) 
> UseMethod("text")
> 
> 
> 
> 
> methods(text)
> text.default
> graphics:::trext.formula
> 
> And then  to go further ... I think she may need the added information in 
> Uwe Ligges classic R-News article:
> 
> http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf
> 
> 
> -- 
> David Winsemius
> Alameda, CA, USA
> 
> 

David Winsemius
Alameda, CA, USA

__
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] creating dummy variables

2013-04-20 Thread David Winsemius

On Apr 20, 2013, at 3:56 PM, Eva Prieto Castro wrote:

> 
> Hi,
> 
> Why do you write that dummy variables are not needed in R?. I would like you 
> explain it.

I suppose you might want individual instruction, but Rhelp was established with 
certain principles (expressed in the Posting Guide), one of which is that 
persons posting to Rhelp should have made demonstrated effort on their own to 
study the offered documentation. You are not demonstrating that you have yet 
understood this principle.

-- 
David.
> 
> Thanks, 
> 
> Eva
> 
> --- El dom, 21/4/13, David Winsemius  escribió:
> 
> De: David Winsemius 
> Asunto: Re: [R] creating dummy variables
> Para: "Bert Gunter" 
> CC: "r-help@R-project.org" , "shyam basnet" 
> 
> Fecha: domingo, 21 de abril, 2013 00:38
> 
> 
> On Apr 20, 2013, at 2:03 PM, Bert Gunter wrote:
> 
> > Dummy variables are not needed in R.
> > 
> > Bert
> > 
> 
> Bert is correct on this point, but if you what to know how the regression 
> functions in R do this "behind the scenes" then you could always look at:
> 
> ?model.matrix # where _some_ of the the automagical stuff happens
> 
> > model.matrix( ~ crop, data=dat[,"crop", drop=FALSE])
>   (Intercept) cropSWHE
> 1   11
> 2   11
> 3   10
> 4   10
> 5   11
> 6   11
> 7   10
> 8   10
> attr(,"assign")
> [1] 0 1
> attr(,"contrasts")
> attr(,"contrasts")$crop
> [1] "contr.treatment"
> 
> 
> 
> > Sent from my iPhone -- please excuse typos.
> > 
> > On Apr 20, 2013, at 11:23 AM, shyam basnet  wrote:
> > 
> >> Hello R-users,
> >> 
> >> The below is a snippet of my data:
> >> 
> >> 
> >> fid  crop  year  value   
> >> 5_1_1  SWHE  1995  171   
> >> 5_1_1  SWHE  1997  696   
> >> 5_1_1  BARL  1996  114   
> >> 5_1_1  BARL  1997  344   
> >> 5_2_2  SWHE  1995  120   
> >> 5_2_2  SWHE  1996  511   
> >> 5_2_2  BARL  1996  239   
> >> 5_2_2  BARL  1997  349   
> >> 
> >> Here, I want to create dummy variables with the names of the content of a 
> >> column 'crop' in a way that the new variable 'SWHE' would receive a value 
> >> of 1 if the column 'crop' contains 'SWHE' and 0 otherwise. So, I would 
> >> have two new variables SWHE and BARL as below:
> >> 
> >> 
> >> fid  crop  year  value  SWHE  BARL   
> >> 5_1_1  SWHE  1995  171  1  0   
> >> 5_1_1  SWHE  1997  696  1  0   
> >> 5_1_1  BARL  1996  114  0  1   
> >> 5_1_1  BARL  1997  344  0  1   
> >> 5_2_2  SWHE  1995  120  1  0   
> >> 5_2_2  SWHE  1996  511  1  0   
> >> 5_2_2  BARL  1996  239  0  1   
> >> 5_2_2  BARL  1997  349  0  1   
> >> 
> >> 
> >> Cheers,
> >> Shyam
> >> Nepal
> >> 
> 
> David Winsemius
> Alameda, CA, USA
> 
> __
> 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.
> 

David Winsemius
Alameda, CA, USA

__
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] creating dummy variables

2013-04-20 Thread Bert Gunter
To all who ask about dummy variables in R:

Please please read the "Introduction to R" section on "Statistical Models
in R" or other tutorial (there are many on the web) on regression modeling
in R. (For that matter -- please read all of this or other basic R tutorial
before posting here!). An excellent but somewhat terse and technical
discussion can be found in the latest edition of V&R's MASS -- the chapter
on linear models. I do not intend to (poorly) try to recapitulate what
others have already (well) explained. Do Your Homework!

Documentation within R can be found in

?lm
?formula
?contrasts
?model.matrix

These may not make much sense unless you have done your homework first --
or already understand the statistical issues.

-- Bert





On Sat, Apr 20, 2013 at 3:56 PM, Eva Prieto Castro wrote:

>
> Hi,
>
> Why do you write that dummy variables are not needed in R?. I would like
> you explain it.
>
> Thanks,
>
> Eva
>
> --- El *dom, 21/4/13, David Winsemius * escribió:
>
>
> De: David Winsemius 
> Asunto: Re: [R] creating dummy variables
> Para: "Bert Gunter" 
> CC: "r-help@R-project.org" , "shyam basnet" <
> shyamabc2...@yahoo.com>
> Fecha: domingo, 21 de abril, 2013 00:38
>
>
> On Apr 20, 2013, at 2:03 PM, Bert Gunter wrote:
>
> > Dummy variables are not needed in R.
> >
> > Bert
> >
>
> Bert is correct on this point, but if you what to know how the regression
> functions in R do this "behind the scenes" then you could always look at:
>
> ?model.matrix # where _some_ of the the automagical stuff happens
>
> > model.matrix( ~ crop, data=dat[,"crop", drop=FALSE])
>   (Intercept) cropSWHE
> 1   11
> 2   11
> 3   10
> 4   10
> 5   11
> 6   11
> 7   10
> 8   10
> attr(,"assign")
> [1] 0 1
> attr(,"contrasts")
> attr(,"contrasts")$crop
> [1] "contr.treatment"
>
>
>
> > Sent from my iPhone -- please excuse typos.
> >
> > On Apr 20, 2013, at 11:23 AM, shyam basnet 
> > http://mc/compose?to=shyamabc2...@yahoo.com>>
> wrote:
> >
> >> Hello R-users,
> >>
> >> The below is a snippet of my data:
> >>
> >>
> >> fid  crop  year  value
> >> 5_1_1  SWHE  1995  171
> >> 5_1_1  SWHE  1997  696
> >> 5_1_1  BARL  1996  114
> >> 5_1_1  BARL  1997  344
> >> 5_2_2  SWHE  1995  120
> >> 5_2_2  SWHE  1996  511
> >> 5_2_2  BARL  1996  239
> >> 5_2_2  BARL  1997  349
> >>
> >> Here, I want to create dummy variables with the names of the content of
> a column 'crop' in a way that the new variable 'SWHE' would receive a value
> of 1 if the column 'crop' contains 'SWHE' and 0 otherwise. So, I would have
> two new variables SWHE and BARL as below:
> >>
> >>
> >> fid  crop  year  value  SWHE  BARL
> >> 5_1_1  SWHE  1995  171  1  0
> >> 5_1_1  SWHE  1997  696  1  0
> >> 5_1_1  BARL  1996  114  0  1
> >> 5_1_1  BARL  1997  344  0  1
> >> 5_2_2  SWHE  1995  120  1  0
> >> 5_2_2  SWHE  1996  511  1  0
> >> 5_2_2  BARL  1996  239  0  1
> >> 5_2_2  BARL  1997  349  0  1
> >>
> >>
> >> Cheers,
> >> Shyam
> >> Nepal
> >>
>
> David Winsemius
> Alameda, CA, USA
>
> __
> 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.
>
>


-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

[[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] Source Code

2013-04-20 Thread R. Michael Weylandt


On Apr 20, 2013, at 7:13 PM, David Winsemius  wrote:

> 
> On Apr 20, 2013, at 4:05 PM, Eva Prieto Castro wrote:
> 
>> 
>> Thanks!. The problem is that I can't see the source code in .Internal(txt...
> 
> Exactly which was why I provided the link to Ligges' article. (So now you 
> _are_ expected to do some self-study.)
> 

Note also that the graphics code isn't exactly the easiest either (to my mind) 
-- perhaps you could say a bit about what you are after and we'll try to give 
pointers as best we're able. 

MW

(Sorry for brain borking in the text() function earlier -- I blame it on the 
travel!)


> -- 
> David.
>> 
>> 
>>> text.default
>> function (x, y = NULL, labels = seq_along(x), adj = NULL, pos = NULL, 
>>offset = 0.5, vfont = NULL, cex = 1, col = NULL, font = NULL, 
>>...) 
>> {
>>if (!missing(y) && (is.character(y) || is.expression(y))) {
>>labels <- y
>>y <- NULL
>>}
>>labels <- as.graphicsAnnot(labels)
>>if (!is.null(vfont)) 
>>vfont <- c(typeface = pmatch(vfont[1L], Hershey$typeface), 
>>fontindex = pmatch(vfont[2L], Hershey$fontindex))
>>.Internal(text(xy.coords(x, y, recycle = TRUE), labels, adj, 
>>pos, offset, vfont, cex, col, font, ...))
>> }
>> 
>> 
>> 
>> Regards,
>> 
>> Eva
>> 
>> --- El dom, 21/4/13, David Winsemius  escribió:
>> 
>> De: David Winsemius 
>> Asunto: Re: [R] Source Code
>> Para: "R. Michael Weylandt " 
>> 
>> CC: "Eva Prieto Castro" , "" 
>> 
>> Fecha: domingo, 21 de abril, 2013 00:45
>> 
>> 
>> On Apr 20, 2013, at 3:34 PM, R. Michael Weylandt 
>>  wrote:
>> 
>>> 
>>> 
>>> On Apr 20, 2013, at 6:23 PM, Eva Prieto Castro  wrote:
>>> 
 Dear all,
 
 How can I get the source code of text function?
>>> 
>>> What is the 'text function'?
>>> 
>>> Try typing the name of the function at the prompt without any parentheses 
>>> after it. If its written in R, then it should be visible.
>> 
>> (It's not, .. or at least it might not seem so to a newbR.)
>> 
>>> text
>> function (x, ...) 
>> UseMethod("text")
>> 
>> 
>> 
>> 
>> methods(text)
>> text.default
>> graphics:::trext.formula
>> 
>> And then  to go further ... I think she may need the added information 
>> in Uwe Ligges classic R-News article:
>> 
>> http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf
>> 
>> 
>> -- 
>> David Winsemius
>> Alameda, CA, USA
> 
> David Winsemius
> Alameda, CA, USA
> 

__
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] Foundation for Open Access Statistics

2013-04-20 Thread Jan de Leeuw
The Foundation for Open Access Statistics is a nonprofit public benefit 
corporation registered in California. We have applied for federal tax-exempt 
status under Internal Revenue Section 501(c)(3). FOAS has a worldwide mission 
to promote free software, open access publishing, and reproducible research in 
statistics. 

Currently, the Journal of Statistical Software is the only FOAS project. JSS 
has grown rapidly over the 15 years of its existence, in page count, quality, 
and impact. It needs a more stable support structure to guarantee its continued 
existence and growth.

On the website 

http://www.foastat.org

you can join FOAS, and/or make financial contributions. We invite you to 
contribute ideas, projects, and materials for the FOAS site.

Jan de Leeuw, email: jan.dele...@foastat.org 
Katharine Mullen, email: katharine.mul...@foastat.org 
Achim Zeileis, email: achim.zeil...@foastat.org

__
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] creating dummy variables

2013-04-20 Thread Rolf Turner

On 21/04/13 10:56, Eva Prieto Castro wrote:

Hi,

Why do you write that dummy variables are not needed in R?. I would like you 
explain it.


As others have said --- do some self-study.  But a brief answer is that 
in any
"reasonable" modelling problem in which dummy variables might arise, R 
creates
the dummy variables that it uses automagically , behind the scenes, from 
the *factors*

whose levels correspond to the dummy variables.

Summary:  Learn about and understand *factors*; forget about dummy
variables.

cheers,

Rolf Turner

__
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 CMD build

2013-04-20 Thread Henrik Bengtsson
On Sat, Apr 20, 2013 at 3:10 PM, Knut Krueger  wrote:
> Am 20.04.2013 15:50, schrieb Gabor Grothendieck:
>
>> Note that there is a separate directory for the 64-bit R executables.
>
> Does it make any difference to check and pack the source files iwth 32 or 64
> bit?
>
>> Also, downloading MinGW should not be needed. Rtools already contains the
>> needed UNIX utilities.
>
> Yes indeed it works better than MinGW
>
>
>> You might want to look into the Windows batch files at
>> http://batchfiles.googlecode.com .
>
>
> At least it would be very helpful for windows user to give the hint to the
> executable rcmd.exe build ... instead of R cmd build ...

FYI,

R CMD build ...

works just fine on Windows (and I'm sure R cmd build ... won't).

/Henrik

>
> I already set up an linux system today to solve the problem 
>
> Thank you
> Knut
>
>
> __
> 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] R CMD build

2013-04-20 Thread Gabor Grothendieck
On Sat, Apr 20, 2013 at 10:14 PM, Henrik Bengtsson  
wrote:
> On Sat, Apr 20, 2013 at 3:10 PM, Knut Krueger  wrote:
>> Am 20.04.2013 15:50, schrieb Gabor Grothendieck:
>>
>>> Note that there is a separate directory for the 64-bit R executables.
>>
>> Does it make any difference to check and pack the source files iwth 32 or 64
>> bit?
>>
>>> Also, downloading MinGW should not be needed. Rtools already contains the
>>> needed UNIX utilities.
>>
>> Yes indeed it works better than MinGW
>>
>>
>>> You might want to look into the Windows batch files at
>>> http://batchfiles.googlecode.com .
>>
>>
>> At least it would be very helpful for windows user to give the hint to the
>> executable rcmd.exe build ... instead of R cmd build ...
>
> FYI,
>
> R CMD build ...
>
> works just fine on Windows (and I'm sure R cmd build ... won't).
>

That is correct but if one were using the batchfiles I mentioned then both work.

--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

__
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] The secret of wisdom, power and knowledge is humility.

2013-04-20 Thread Eva Prieto Castro

Dear all,

Thank for your friendliness. 

I have read several documents and I'm sure that if I have time to read ALL 
documents in the world I would not need to be part of this list, because of my 
capabilities...

I have used this idea (factors) in several cases in which dummy variables 
arise, but I asked about the question because (in relation with my humility) I 
thought I had used the idea incorrectly. Nevertheless, I have noticed all I 
know is all I have to know about this question.

Regards.

Eva

--- El dom, 21/4/13, Rolf Turner  escribió:

De: Rolf Turner 
Asunto: Re: [R] creating dummy variables
Para: "Eva Prieto Castro" 
CC: "r-help@R-project.org" 
Fecha: domingo, 21 de abril, 2013 03:16

On 21/04/13 10:56, Eva Prieto Castro wrote:
> Hi,
> 
> Why do you write that dummy variables are not needed in R?. I would like you 
> explain it.

As others have said --- do some self-study.  But a brief answer is that in any
"reasonable" modelling problem in which dummy variables might arise, R creates
the dummy variables that it uses automagically , behind the scenes, from the 
*factors*
whose levels correspond to the dummy variables.

Summary:  Learn about and understand *factors*; forget about dummy
variables.

    cheers,

        Rolf Turner

[[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] creating dummy variables

2013-04-20 Thread Santosh
R is for dummies (like me, but I don't use dummy variables) or for the
non-Dummies like all experts who help us all the time@@.. so dummy
variables are not needed! :)
QED...


On Sat, Apr 20, 2013 at 6:16 PM, Rolf Turner  wrote:

> On 21/04/13 10:56, Eva Prieto Castro wrote:
>
>> Hi,
>>
>> Why do you write that dummy variables are not needed in R?. I would like
>> you explain it.
>>
>
> As others have said --- do some self-study.  But a brief answer is that in
> any
> "reasonable" modelling problem in which dummy variables might arise, R
> creates
> the dummy variables that it uses automagically , behind the scenes, from
> the *factors*
> whose levels correspond to the dummy variables.
>
> Summary:  Learn about and understand *factors*; forget about dummy
> variables.
>
> cheers,
>
> Rolf Turner
>
>
> __**
> 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] cluster gene list

2013-04-20 Thread Sudhir Singh
 Hi,

I have created a heatmap using heatmap.2 having 7 clusters.  I would like
to extract the list of genes that are in these 7 clusters.

 Is there any function that can be used to extract genes for each cluster?

Cheers,

Sudhir

-- 
__

SAVE PAPER - Please do not print this e-mail unless absolutely necessary
Being happy doesn't mean everything's perfect.
It means you've decided to see beyond  imperfections.
__

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