Re: [R] Neural Network

2015-01-23 Thread javad bayat via R-help
Dear All;
Many thanks for your attention. what I want to know is: How can I predict the 
Eutrophication by these parameters in the future?
These variables are the most important variables that control the Eutro. in 
lakes.
Let me break it to two parts.
1) How can I predict these variables by NN?
2) Is it possible to predict the Eutro. by these variables?


Many thanks for your help.
Regards,

On Thu, 1/22/15, Charles Determan Jr  wrote:

 Subject: Re: [R] Neural Network

roject.org>
 Date: Thursday, January 22, 2015, 4:41 PM

 Javad,
 First,
 please make sure to hit 'reply all' so that these
 messages go to the R help list so others (many far more
 skilled than I) may possibly chime in.
 The problem here is that you appear
 to have no dependent variable (i.e. no eutrophication
 variable).  Without it, there is no way to a typical
 'supervised' analysis.  Given that this is likely a
 regression type problem (I assume eutrophication would be
 continous) I'm not quite sure 'supervised' is
 the correct description but it furthers my point that you
 need a dependent variable for any neuralnet algorithm I am
 aware of.  As such, if you don't have a dependent
 variable then you will need to look at unsupervised methods
 such as PCA.  Other users may have other
 suggestions.
 Regards,Charles
 On Wed, Jan 21, 2015 at

 wrote:
 Dear
 Charles;

 Many thanks for your attention. what I want to know is: How
 can I predict the Eutrophication by these parameters in the
 future?

 These variables are the most important variables that
 control the Eutro. in lakes.

 Let me break it to two parts.

 1) How can I predict these variables by NN?

 2) Is it possible to predict the Eutro. by these
 variables?





 Many thanks for your help.

  Regards,















 

 On Wed, 1/21/15, Charles Determan Jr 
 wrote:



  Subject: Re: [R] Neural Network



  Cc: "r-help@r-project.org"
 

  Date: Wednesday, January 21, 2015, 9:10 PM



  Javad,

  You

  question is a little too broad to be answered

  definitively.  Also, this is not a code writing
 service. 

  You should make a meaningful attempt and we are here to
 help

  when you get stuck.

  1.

  If you want to know if you can do neural nets, the answer
 is

  yes.  The three packages most commonly used (that I
 know

  of) are 'neuralnet', 'nnet' and

  'RSNNS'.  You should look in to these package

  documentation for how to use them.  There are also
 many

  examples online if you simply google them.

  2. You question is unclear, are you

  wanting to predict all the variables (e.g. phosphorus,
 Total

  N, etc.) or do you have some metric for
 eutrophication? 

  What exactly is the model supposed to predict?

  3. If you want to know if a

  neuralnet is appropriate, that is more of a statistical

  question.  It depends more on the question you want to

  answer.  Given your temporal data, you may want to look
 in

  to mixed effects models (e.g nlme, lme4) as another

  potential approach.

  Regards,

  On Tue, Jan 20, 2015 at

  11:35 PM, javad bayat via R-help 

  wrote:

  Dear

  all;



  I am the new user of R. I want to simulation or
 prediction

  the Eutrophication of a lake. I have weekly data(almost
 for

  two years) for Total phosphorus, Total N, pH, Chlorophyll
 a,

  Alkalinity, Silica.



  Can I predict the Eutrophication by Neural Network in
 R?



  How can I simulation the Eutrophication by these

  parameter?



  please help me to write the codes.



  many thanks.







  __



  R-help@r-project.org

  mailing list -- To UNSUBSCRIBE and more, see



  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.









  --

  Dr. Charles Determan, PhD

  Integrated Biosciences








 -- 
 Dr. Charles Determan, PhD
 Integrated Biosciences

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Neural Network

2015-01-23 Thread javad bayat via R-help
Dear Charles;
I think my variables are dependent. For e.g. the concentration of  Phosphorus, 
Nitrogen, Silica and etc. have effect on the present of Chlorophyll a and the 
concentration of Chlorophyll a can make the Eutrophication in lake along with 
other algeas. 
So I think they are dependent variables.
Regards. 




On Thu, 1/22/15, Charles Determan Jr  wrote:

 Subject: Re: [R] Neural Network

roject.org>
 Date: Thursday, January 22, 2015, 4:41 PM

 Javad,
 First,
 please make sure to hit 'reply all' so that these
 messages go to the R help list so others (many far more
 skilled than I) may possibly chime in.
 The problem here is that you appear
 to have no dependent variable (i.e. no eutrophication
 variable).  Without it, there is no way to a typical
 'supervised' analysis.  Given that this is likely a
 regression type problem (I assume eutrophication would be
 continous) I'm not quite sure 'supervised' is
 the correct description but it furthers my point that you
 need a dependent variable for any neuralnet algorithm I am
 aware of.  As such, if you don't have a dependent
 variable then you will need to look at unsupervised methods
 such as PCA.  Other users may have other
 suggestions.
 Regards,Charles
 On Wed, Jan 21, 2015 at

 wrote:
 Dear
 Charles;

 Many thanks for your attention. what I want to know is: How
 can I predict the Eutrophication by these parameters in the
 future?

 These variables are the most important variables that
 control the Eutro. in lakes.

 Let me break it to two parts.

 1) How can I predict these variables by NN?

 2) Is it possible to predict the Eutro. by these
 variables?





 Many thanks for your help.

  Regards,















 

 On Wed, 1/21/15, Charles Determan Jr 
 wrote:



  Subject: Re: [R] Neural Network



  Cc: "r-help@r-project.org"
 

  Date: Wednesday, January 21, 2015, 9:10 PM



  Javad,

  You

  question is a little too broad to be answered

  definitively.  Also, this is not a code writing
 service. 

  You should make a meaningful attempt and we are here to
 help

  when you get stuck.

  1.

  If you want to know if you can do neural nets, the answer
 is

  yes.  The three packages most commonly used (that I
 know

  of) are 'neuralnet', 'nnet' and

  'RSNNS'.  You should look in to these package

  documentation for how to use them.  There are also
 many

  examples online if you simply google them.

  2. You question is unclear, are you

  wanting to predict all the variables (e.g. phosphorus,
 Total

  N, etc.) or do you have some metric for
 eutrophication? 

  What exactly is the model supposed to predict?

  3. If you want to know if a

  neuralnet is appropriate, that is more of a statistical

  question.  It depends more on the question you want to

  answer.  Given your temporal data, you may want to look
 in

  to mixed effects models (e.g nlme, lme4) as another

  potential approach.

  Regards,

  On Tue, Jan 20, 2015 at

  11:35 PM, javad bayat via R-help 

  wrote:

  Dear

  all;



  I am the new user of R. I want to simulation or
 prediction

  the Eutrophication of a lake. I have weekly data(almost
 for

  two years) for Total phosphorus, Total N, pH, Chlorophyll
 a,

  Alkalinity, Silica.



  Can I predict the Eutrophication by Neural Network in
 R?



  How can I simulation the Eutrophication by these

  parameter?



  please help me to write the codes.



  many thanks.







  __



  R-help@r-project.org

  mailing list -- To UNSUBSCRIBE and more, see



  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.









  --

  Dr. Charles Determan, PhD

  Integrated Biosciences








 -- 
 Dr. Charles Determan, PhD
 Integrated Biosciences

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Operations with dates just as Month and Day and not Year

2015-01-23 Thread Camilo Mora
Hi everyone,

I am trying to calculate the number of days between any two dates in a year 
regardless of the year. Specifically, image two dates:
MonDay1 <-   "01-30"  #January 30
MonDay2 <-   "12-31"  #December 31

I want the difference of those two dates to be
MonDay1- MonDay2=30 days   #January is closer to December from the prior year 
than to the December in the year when January is.

FYI. this calculation is to count the number of days between any given date to 
the peak of the summer, which in the southern hemisphere can be around December.

Unfortunately, I have not been able to make R recognize a date as just Mon-Day. 
If I try:
MonDay1<-as.Date("01-30",format="%m-%d")# this automatically assigns the 
current year
[1] "2015-01-30"

This following code allows to define just Mon-Day but it is recognized as 
character:
format(strptime("07-30", format="%j"), format="%m-%d")

Any help will be greatly appreciated,

Thanks,

Camilo
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] correlation between categorical data

2015-01-23 Thread JohnDee
Heinz Tuechler wrote
> At 07:40 21.06.2009, J Dougherty wrote:
> 
> [...]
>>There are other ways of regarding the FET.  Since it is precisely 
>>what it says
>>- an exact test - you can argue that you should avoid carrying over any
>>conclusions drawn about the small population the test was applied to and
>>employing them in a broader context.  In so far as the test is concerned,
the
>>"sample" data and the contingency table it is arrayed in are the entire
>>universe.  In that sense, the FET can't be "conservative" or "liberal." 
It
>>isn't actually a hypothesis test and should not be thought of as one or
used
>>in the place of one.
>> >
>>JDougherty
> 
> Could you give some reference, supporting this, for me, surprising 
> view? I don't see a necessary connection between an exact test and 
> the idea that it does not test a hypothesis.
> 
> Thanks,
> Heinz
> 
> __

> R-help@

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

Fisher's Exact Test is a nonparametric "test."  It tests the distribution in
the contingency table against the total possible arrangements and gives you
the precise likelihood of that many items being arranged in that manner.  No
more and no less.  You could argue about the greater population from which
your sample is drawn, but FET makes no assumptions at all about any greater
sample universe.  Also, since the "population" being used in FET is strictly
limited to the members of the contingency table, the results are a subset of
a finite group of possible results that are relevant to that specific
arrangement of data.  You are not "estimating" parameters of a parent
population or making any assumptions about the parent distribution.  You can
designate a "p" value such as 0.05 as a level of significance, but there is
no "error" term in the FET result.  Fisher stated that the test DOES assume
a null hypothesis of independence to a hypergeometric distribution of the
cell members.  But that creates other issues if you are attempting to use
the results in conjunction with assumptions about a broader sample universe
than that in the test.  For instance you have to carry the assumption of a
hypergeometric distribution over in to the land of reality your sample is
drawn from and you then have to justify that.  



--
View this message in context: 
http://r.789695.n4.nabble.com/correlation-between-categorical-data-tp888975p4702235.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] get latest dates for different people in a dataset

2015-01-23 Thread Chel Hee Lee
> do.call(rbind, lapply(split(data, data$Name), function(x) 
x[order(x$CheckInDate),][nrow(x),]))

 Name CheckInDate Temp
John John  2014-04-01 99.0
Mary Mary  2014-03-01 98.1
Sam   Sam  2014-04-01 97.5
>

Is this what you are looking for?  I hope this helps.

Chel Hee Lee

On 01/23/2015 05:43 PM, Tan, Richard wrote:

Hi,

Can someone help for a R question?

I have a data set like:

NameCheckInDate  Temp
John  1/3/2014  97
Mary 1/3/2014  98.1
Sam   1/4/2014  97.5
John  1/4/2014  99

I'd like to return a dataset that for each Name, get the row that is the latest 
CheckInDate for that person.  For the example above it would be

NameCheckInDate  Temp
John  1/4/2014  99
Mary 1/3/2014  98.1
Sam   1/4/2014  97.5


Thank you for your help!

Richard


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] get latest dates for different people in a dataset

2015-01-23 Thread William Dunlap
Here is one way.  Sort the data.frame, first by Name then break ties with
CheckInDate.
Then choose the rows that are the last in a run of identical Name values.

> txt <- "NameCheckInDate  Temp
+ John  1/3/2014  97
+ Mary 1/3/2014  98.1
+ Sam   1/4/2014  97.5
+ John  1/4/2014  99"
> d <- read.table(header=TRUE,
colClasses=c("character","character","numeric"), text=txt)
> d$CheckInDate <- as.Date(d$CheckInDate, as.Date, format="%d/%m/%Y")
> isEndOfRun <- function(x) c(x[-1] != x[-length(x)], TRUE)
> dSorted <- d[order(d$Name, d$CheckInDate), ]
> dLatestVisit <- dSorted[isEndOfRun(dSorted$Name), ]
> dLatestVisit
  Name CheckInDate Temp
4 John  2014-04-01 99.0
2 Mary  2014-03-01 98.1
3  Sam  2014-04-01 97.5


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Fri, Jan 23, 2015 at 3:43 PM, Tan, Richard  wrote:

> Hi,
>
> Can someone help for a R question?
>
> I have a data set like:
>
> NameCheckInDate  Temp
> John  1/3/2014  97
> Mary 1/3/2014  98.1
> Sam   1/4/2014  97.5
> John  1/4/2014  99
>
> I'd like to return a dataset that for each Name, get the row that is the
> latest CheckInDate for that person.  For the example above it would be
>
> NameCheckInDate  Temp
> John  1/4/2014  99
> Mary 1/3/2014  98.1
> Sam   1/4/2014  97.5
>
>
> Thank you for your help!
>
> Richard
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] get latest dates for different people in a dataset

2015-01-23 Thread Tan, Richard
Hi,

Can someone help for a R question?

I have a data set like:

NameCheckInDate  Temp
John  1/3/2014  97
Mary 1/3/2014  98.1
Sam   1/4/2014  97.5
John  1/4/2014  99

I'd like to return a dataset that for each Name, get the row that is the latest 
CheckInDate for that person.  For the example above it would be

NameCheckInDate  Temp
John  1/4/2014  99
Mary 1/3/2014  98.1
Sam   1/4/2014  97.5


Thank you for your help!

Richard


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] plot circles where z values are circles radius

2015-01-23 Thread Jim Lemon
Hi Alireza,
Part of the problem is the scale of your numbers. You probably want
something like this.

plot(x,y,cex=z/min(z)*2)

What happens here is that the default plotting character, which
happens to be a circle, is plotted in a size relative to the ratio of
each z value to the minimum z value. This is because the default value
of cex is 1. I have multiplied the result by 2 to make what is
happening more obvious. If you want to generate circles with specific
diameters, you will have to scale these to the area of the plot in
user units - see par("usr").

Jim


On Sat, Jan 24, 2015 at 8:29 AM, Thomas Adams  wrote:
> I think what you should look at are these web sites I found with a Google
> search:
>
> http://flowingdata.com/2010/11/23/how-to-make-bubble-charts/
> http://www.r-bloggers.com/bubble-plots-ggplot2/
> http://cran.r-project.org/web/packages/HSAUR/vignettes/Ch_logistic_regression_glm.pdf
> http://cran.r-project.org/web/packages/mapplots/mapplots.pdf
>
>
> Cheers!
> Tom
>
> On Fri, Jan 23, 2015 at 2:12 PM, Dr. Alireza Zolfaghari <
> ali.zolfagh...@gmail.com> wrote:
>
>> Hi there,
>> I am trying to plot z values using Circle symbol. Each x and y has a value
>> which will be plotted using a circle where circle's radius is corrlated
>> with the value of z.
>>
>> I wrote the code , but unable to change the size of circle no matter what I
>> chose for Scale. Any help please?
>>
>> x=c(84390255386 ,84390255386, 78028317380 ,53594648044,422)
>> y=c(949849442 ,941645043, 840135292, 74, 821632939)
>> z=c(0.005641896, 0.005641896 ,0.005641896, 0.007978846,0.007978846)
>>
>> convertToRadius<-function(x){return(sqrt(x/pi))}
>>
>> scale=0.3
>>
>> xlims =c(min(x),max(x))
>> ylims =c(min(y),max(y))
>> z=convertToRadius(z)*scale
>>
>> symbols(x,y, circles=z,  fg='red')
>>
>> thanks
>> Alireza
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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 -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] need help with renaming a variable

2015-01-23 Thread Jim Lemon
Hi Pavel,
I probably should have explained that an object name beginning with a
number is not valid. See "An Introduction to R", section 1.8. I think
that the invalid name "2013fixed.data" has somehow been generated. If
you can find where this occurred and change it to "fixed2013.data" the
original error should disappear.

Jim


On Sat, Jan 24, 2015 at 5:51 AM, Pavel Yakovlev  wrote:
> Jim, I tried as you suggested but it also did not work. Here's the error:
> rxSetVarInfo(fixed2013.data, outfile)
> Error in rxSetVarInfoXdf(varInfo, file = data) :
>   object 'fixed2013.data' not found
>
> On Thu, Jan 22, 2015 at 5:50 PM, Jim Lemon  wrote:
>>
>> Hi Pavel,
>> The problem may be with the name "2013fixed.data". I don't know where
>> that came from, but try naming it "fixed2013.data".
>>
>> Jim
>>
>>
>> On Fri, Jan 23, 2015 at 4:53 AM, Pavel Yakovlev 
>> wrote:
>> > Hello.
>> >
>> > I am new to R, so my question/problem might be very basic, but I cannot
>> > figure out how to solve it.
>> > So, I would really appreciate your help.
>> >
>> > I would like to rename a variable in a very large file (181GB) called
>> > "2013.xdf" that is saved on my external hard drive.
>> >
>> > I tried running the following code to rename variable # 2 in the file
>> > and
>> > save this change, which produced some errors that I cannot resolve:
>> >
>> >> temp.data <- rxGetVarInfo("E:/2013.xdf")
>> >> temp.data[2] <- "transsactionnumber"
>> >> rxSetVarInfo(2013fixed.data, outfile)
>> > Error: unexpected symbol in "rxSetVarInfo(2013fixed.data"
>> >> rxSetVarInfo(temp.data, outfile)
>> > Error in is.data.frame(file) : object 'outfile' not found
>> >> rxSetVarInfo(outfile)
>> > Error in rxSetVarInfoXdf(varInfo, file = data) :
>> >   object 'outfile' not found
>> >
>> >
>> > Please help me figure out how to do it right.
>> >
>> > Gratefully,
>> > --
>> >
>> > Pavel A. Yakovlev, Ph.D.
>> > Associate Professor
>> > 819 Rockwell Hall
>> > Department of Economics and Finance
>> > Duquesne University
>> > 600 Forbes Avenue
>> > Pittsburgh, PA 15282
>> > Work Phone: 412-396-1908
>> >
>> > [[alternative HTML version deleted]]
>> >
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > 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.
>
>
>
>
> --
>
> Pavel A. Yakovlev, Ph.D.
> Associate Professor
> 819 Rockwell Hall
> Department of Economics and Finance
> Duquesne University
> 600 Forbes Avenue
> Pittsburgh, PA 15282
> Work Phone: 412-396-1908

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] plot circles where z values are circles radius

2015-01-23 Thread Thomas Adams
I think what you should look at are these web sites I found with a Google
search:

http://flowingdata.com/2010/11/23/how-to-make-bubble-charts/
http://www.r-bloggers.com/bubble-plots-ggplot2/
http://cran.r-project.org/web/packages/HSAUR/vignettes/Ch_logistic_regression_glm.pdf
http://cran.r-project.org/web/packages/mapplots/mapplots.pdf


Cheers!
Tom

On Fri, Jan 23, 2015 at 2:12 PM, Dr. Alireza Zolfaghari <
ali.zolfagh...@gmail.com> wrote:

> Hi there,
> I am trying to plot z values using Circle symbol. Each x and y has a value
> which will be plotted using a circle where circle's radius is corrlated
> with the value of z.
>
> I wrote the code , but unable to change the size of circle no matter what I
> chose for Scale. Any help please?
>
> x=c(84390255386 ,84390255386, 78028317380 ,53594648044,422)
> y=c(949849442 ,941645043, 840135292, 74, 821632939)
> z=c(0.005641896, 0.005641896 ,0.005641896, 0.007978846,0.007978846)
>
> convertToRadius<-function(x){return(sqrt(x/pi))}
>
> scale=0.3
>
> xlims =c(min(x),max(x))
> ylims =c(min(y),max(y))
> z=convertToRadius(z)*scale
>
> symbols(x,y, circles=z,  fg='red')
>
> thanks
> Alireza
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] plot circles where z values are circles radius

2015-01-23 Thread Kehl Dániel
Hi,

see the help and especially the argument inches:

Argument inches controls the sizes of the symbols. If TRUE (the default), the 
symbols are scaled so that the largest dimension of any symbol is one inch. If 
a positive number is given the symbols are scaled to make largest dimension 
this size in inches (so TRUE and 1 are equivalent). If inches is FALSE, the 
units are taken to be those of the appropriate axes. (For circles, squares and 
stars the units of the x axis are used. For boxplots, the lengths of the 
whiskers are regarded as dimensions alongside width and height when scaling by 
inches, and are otherwise interpreted in the units of the y axis.)

Try 

scale=5000

xlims =c(min(x),max(x))
ylims =c(min(y),max(y))
z=convertToRadius(z)*scale

symbols(x,y, circles=z,  fg='red', inches=FALSE)

HTH
kd

Feladó: R-help [r-help-boun...@r-project.org] ; meghatalmazó: Dr. Alireza 
Zolfaghari [ali.zolfagh...@gmail.com]
Küldve: 2015. január 23. 22:12
To: R-help; r-help-requ...@r-project.org
Tárgy: [R] plot circles where z values are circles radius

Hi there,
I am trying to plot z values using Circle symbol. Each x and y has a value
which will be plotted using a circle where circle's radius is corrlated
with the value of z.

I wrote the code , but unable to change the size of circle no matter what I
chose for Scale. Any help please?

x=c(84390255386 ,84390255386, 78028317380 ,53594648044,422)
y=c(949849442 ,941645043, 840135292, 74, 821632939)
z=c(0.005641896, 0.005641896 ,0.005641896, 0.007978846,0.007978846)

convertToRadius<-function(x){return(sqrt(x/pi))}

scale=0.3

xlims =c(min(x),max(x))
ylims =c(min(y),max(y))
z=convertToRadius(z)*scale

symbols(x,y, circles=z,  fg='red')

thanks
Alireza

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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] plot circles where z values are circles radius

2015-01-23 Thread Dr. Alireza Zolfaghari
Hi there,
I am trying to plot z values using Circle symbol. Each x and y has a value
which will be plotted using a circle where circle's radius is corrlated
with the value of z.

I wrote the code , but unable to change the size of circle no matter what I
chose for Scale. Any help please?

x=c(84390255386 ,84390255386, 78028317380 ,53594648044,422)
y=c(949849442 ,941645043, 840135292, 74, 821632939)
z=c(0.005641896, 0.005641896 ,0.005641896, 0.007978846,0.007978846)

convertToRadius<-function(x){return(sqrt(x/pi))}

scale=0.3

xlims =c(min(x),max(x))
ylims =c(min(y),max(y))
z=convertToRadius(z)*scale

symbols(x,y, circles=z,  fg='red')

thanks
Alireza

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Testing for significant differences between groups in multiple linear regression

2015-01-23 Thread Bert Gunter
Look no further!  The answer is yes.

However,  if you are interested in why your query is probably nonsense
and why overall tests of significance are a **really bad idea** in
most scientific contexts (imho, anyway), then I suggest you post to a
statistical list like stats.stackexchange.com .

... oh, and while you're at it, please read the posting guide for this
list (see link below) and, in particular, DO NOT POST IN HTML, which,
as you can see here, often becomes a mess on this **plain text**
mailing list.

Cheers,
Bert


Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
Clifford Stoll




On Fri, Jan 23, 2015 at 1:46 AM, Janka Vanschoenwinkel
 wrote:
> Dear R-colleagues,
>
> I am looking for a way to test whether one regression has significant
> different coefficients and overall results for 10 groups (grouping variable
> is "irr").
>
>
>
> *What I have*
>
> The regression is:
>
> Depend = temp + temp² + perc + perc² + conti è split up for multiple groups
> of irr
>
>
>   *Dataset = Alldata (real dataset has over 5 IDs)*
>
> *ID*
>
> *irr *
>
> *(= grouping variable)*
>
> *temp*
>
> *perc*
>
> *conti*
>
> *Depend*
>
> *w*
>
> 1
>
> 1
>
> 10
>
> 34
>
> 26
>
> 8
>
> 23
>
> 2
>
> 1
>
> 11
>
> 36
>
> 27
>
> 6
>
> 58
>
> 3
>
> 1
>
> 26
>
> 57
>
> 45
>
> 3
>
> 76
>
> 4
>
> 2
>
> 23
>
> 68
>
> 24
>
> 2
>
> 4
>
> 5
>
> 2
>
> 6
>
> 26
>
> 8
>
> 1
>
> 323
>
> 6
>
> 2
>
> 3
>
> 17
>
> 56
>
> 6
>
> 45
>
> 7
>
> 3
>
> 17
>
> 39
>
> 17
>
> 5
>
> 57
>
>
>
> I can obtain the different regression coefficients for the different groups
> with the following code (other codes are possible as wel).
>
>
> datairrigation <- split(Alldata, Alldata$irr)
>
> model.per.irrigation <- lapply(datairrigation, function (x) {
>
>   lm(Depend~ temp + temp² + perc + perc² + conti,
>
>  weights=w, data = x)
>
> })
>
>
> OR I can do it manually by splitting all the data in subsets (and then I
> also receive the R²…)
>
>
>
> *What I don’t have*
>
> However, now I don’t know how to compare those regressions to test whether
> they differ significantly over all the groups.
>
> (Preferably, I would like to test the coefficients individually (temp(group
> 1) = temp(group2)) and the regression as a whole between the groups.)
>
>
>
> *Note*
>
> I know that one way to test differences in significance between groups, is
> to use dummy variables of that group, in the regression. Yet, this is no
> option for my model because it only allows exogenous variables in the
> regression (and irrigation is an endogenous variable because the farmer can
> decide himself if he irrigates or not).
>
>
>
> Thank you very much in advance! I really appreciate your help!
>
>
> Janka
>
>
> P Please consider the environment before printing this e-mail
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] Best method of analysis for negatively skewed longitudinal environmental data?

2015-01-23 Thread kmurphy
I have a dataset composed of a dependent variable (species percent cover) and
a range of abiotic variables (salinity, temperature, pH, water movement
etc). It is a longitudinal study, in which species percent cover was
measured once a month for five months. The abiotic variables were measured
using data-loggers every five minutes for the entire duration of the study.
I have organised those data as monthly means in order to compare them with
the species percent cover values. I have 13 study sites, at each of which I
used three settlement collectors (each of the collectors is composed of
three settlement plates). The goal is to determine the extent of influence
of the abiotic variables on the species growth.

I was initially planning on carrying out partial least square regression,
but I have been unable to account for the repeated measures aspect of the
study. I have very limited R experience and have been unable to write script
to carry out an appropriate analysis with PLS, so have been primarily been
using SPSS and JMP.

I am now trying to use Linear Mixed Models. The issue here is that the data
are heavily negatively skewed, given the large number of zero percent cover
points, especially as every single site I worked at started as zero percent
cover. There is also a smaller peak on the positive side where there are a
reasonable number of 100% values. In SPSS -> Analyze -> Mixed Models ->
Linear I use the settlement collectors as the Subject and Months as the
Repeated Measure. Then I use % cover as the Dependent Variable, Site as the
Fixed Factor and the abiotic variables of interest as covariates. Fixed
effects of abiotic variables and a random effect of the intercept and the
subjects. I am not sure if this is appropriate given the non-normality of
those data.

Any suggestions of alternative methods or enhancements of the ones I have
mentioned would be greatly appreciated.

Thanks!



--
View this message in context: 
http://r.789695.n4.nabble.com/Best-method-of-analysis-for-negatively-skewed-longitudinal-environmental-data-tp4702212.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] sum of grouped elements of vector

2015-01-23 Thread Ivan Kasanický
Hi Kathryn,
another solution would be to use tapply function. So the code to
create new1 vector would be:

a <- 1:8
fc <- c('g1','g1','g2','g3','g3','g3','g4','g4') # definitions of
groups to sum over
tapply(a,fc,sum)

ivan


On Fri, Jan 23, 2015 at 10:32 AM, Bert Gunter  wrote:
> If Jim's answer is not what you want, then I would say it is because
> your question is too vague to be answered. In particular, how do you
> specify the elements of the vector that are to be summed to create the
> new vectors? ?tapply might then be relevant here, but that's just a
> guess.
>
> -- Bert
>
>
>
>
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
> (650) 467-7374
>
> "Data is not information. Information is not knowledge. And knowledge
> is certainly not wisdom."
> Clifford Stoll
>
>
>
>
> On Fri, Jan 23, 2015 at 12:45 AM, Kathryn Lord
>  wrote:
>> Dear R users,
>>
>> I have a quick quesiton.
>>
>> Here is a vector "a".
>>
>> a<- c(1,2,3,4,5,6,7,8).
>>
>> (In fact, I have a huge vector.)
>>
>>
>> With "a", I'd like to create new vectors, for example,
>>
>> new1 = (1+2, 3, 4+5+6, 7+8)
>> new2 = (1, 2+3+4+5+6+7, 8)
>> new3 = (1+2+3+4+5+6+7, 8)
>>
>>
>> How could I make the above vectors using R?
>>
>>
>> Any suggestion will be greatly appreciated.
>>
>> Best,
>>
>> Kathryn Lord
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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 -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] Testing for significant differences between groups in multiple linear regression

2015-01-23 Thread Janka Vanschoenwinkel
Dear R-colleagues,

I am looking for a way to test whether one regression has significant
different coefficients and overall results for 10 groups (grouping variable
is "irr").



*What I have*

The regression is:

Depend = temp + temp² + perc + perc² + conti è split up for multiple groups
of irr


  *Dataset = Alldata (real dataset has over 5 IDs)*

*ID*

*irr *

*(= grouping variable)*

*temp*

*perc*

*conti*

*Depend*

*w*

1

1

10

34

26

8

23

2

1

11

36

27

6

58

3

1

26

57

45

3

76

4

2

23

68

24

2

4

5

2

6

26

8

1

323

6

2

3

17

56

6

45

7

3

17

39

17

5

57



I can obtain the different regression coefficients for the different groups
with the following code (other codes are possible as wel).


datairrigation <- split(Alldata, Alldata$irr)

model.per.irrigation <- lapply(datairrigation, function (x) {

  lm(Depend~ temp + temp² + perc + perc² + conti,

 weights=w, data = x)

})


OR I can do it manually by splitting all the data in subsets (and then I
also receive the R²…)



*What I don’t have*

However, now I don’t know how to compare those regressions to test whether
they differ significantly over all the groups.

(Preferably, I would like to test the coefficients individually (temp(group
1) = temp(group2)) and the regression as a whole between the groups.)



*Note*

I know that one way to test differences in significance between groups, is
to use dummy variables of that group, in the regression. Yet, this is no
option for my model because it only allows exogenous variables in the
regression (and irrigation is an endogenous variable because the farmer can
decide himself if he irrigates or not).



Thank you very much in advance! I really appreciate your help!


Janka


P Please consider the environment before printing this e-mail

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] sum of grouped elements of vector

2015-01-23 Thread Chel Hee Lee
Here is some examples using functions 'tapply()' as suggested by Bert 
Gunter in the previous post, 'aggregate()', and 'xtabs()'.  Note that 
'grp.id' means 'group indicator'.


> a <- c(1,2,3,4,5,6,7,8)
> new1 <- c(1+2, 3, 4+5+6, 7+8)
> new1
[1]  3  3 15 15
>
> grp.id <- c(1,1, 2, 3,3,3, 4,4)
> tapply(X=a, INDEX=grp.id, FUN=sum)
 1  2  3  4
 3  3 15 15
> aggregate(x=a, by=list(grp.id), FUN=sum)
  Group.1  x
1   1  3
2   2  3
3   3 15
4   4 15
> xtabs(formula=a~grp.id)
grp.id
 1  2  3  4
 3  3 15 15
>
>

I hope this helps.

Chel Hee Lee

On 1/23/2015 3:32 AM, Bert Gunter wrote:

If Jim's answer is not what you want, then I would say it is because
your question is too vague to be answered. In particular, how do you
specify the elements of the vector that are to be summed to create the
new vectors? ?tapply might then be relevant here, but that's just a
guess.

-- Bert





Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
Clifford Stoll




On Fri, Jan 23, 2015 at 12:45 AM, Kathryn Lord
 wrote:

Dear R users,

I have a quick quesiton.

Here is a vector "a".

a<- c(1,2,3,4,5,6,7,8).

(In fact, I have a huge vector.)


With "a", I'd like to create new vectors, for example,

new1 = (1+2, 3, 4+5+6, 7+8)
new2 = (1, 2+3+4+5+6+7, 8)
new3 = (1+2+3+4+5+6+7, 8)


How could I make the above vectors using R?


Any suggestion will be greatly appreciated.

Best,

Kathryn Lord

 [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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] elegant way to remove cases with many different ids

2015-01-23 Thread Ivan Calandra

I did not know there was a warning about that!
I usually find it easier to use [ in scripts anyway.

--
Ivan Calandra, ATER
University of Reims Champagne-Ardenne
GEGENAA - EA 3795
CREA - 2 esplanade Roland Garros
51100 Reims, France
+33(0)3 26 77 36 89
ivan.calan...@univ-reims.fr
https://www.researchgate.net/profile/Ivan_Calandra

Le 23/01/15 11:59, Göran Broström a écrit :



On 2015-01-23 11:09, Ivan Calandra wrote:

Hi Alain,

I think you're looking for %in% (see ?'%in%' for the help page)

id.vector <- c(1,3)  ## here you define the values you want to select:
x, y, z...
subset(df, id %in% id.vector)



But note the Warning in

>?subset

Göran



HTH,
Ivan

--
Ivan Calandra, ATER
University of Reims Champagne-Ardenne
GEGENAA - EA 3795
CREA - 2 esplanade Roland Garros
51100 Reims, France
+33(0)3 26 77 36 89
ivan.calan...@univ-reims.fr
https://www.researchgate.net/profile/Ivan_Calandra

Le 23/01/15 10:50, D. Alain a écrit :

Dear R-List,

I have nested data with cases grouped by IDs and I want to remove 
all cases with specific IDs.


something like

df<-data.frame(id=c(1,1,1,2,2,2,3,3,3,4,4,4,5,5,5),var=c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)) 



subset(df,id== 1 | id == 3)

Having a very large dataset with many IDs to remove this solution 
leaves me to write quite a long list of "id == x | id == y | id == z 
...". I wonder if there is a more elegant way to do this? I tried 
with "id = c(x,y,z)" but this did not give the proper result.


Any suggestions? Thank you!

Best wishes

Alain






[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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] elegant way to remove cases with many different ids

2015-01-23 Thread Göran Broström



On 2015-01-23 11:09, Ivan Calandra wrote:

Hi Alain,

I think you're looking for %in% (see ?'%in%' for the help page)

id.vector <- c(1,3)  ## here you define the values you want to select:
x, y, z...
subset(df, id %in% id.vector)



But note the Warning in

>?subset

Göran



HTH,
Ivan

--
Ivan Calandra, ATER
University of Reims Champagne-Ardenne
GEGENAA - EA 3795
CREA - 2 esplanade Roland Garros
51100 Reims, France
+33(0)3 26 77 36 89
ivan.calan...@univ-reims.fr
https://www.researchgate.net/profile/Ivan_Calandra

Le 23/01/15 10:50, D. Alain a écrit :

Dear R-List,

I have nested data with cases grouped by IDs and I want to remove all cases 
with specific IDs.

something like

df<-data.frame(id=c(1,1,1,2,2,2,3,3,3,4,4,4,5,5,5),var=c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15))

subset(df,id== 1 | id == 3)

Having a very large dataset with many IDs to remove this solution leaves me to write quite a long 
list of "id == x | id == y | id == z ...". I wonder if there is a more elegant way to do 
this? I tried with "id = c(x,y,z)" but this did not give the proper result.

Any suggestions? Thank you!

Best wishes

Alain






[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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] elegant way to remove cases with many different ids

2015-01-23 Thread Ivan Calandra

Hi Alain,

I think you're looking for %in% (see ?'%in%' for the help page)

id.vector <- c(1,3)  ## here you define the values you want to select: 
x, y, z...

subset(df, id %in% id.vector)

HTH,
Ivan

--
Ivan Calandra, ATER
University of Reims Champagne-Ardenne
GEGENAA - EA 3795
CREA - 2 esplanade Roland Garros
51100 Reims, France
+33(0)3 26 77 36 89
ivan.calan...@univ-reims.fr
https://www.researchgate.net/profile/Ivan_Calandra

Le 23/01/15 10:50, D. Alain a écrit :

Dear R-List,

I have nested data with cases grouped by IDs and I want to remove all cases 
with specific IDs.

something like

df<-data.frame(id=c(1,1,1,2,2,2,3,3,3,4,4,4,5,5,5),var=c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15))

subset(df,id== 1 | id == 3)

Having a very large dataset with many IDs to remove this solution leaves me to write quite a long 
list of "id == x | id == y | id == z ...". I wonder if there is a more elegant way to do 
this? I tried with "id = c(x,y,z)" but this did not give the proper result.

Any suggestions? Thank you!

Best wishes

Alain


  
  



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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] elegant way to remove cases with many different ids

2015-01-23 Thread D. Alain
Dear R-List, 

I have nested data with cases grouped by IDs and I want to remove all cases 
with specific IDs. 

something like

df<-data.frame(id=c(1,1,1,2,2,2,3,3,3,4,4,4,5,5,5),var=c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15))

subset(df,id== 1 | id == 3)

Having a very large dataset with many IDs to remove this solution leaves me to 
write quite a long list of "id == x | id == y | id == z ...". I wonder if there 
is a more elegant way to do this? I tried with "id = c(x,y,z)" but this did not 
give the proper result.

Any suggestions? Thank you!

Best wishes

Alain 


 
 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] sum of grouped elements of vector

2015-01-23 Thread Bert Gunter
If Jim's answer is not what you want, then I would say it is because
your question is too vague to be answered. In particular, how do you
specify the elements of the vector that are to be summed to create the
new vectors? ?tapply might then be relevant here, but that's just a
guess.

-- Bert





Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
Clifford Stoll




On Fri, Jan 23, 2015 at 12:45 AM, Kathryn Lord
 wrote:
> Dear R users,
>
> I have a quick quesiton.
>
> Here is a vector "a".
>
> a<- c(1,2,3,4,5,6,7,8).
>
> (In fact, I have a huge vector.)
>
>
> With "a", I'd like to create new vectors, for example,
>
> new1 = (1+2, 3, 4+5+6, 7+8)
> new2 = (1, 2+3+4+5+6+7, 8)
> new3 = (1+2+3+4+5+6+7, 8)
>
>
> How could I make the above vectors using R?
>
>
> Any suggestion will be greatly appreciated.
>
> Best,
>
> Kathryn Lord
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] sum of grouped elements of vector

2015-01-23 Thread Jim Lemon
Hi Kathryn,
I think this might do the trick:

make_group_sums<-function(x,maxgroups) {
 lenx<-length(x)
 runlengths<-sample(1:lenx,1)
 for(i in 2:(maxgroups-1)) {
  lenx<-lenx-runlengths[i-1]
  runlengths[i]<-ifelse(lenx,sample(1:lenx,1),0)
 }
 runlengths[maxgroups]<-length(x)-sum(runlengths)
 groups<-rep(1:maxgroups,runlengths)
 groupsums<-by(x,groups,sum)
 return(as.vector(groupsums))
}

Jim


On Fri, Jan 23, 2015 at 7:45 PM, Kathryn Lord
 wrote:
> Dear R users,
>
> I have a quick quesiton.
>
> Here is a vector "a".
>
> a<- c(1,2,3,4,5,6,7,8).
>
> (In fact, I have a huge vector.)
>
>
> With "a", I'd like to create new vectors, for example,
>
> new1 = (1+2, 3, 4+5+6, 7+8)
> new2 = (1, 2+3+4+5+6+7, 8)
> new3 = (1+2+3+4+5+6+7, 8)
>
>
> How could I make the above vectors using R?
>
>
> Any suggestion will be greatly appreciated.
>
> Best,
>
> Kathryn Lord
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] sum of grouped elements of vector

2015-01-23 Thread Kathryn Lord
Dear R users,

I have a quick quesiton.

Here is a vector "a".

a<- c(1,2,3,4,5,6,7,8).

(In fact, I have a huge vector.)


With "a", I'd like to create new vectors, for example,

new1 = (1+2, 3, 4+5+6, 7+8)
new2 = (1, 2+3+4+5+6+7, 8)
new3 = (1+2+3+4+5+6+7, 8)


How could I make the above vectors using R?


Any suggestion will be greatly appreciated.

Best,

Kathryn Lord

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.