Re: [R] Newbie Question: Using R with PHP and MySQL

2007-08-24 Thread Ryan

 
 What's the best reference, if there is one,  for PHP, MySQL, R integration?
 


It is possible to integrate PHP, R and MySQL, but I don't have 
a good reference for you.

If all you need are a few simple charts, then I think it would be 
easiest for you to forget about R and use some other solution.  
One example is a flash-based solution: 
http://www.maani.us/charts/index.php, 
but there are many others out there.  There are examples on 
this site with code that make it pretty simple to adapt to your 
situation.

__
R-help@stat.math.ethz.ch 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] Newbie Question: Using R with PHP and MySQL

2007-08-24 Thread Eric Theise
On 8/22/07 1:31 PM, MASFERFC Team wrote:
 I'd like to
 (more or less) simultaneously return to the browser a couple of canned
 charts and graphs based on the data. Nothing fancy, two pie charts and two
 simple bar-charts to start. I need to generate these on-the-fly, based on
 the results of the MySQL query, and display them in the web-page, beside the
 table data.
 
 What's the best reference, if there is one,  for PHP, MySQL, R integration?

I'm quite new to R myself, and hope to read about your experiences 
further on down the road.

I thought I'd mention that we use PHP/SWF Charts in a similar 
environment for similar purposes, though I'm hoping to extend the 
complexity of what we report using R.

 http://maani.us/charts/index.php

Cheers, Eric

__
R-help@stat.math.ethz.ch 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] Newbie Question: Using R with PHP and MySQL

2007-08-23 Thread MASFERFC Team
First, I should admit that I didn't do a lot of searching beforehand, I'm
just cutting to the chase to ask the experts:

I'm currently running MySQL 5 queries with PHP 5.2.3 and returning results
to the end-user in web-page tables of ca. 50 rows by 5 columns. I'd like to
(more or less) simultaneously return to the browser a couple of canned
charts and graphs based on the data. Nothing fancy, two pie charts and two
simple bar-charts to start. I need to generate these on-the-fly, based on
the results of the MySQL query, and display them in the web-page, beside the
table data.

What's the best reference, if there is one,  for PHP, MySQL, R integration?

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] Newbie Question: Using R with PHP and MySQL

2007-08-23 Thread Dieter Menne
MASFERFC Team masferfc at gmail.com writes:

 I'm currently running MySQL 5 queries with PHP 5.2.3 and returning results
 to the end-user in web-page tables of ca. 50 rows by 5 columns. I'd like to
 (more or less) simultaneously return to the browser a couple of canned
 charts and graphs based on the data. Nothing fancy, two pie charts and two
 simple bar-charts to start. I need to generate these on-the-fly, based on
 the results of the MySQL query, and display them in the web-page, beside the
 table data.
 
 What's the best reference, if there is one,  for PHP, MySQL, R integration?

It's not the best, but it's simple, works for all our sites and comes with a
sample: package phpSerialize. Graphs are should be written to a file as png and
linked via standard HTML.

Dieter

__
R-help@stat.math.ethz.ch 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] Newbie question: Statistical functions (e.g., mean, sd) in a transform statement?

2007-01-19 Thread Ben Fairbank
Greetings listeRs - 

 

Given a data frame such as 

 

times

   time1time2 time3time4

1  70.408543 48.92378  7.399605 95.93050

2  17.231940 27.48530 82.962916 10.20619

3  20.279220 10.33575 66.209290 30.71846

4 NA 53.31993 12.398237 35.65782

5   9.295965   NA 48.929201   NA

6  63.966518 42.16304  1.777342   NA

 

one can use transform to total all or some columns, thus,

 

times2 - transform(times,totaltime=time1+time2+time3+time4)

 

 times2

   time1time2 time3time4 totaltime

1  70.408543 48.92378  7.399605 95.93050  222.6624

2  17.231940 27.48530 82.962916 10.20619  137.8863

3  20.279220 10.33575 66.209290 30.71846  127.5427

4 NA 53.31993 12.398237 35.65782NA

5   9.295965   NA 48.929201   NANA

6  63.966518 42.16304  1.777342   NANA

 

I cannot, however, find a way, other than for looping,

to use statistical functions, such as mean or sd, to 

compute the new column.  For example,

 


times2-transform(times,meantime=(mean(c(time1,time2,time3,time4),na.rm=
TRUE)))

 

 times2

 

 time1time2 time3time4 meantime

1  70.408543 48.92378  7.399605 95.93050 45.54178

2  17.231940 27.48530 82.962916 10.20619 45.54178

3  20.279220 10.33575 66.209290 30.71846 45.54178

4 NA 53.31993 12.398237 35.65782 45.54178

5   9.295965   NA 48.929201   NA 45.54178

6  63.966518 42.16304  1.777342   NA 45.54178

 

How can this be done?  And, generally, what is the recommended method 

for creating computed new columns in data frames when for loops take 

too long?

 

With thanks for any suggestions,

 

Ben Fairbank

 

Using version 2.4.1 on a Windows XP professional operating system.

 


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] Newbie question: Statistical functions (e.g., mean, sd) in a transform statement?

2007-01-19 Thread Michael Kubovy

On Jan 19, 2007, at 12:54 PM, Ben Fairbank wrote:

 Given a data frame such as

 times

time1time2 time3time4
 1  70.408543 48.92378  7.399605 95.93050
 2  17.231940 27.48530 82.962916 10.20619
 3  20.279220 10.33575 66.209290 30.71846
 4 NA 53.31993 12.398237 35.65782
 5   9.295965   NA 48.929201   NA
 6  63.966518 42.16304  1.777342   NA

 I cannot, however, find a way, other than for looping,
 to use statistical functions, such as mean or sd, to
 compute the new column.

times - data.frame(time1 = rnorm(6, 50, 20), time2 = rnorm(6, 40, 15),
 time3 = rnorm(6, 60, 25), time4 = rnorm(6, 55, 23))
times[4,1] - NA
times[5, c(2, 4)] - NA
times[6, 4] - NA
times$totaltime - apply(times, 1, sum, na.rm = T)
times$meantime - apply(times, 1, mean, na.rm = T)
times$sdtime - apply(times, 1, sd, na.rm = T)

  time1time2time3time4 totaltime meantime   sdtime
1 28.84859 29.94037 92.11518 71.80472 222.70886 89.08354 71.11911
2 50.72260 39.02439 61.18364 31.63962 182.57024 73.02810 55.68944
3 11.75829 28.61262 72.37066 79.23817 191.97974 76.79189 62.99902
4   NA 27.23659 75.69952 38.19262 141.12872 70.56436 44.52787
5 31.05109   NA 52.41755   NA  83.46864 55.64576 21.52078
6 54.01291 52.48922 53.97689   NA 160.47902 80.23951 46.33038



_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/



[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] Newbie question: Statistical functions (e.g., mean, sd) in a transform statement?

2007-01-19 Thread Gabor Grothendieck
Try this using the builtin data set anscombe:

transform(anscombe, rowMeans = rowMeans(anscombe))

On 1/19/07, Ben Fairbank [EMAIL PROTECTED] wrote:
 Greetings listeRs -



 Given a data frame such as



 times

   time1time2 time3time4

 1  70.408543 48.92378  7.399605 95.93050

 2  17.231940 27.48530 82.962916 10.20619

 3  20.279220 10.33575 66.209290 30.71846

 4 NA 53.31993 12.398237 35.65782

 5   9.295965   NA 48.929201   NA

 6  63.966518 42.16304  1.777342   NA



 one can use transform to total all or some columns, thus,



 times2 - transform(times,totaltime=time1+time2+time3+time4)



  times2

   time1time2 time3time4 totaltime

 1  70.408543 48.92378  7.399605 95.93050  222.6624

 2  17.231940 27.48530 82.962916 10.20619  137.8863

 3  20.279220 10.33575 66.209290 30.71846  127.5427

 4 NA 53.31993 12.398237 35.65782NA

 5   9.295965   NA 48.929201   NANA

 6  63.966518 42.16304  1.777342   NANA



 I cannot, however, find a way, other than for looping,

 to use statistical functions, such as mean or sd, to

 compute the new column.  For example,



 
 times2-transform(times,meantime=(mean(c(time1,time2,time3,time4),na.rm=
 TRUE)))



  times2



  time1time2 time3time4 meantime

 1  70.408543 48.92378  7.399605 95.93050 45.54178

 2  17.231940 27.48530 82.962916 10.20619 45.54178

 3  20.279220 10.33575 66.209290 30.71846 45.54178

 4 NA 53.31993 12.398237 35.65782 45.54178

 5   9.295965   NA 48.929201   NA 45.54178

 6  63.966518 42.16304  1.777342   NA 45.54178



 How can this be done?  And, generally, what is the recommended method

 for creating computed new columns in data frames when for loops take

 too long?



 With thanks for any suggestions,



 Ben Fairbank



 Using version 2.4.1 on a Windows XP professional operating system.




[[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] Newbie question: Statistical functions (e.g., mean, sd) in a transform statement?

2007-01-19 Thread Charles C. Berry

Ben,

transform() is probably the wrong tool if what you want is to

'apply a function'

to the corresponding elements of time1, time2, ... , and return a vector 
of results.

If this is what you are after, the 'apply' family of functions is what you 
want.

See

?apply

and

?mapply

and the 'See Also's on each page.

Chuck Berry

On Fri, 19 Jan 2007, Ben Fairbank wrote:

 Greetings listeRs -



 Given a data frame such as



 times

   time1time2 time3time4

 1  70.408543 48.92378  7.399605 95.93050

 2  17.231940 27.48530 82.962916 10.20619

 3  20.279220 10.33575 66.209290 30.71846

 4 NA 53.31993 12.398237 35.65782

 5   9.295965   NA 48.929201   NA

 6  63.966518 42.16304  1.777342   NA



 one can use transform to total all or some columns, thus,



 times2 - transform(times,totaltime=time1+time2+time3+time4)



 times2

   time1time2 time3time4 totaltime

 1  70.408543 48.92378  7.399605 95.93050  222.6624

 2  17.231940 27.48530 82.962916 10.20619  137.8863

 3  20.279220 10.33575 66.209290 30.71846  127.5427

 4 NA 53.31993 12.398237 35.65782NA

 5   9.295965   NA 48.929201   NANA

 6  63.966518 42.16304  1.777342   NANA



 I cannot, however, find a way, other than for looping,

 to use statistical functions, such as mean or sd, to

 compute the new column.  For example,




 times2-transform(times,meantime=(mean(c(time1,time2,time3,time4),na.rm=
 TRUE)))



 times2



 time1time2 time3time4 meantime

 1  70.408543 48.92378  7.399605 95.93050 45.54178

 2  17.231940 27.48530 82.962916 10.20619 45.54178

 3  20.279220 10.33575 66.209290 30.71846 45.54178

 4 NA 53.31993 12.398237 35.65782 45.54178

 5   9.295965   NA 48.929201   NA 45.54178

 6  63.966518 42.16304  1.777342   NA 45.54178



 How can this be done?  And, generally, what is the recommended method

 for creating computed new columns in data frames when for loops take

 too long?



 With thanks for any suggestions,



 Ben Fairbank



 Using version 2.4.1 on a Windows XP professional operating system.




   [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch 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.


Charles C. Berry(858) 534-2098
  Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]   UC San Diego
http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0901

__
R-help@stat.math.ethz.ch 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] Newbie question: Statistical functions (e.g., mean, sd) in a transform statement?

2007-01-19 Thread Gavin Simpson
On Fri, 2007-01-19 at 11:54 -0600, Ben Fairbank wrote:
 Greetings listeRs - 

Here are two solutions, depending on whether you wanted the NA's or not,
and I assume you wanted the row means:

 times3 - transform(times, meantime = rowMeans(times))
 times3
  time1time2 time3time4 meantime
1 70.408543 48.92378  7.399605 95.93050 55.66561
2 17.231940 27.48530 82.962916 10.20619 34.47159
3 20.279220 10.33575 66.209290 30.71846 31.88568
4NA 53.31993 12.398237 35.65782   NA
5  9.295965   NA 48.929201   NA   NA
6 63.966518 42.16304  1.777342   NA   NA
 times4 - transform(times, meantime = rowMeans(times, na.rm = TRUE))
 times4
  time1time2 time3time4 meantime
1 70.408543 48.92378  7.399605 95.93050 55.66561
2 17.231940 27.48530 82.962916 10.20619 34.47159
3 20.279220 10.33575 66.209290 30.71846 31.88568
4NA 53.31993 12.398237 35.65782 33.79200
5  9.295965   NA 48.929201   NA 29.11258
6 63.966518 42.16304  1.777342   NA 35.96897

HTH

G

 
 Given a data frame such as 
 
  
 
 times
 
time1time2 time3time4
 
 1  70.408543 48.92378  7.399605 95.93050
 
 2  17.231940 27.48530 82.962916 10.20619
 
 3  20.279220 10.33575 66.209290 30.71846
 
 4 NA 53.31993 12.398237 35.65782
 
 5   9.295965   NA 48.929201   NA
 
 6  63.966518 42.16304  1.777342   NA
 
  
 
 one can use transform to total all or some columns, thus,
 
  
 
 times2 - transform(times,totaltime=time1+time2+time3+time4)
 
  
 
  times2
 
time1time2 time3time4 totaltime
 
 1  70.408543 48.92378  7.399605 95.93050  222.6624
 
 2  17.231940 27.48530 82.962916 10.20619  137.8863
 
 3  20.279220 10.33575 66.209290 30.71846  127.5427
 
 4 NA 53.31993 12.398237 35.65782NA
 
 5   9.295965   NA 48.929201   NANA
 
 6  63.966518 42.16304  1.777342   NANA
 
  
 
 I cannot, however, find a way, other than for looping,
 
 to use statistical functions, such as mean or sd, to 
 
 compute the new column.  For example,
 
  
 
 
 times2-transform(times,meantime=(mean(c(time1,time2,time3,time4),na.rm=
 TRUE)))
 
  
 
  times2
 
  
 
  time1time2 time3time4 meantime
 
 1  70.408543 48.92378  7.399605 95.93050 45.54178
 
 2  17.231940 27.48530 82.962916 10.20619 45.54178
 
 3  20.279220 10.33575 66.209290 30.71846 45.54178
 
 4 NA 53.31993 12.398237 35.65782 45.54178
 
 5   9.295965   NA 48.929201   NA 45.54178
 
 6  63.966518 42.16304  1.777342   NA 45.54178
 
  
 
 How can this be done?  And, generally, what is the recommended method 
 
 for creating computed new columns in data frames when for loops take 
 
 too long?
 
  
 
 With thanks for any suggestions,
 
  
 
 Ben Fairbank
 
  
 
 Using version 2.4.1 on a Windows XP professional operating system.
 
  
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch 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.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@stat.math.ethz.ch 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] Newbie question about saving results

2007-01-13 Thread David Kaplan
Hi all,

When I run a procedure and the results are printed to the console, is 
there a way to just save the results?  When I save to file, it also 
saves the syntax of the procedure.  Thanks in advance,

David


-- 
===
David Kaplan, Ph.D.
Professor
Department of Educational Psychology
University of Wisconsin - Madison
Educational Sciences, Room 1061
1025 W. Johnson Street
Madison, WI 53706

email: [EMAIL PROTECTED]
Web:   http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm
Phone: 608-262-0836
Fax:   608-262-0843

__
R-help@stat.math.ethz.ch 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] Newbie question about saving results

2007-01-13 Thread Duncan Murdoch
On 1/14/2007 12:17 AM, David Kaplan wrote:
 Hi all,
 
 When I run a procedure and the results are printed to the console, is 
 there a way to just save the results?  When I save to file, it also 
 saves the syntax of the procedure.  Thanks in advance,

You can redirect results to a file, using the sink() function, e.g.

sink(results.txt)
1+1

will print the answer in the file.  Use sink() to redirect output back 
to the console.

Duncan Murdoch

__
R-help@stat.math.ethz.ch 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] newbie question

2006-10-21 Thread Larry White
Sorry - this must be obvious, but i haven't been able to find the
answer in the guides i've searched.  The examples seem to assume you
always want to look at all the data.

I want to be able to filter data in a dataframe before analyzing it.
For example, I'd like to plot(a,b) but only include values where b 
1000.

I'd also like to be able to do similar filtering before doing other
statistical functions.

Thanks for your help.

__
R-help@stat.math.ethz.ch 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] newbie question

2006-10-21 Thread Paul Hiemstra
Dear Larry,

Data can be filtered in the following manner:

a = c(1,2,3,4)
b = c(1,2,3,4)
b = b[a3]
b = b[b3]
a
b
[1] 4

Or if the data is in a data frame:

b = data.frame(seq(1:10),seq(1:10)
names(b) = c(a,b)
b
b = b[b$a  5,]
b

The trailing comma at the end is important.

Hopes this helps,

Paul





Larry White schreef:
 Sorry - this must be obvious, but i haven't been able to find the
 answer in the guides i've searched.  The examples seem to assume you
 always want to look at all the data.

 I want to be able to filter data in a dataframe before analyzing it.
 For example, I'd like to plot(a,b) but only include values where b 
 1000.

 I'd also like to be able to do similar filtering before doing other
 statistical functions.

 Thanks for your help.

 __
 R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] newbie question

2006-10-21 Thread Chuck Cleland
Larry White wrote:
 Sorry - this must be obvious, but i haven't been able to find the
 answer in the guides i've searched.  The examples seem to assume you
 always want to look at all the data.
 
 I want to be able to filter data in a dataframe before analyzing it.
 For example, I'd like to plot(a,b) but only include values where b 
 1000.
 
 I'd also like to be able to do similar filtering before doing other
 statistical functions.

  In addition to what Paul Hiemstra mentioned, you should look at the
help page for subset().  For example:

df - data.frame(a = runif(20), b = 1:20)
plot(a ~ b, data = subset(df, b  5))

 Thanks for your help.
 
 __
 R-help@stat.math.ethz.ch 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.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
R-help@stat.math.ethz.ch 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] newbie question

2006-10-21 Thread Alberto Vieira Ferreira Monteiro
Larry White wrote:

 Sorry - this must be obvious,

Yes, it is :-)

 I want to be able to filter data in a dataframe before analyzing it.
 For example, I'd like to plot(a,b) but only include values where b 
 1000.

If a and b are vectors, then b  1000 is another vector of logical
values.

You can use logical vectors to select pieces of other vectors, like
this:

x - c(1, 2, 3)
y - c(TRUE, FALSE, FALSE)
x[y]
# returns only the first element, 1

So, this plot can be done this way:

filter - (b  1000) # filter is a logical vector
a1 - a[filter]
b1 - b[filter]
# Now, a1 and b1 are, resp, a and b filtered
plot(a1, b1)

Alberto Monteiro

__
R-help@stat.math.ethz.ch 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] newbie question about index

2006-09-04 Thread sun
Thanks for all these replies, all work perfectly.

Sun
--- Petr Pikal [EMAIL PROTECTED]写道:

 Hallo
 
 probably there are other options but
 
 outer(1:3,a, ==)*1
 
 can do what you want.
 
 HTH
 Petr
 
 
 
 On 31 Aug 2006 at 22:41, z s wrote:
 
 Date sent:Thu, 31 Aug 2006 22:41:27 +0800
 (CST)
 From: z s [EMAIL PROTECTED]
 To:   r-help@stat.math.ethz.ch
 Subject:  [R] newbie question about index
 
  Hi,
 
I am trying to convert a variable a =
 sample(1:3,100,rep = T)
represents choices into a 3X100 dummy varible b
 with corresponding
element set to 1 otherwise 0.
  eg.
 
  a: 1 3 2 1 2 3 1 1
 
  b: 1 0 0 1 0 0 1 1..
  0 0 1 0 1 0 0 0...
  0 1 0 0 0 1 0 0...
 
   Is there something like b[a] =1 existing? I could
 not figure this out
   myself.
 
 
  -
   Mp3�杩袼�-新歌热歌高速下
   [[alternative HTML version deleted]]
 
 
 
 Petr Pikal
 [EMAIL PROTECTED]
 
 




___ 
抢注雅虎免费邮箱-3.5G容量,20M附件!

__
R-help@stat.math.ethz.ch 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] newbie question about index

2006-09-01 Thread z s
Hi,

  I am trying to convert a variable a = sample(1:3,100,rep = T) represents 
choices into a 3X100 dummy varible b with corresponding element set to 1 
otherwise 0.
eg.

a: 1 3 2 1 2 3 1 1

b: 1 0 0 1 0 0 1 1..
0 0 1 0 1 0 0 0...
0 1 0 0 0 1 0 0...

 Is there something like b[a] =1 existing? I could not figure this out myself.


-
 Mp3·è¿ñËÑ-иèÈȸè¸ßËÙÏ   
[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] newbie question about index

2006-09-01 Thread Jacques VESLOT
(a==1)*1
or ifelse(a == 1, 1, 0)
---
Jacques VESLOT

CNRS UMR 8090
I.B.L (2ème étage)
1 rue du Professeur Calmette
B.P. 245
59019 Lille Cedex

Tel : 33 (0)3.20.87.10.44
Fax : 33 (0)3.20.87.10.31

http://www-good.ibl.fr
---


z s a écrit :
 Hi,
 
   I am trying to convert a variable a = sample(1:3,100,rep = T) represents 
 choices into a 3X100 dummy varible b with corresponding element set to 1 
 otherwise 0.
 eg.
 
 a: 1 3 2 1 2 3 1 1
 
 b: 1 0 0 1 0 0 1 1..
 0 0 1 0 1 0 0 0...
 0 1 0 0 0 1 0 0...
 
  Is there something like b[a] =1 existing? I could not figure this out myself.
 
   
 -
  Mp3·è¿ñËÑ-иèÈȸè¸ßËÙÏ   
   [[alternative HTML version deleted]]
 
 
 
 
 
 __
 R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] newbie question about index

2006-09-01 Thread Gabor Grothendieck

Try using outer:

outer(1:3, a, ==)+0




On 8/31/06, z s [EMAIL PROTECTED] wrote:

Hi,

 I am trying to convert a variable a = sample(1:3,100,rep = T) represents 
choices into a 3X100 dummy varible b with corresponding element set to 1 
otherwise 0.
eg.

a: 1 3 2 1 2 3 1 1

b: 1 0 0 1 0 0 1 1..
   0 0 1 0 1 0 0 0...
   0 1 0 0 0 1 0 0...

 Is there something like b[a] =1 existing? I could not figure this out myself.


-
 Mp3疯狂搜-新歌热歌高速下
   [[alternative HTML version deleted]]



__
R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] newbie question about index

2006-09-01 Thread Gabor Grothendieck

Here is an additional way:

model.matrix(~ factor(a) - 1)


On 9/1/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:

Try using outer:

outer(1:3, a, ==)+0




On 8/31/06, z s [EMAIL PROTECTED] wrote:
 Hi,

  I am trying to convert a variable a = sample(1:3,100,rep = T) represents 
choices into a 3X100 dummy varible b with corresponding element set to 1 otherwise 
0.
 eg.

 a: 1 3 2 1 2 3 1 1

 b: 1 0 0 1 0 0 1 1..
0 0 1 0 1 0 0 0...
0 1 0 0 0 1 0 0...

  Is there something like b[a] =1 existing? I could not figure this out myself.


 -
  Mp3疯狂搜-新歌热歌高速下
[[alternative HTML version deleted]]



 __
 R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] newbie question about index

2006-09-01 Thread Joris De Wolf
what about:
b - rbind(1*(a==1),1*(a==2),1*(a==3))


z s wrote:
 Hi,
 
   I am trying to convert a variable a = sample(1:3,100,rep = T) represents 
 choices into a 3X100 dummy varible b with corresponding element set to 1 
 otherwise 0.
 eg.
 
 a: 1 3 2 1 2 3 1 1
 
 b: 1 0 0 1 0 0 1 1..
 0 0 1 0 1 0 0 0...
 0 1 0 0 0 1 0 0...
 
  Is there something like b[a] =1 existing? I could not figure this out myself.
 
   
 -
  Mp3·è¿ñËÑ-иèÈȸè¸ßËÙÏ   
   [[alternative HTML version deleted]]
 
 
 
 
 
 __
 R-help@stat.math.ethz.ch 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.


confidentiality notice:
The information contained in this e-mail is confidential and...{{dropped}}

__
R-help@stat.math.ethz.ch 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] newbie question about index

2006-09-01 Thread Petr Pikal
Hallo

probably there are other options but

outer(1:3,a, ==)*1

can do what you want.

HTH
Petr



On 31 Aug 2006 at 22:41, z s wrote:

Date sent:  Thu, 31 Aug 2006 22:41:27 +0800 (CST)
From:   z s [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Subject:[R] newbie question about index

 Hi,
 
   I am trying to convert a variable a = sample(1:3,100,rep = T)
   represents choices into a 3X100 dummy varible b with corresponding
   element set to 1 otherwise 0.
 eg.
 
 a: 1 3 2 1 2 3 1 1
 
 b: 1 0 0 1 0 0 1 1..
 0 0 1 0 1 0 0 0...
 0 1 0 0 0 1 0 0...
 
  Is there something like b[a] =1 existing? I could not figure this out
  myself.
 
 
 -
  Mp3˙čżńËŃ-иčČȸč¸ßËŮĎ   
  [[alternative HTML version deleted]]
 
 

Petr Pikal
[EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch 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] newbie question: ROW average

2006-05-29 Thread A Ezhil
Hi,

I am new to R programming. I have a 992 x 74 matrix. I
would like to form a new matrix by averging each 4
rows
from the original one. How can I use 'apply' instead
of usual mean inside the nested for loop?

Thanks in advance. 

regards,
ezhil

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question: ROW average

2006-05-29 Thread Dimitris Rizopoulos
look at ?rowMeans; you can also use apply(mat, 1, mean) but 
rowMeans() is better.

Best,
Dimitris


Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://www.med.kuleuven.be/biostat/
 http://www.student.kuleuven.be/~m0390867/dimitris.htm


- Original Message - 
From: A Ezhil [EMAIL PROTECTED]
To: r-help r-help@stat.math.ethz.ch
Sent: Monday, May 29, 2006 1:24 PM
Subject: [R] newbie question: ROW average


 Hi,

 I am new to R programming. I have a 992 x 74 matrix. I
 would like to form a new matrix by averging each 4
 rows
 from the original one. How can I use 'apply' instead
 of usual mean inside the nested for loop?

 Thanks in advance.

 regards,
 ezhil

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question: ROW average

2006-05-29 Thread Peter Dalgaard
A Ezhil [EMAIL PROTECTED] writes:

 Hi,
 
 I am new to R programming. I have a 992 x 74 matrix. I
 would like to form a new matrix by averging each 4
 rows
 from the original one. How can I use 'apply' instead
 of usual mean inside the nested for loop?

How about 

dim(M) - c(4,248,74)
mn - apply(M, c(2,3), mean)
 
(Yes, this is a bit confusing and easy to get wrong...)

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question: ROW average

2006-05-29 Thread Rolf Turner
Peter Dalgaard wrote:

 How about 
 
 dim(M) - c(4,248,74)
 mn - apply(M, c(2,3), mean)

Hey!  That's sexy!  Much better than my kludgy
suggestion!

cheers,

Rolf

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question: ROW average

2006-05-29 Thread Rolf Turner
Dimitris Rizopoulos wrote:

 look at ?rowMeans; you can also use apply(mat, 1, mean) but 
 rowMeans() is better.

By my reading of the question, this is not what
Ezhil wants.  He said:

``I have a 992 x 74 matrix. I would like to form a new matrix
  by averaging each 4 rows from the original one.''

I.e. he wants (I think) the first row of the new matrix
to be the mean of the first 4 rows of the old one, the
second row of the new matrix to be the mean of rows 5
through 8 of the old one, and so on.

One way this could be done is via

 m.new - t(apply(array(t(m.old),dim=c(74,4,992/4)),c(1,3),mean))

cheers,

Rolf Turner
[EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question: ROW average

2006-05-29 Thread Dimitris Rizopoulos
yes you're right; it was my mistake.

Best,
Dimitris


Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
 http://www.student.kuleuven.be/~m0390867/dimitris.htm


- Original Message - 
From: Rolf Turner [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Sent: Monday, May 29, 2006 1:55 PM
Subject: Re: [R] newbie question: ROW average


 Dimitris Rizopoulos wrote:
 
 look at ?rowMeans; you can also use apply(mat, 1, mean) but 
 rowMeans() is better.
 
 By my reading of the question, this is not what
 Ezhil wants.  He said:
 
 ``I have a 992 x 74 matrix. I would like to form a new matrix
   by averaging each 4 rows from the original one.''
 
 I.e. he wants (I think) the first row of the new matrix
 to be the mean of the first 4 rows of the old one, the
 second row of the new matrix to be the mean of rows 5
 through 8 of the old one, and so on.
 
 One way this could be done is via
 
  m.new - t(apply(array(t(m.old),dim=c(74,4,992/4)),c(1,3),mean))
 
 cheers,
 
 Rolf Turner
 [EMAIL PROTECTED]


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question: ROW average

2006-05-29 Thread Gabor Grothendieck
Try this:

   rowsum(mat, gl(nrow(mat)/4, 4)) / 4

On 5/29/06, A Ezhil [EMAIL PROTECTED] wrote:
 Hi,

 I am new to R programming. I have a 992 x 74 matrix. I
 would like to form a new matrix by averging each 4
 rows
 from the original one. How can I use 'apply' instead
 of usual mean inside the nested for loop?

 Thanks in advance.

 regards,
 ezhil

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question: ROW average

2006-05-29 Thread A Ezhil
Hi,

Thank you all (Dimitris, Peter, Rolf, Gabor) for your
suggestions. I tried with all your suggestions. I am
getting different answers when I use:

rowsum(mat, gl(nrow(mat)/4, 4)) / 4 

and 

m.new -
t(apply(array(t(m.old),dim=c(74,4,992/4)),c(1,3),mean))

When I tried with (assuming 'M' is my old matrix): 

dim(M) - c(4,248,74)
mn - apply(M, c(2,3), mean)

the following error occured:
Error: dim- : dims [product 73408] do not match the
length of object [74]

When I manually checked the answers, it seems that 
rowsum(mat, gl(nrow(mat)/4, 4)) / 4 gives me the
correct answer. 

Thanks again for your time  suggestions.

Regards,
Ezhil




--- Dimitris Rizopoulos
[EMAIL PROTECTED] wrote:

 yes you're right; it was my mistake.
 
 Best,
 Dimitris
 
 
 Dimitris Rizopoulos
 Ph.D. Student
 Biostatistical Centre
 School of Public Health
 Catholic University of Leuven
 
 Address: Kapucijnenvoer 35, Leuven, Belgium
 Tel: +32/(0)16/336899
 Fax: +32/(0)16/337015
 Web: http://med.kuleuven.be/biostat/
 

http://www.student.kuleuven.be/~m0390867/dimitris.htm
 
 
 - Original Message - 
 From: Rolf Turner [EMAIL PROTECTED]
 To: [EMAIL PROTECTED];
 [EMAIL PROTECTED]
 Cc: r-help@stat.math.ethz.ch
 Sent: Monday, May 29, 2006 1:55 PM
 Subject: Re: [R] newbie question: ROW average
 
 
  Dimitris Rizopoulos wrote:
  
  look at ?rowMeans; you can also use apply(mat,
 1, mean) but 
  rowMeans() is better.
  
  By my reading of the question, this is not what
  Ezhil wants.  He said:
  
  ``I have a 992 x 74 matrix. I would like to form a
 new matrix
by averaging each 4 rows from the original
 one.''
  
  I.e. he wants (I think) the first row of the new
 matrix
  to be the mean of the first 4 rows of the old one,
 the
  second row of the new matrix to be the mean of
 rows 5
  through 8 of the old one, and so on.
  
  One way this could be done is via
  
   m.new -

t(apply(array(t(m.old),dim=c(74,4,992/4)),c(1,3),mean))
  
  cheers,
  
  Rolf Turner
  [EMAIL PROTECTED]
 
 
 Disclaimer:
 http://www.kuleuven.be/cwis/email_disclaimer.htm
 


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question: ROW average

2006-05-29 Thread Peter Dalgaard
A Ezhil [EMAIL PROTECTED] writes:

 When I tried with (assuming 'M' is my old matrix): 
 
 dim(M) - c(4,248,74)
 mn - apply(M, c(2,3), mean)
 
 the following error occured:
 Error: dim- : dims [product 73408] do not match the
 length of object [74]

In that case, M clearly wasn't a 992x74 matrix!

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Newbie question about read.table

2006-05-11 Thread David Kaplan
Hi

When I use the read.table function with header = T, I notice that it gives me 
the variable names along the top as I expect.  But, when I then attempt an 
analysis, e.g. regression, it doesn't recognize the variable names.  Am I 
missing a step.  

Thank you

David


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question about read.table

2006-05-11 Thread Steve Miller
Are you prefixing the variable names with the data.frame name, i.e.
mydf$col2, or referencing by index mydf[,2]?

Steve Miller

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of David Kaplan
Sent: Thursday, May 11, 2006 12:39 PM
To: r-help@stat.math.ethz.ch
Subject: [R] Newbie question about read.table

Hi

When I use the read.table function with header = T, I notice that it gives
me the variable names along the top as I expect.  But, when I then attempt
an analysis, e.g. regression, it doesn't recognize the variable names.  Am I
missing a step.  

Thank you

David


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question about read.table

2006-05-11 Thread Chuck Cleland
David Kaplan wrote:
 Hi
 
 When I use the read.table function with header = T, I notice that it gives me 
 the variable names along the top as I expect.  But, when I then attempt an 
 analysis, e.g. regression, it doesn't recognize the variable names.  Am I 
 missing a step.  
 
 Thank you
 
 David

   Are you assigning the result of read.table() to a data frame.  And 
then do you refer to that data frame in your call to lm()?  If that does 
not solve the problem, you may want to show us the code you are using.

Chuck

   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question about read.table

2006-05-11 Thread David Kaplan
Here is what I'm doing

 birthweight - read.table(c:/bw.dat, header = T)
 summary(glm(low~age,binomial))
Error in eval(expr, envir, enclos) : object low not found



Thanks all!


- Original Message - 
From: Chuck Cleland [EMAIL PROTECTED]
To: David Kaplan [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Sent: Thursday, May 11, 2006 1:53 PM
Subject: Re: [R] Newbie question about read.table


 David Kaplan wrote:
 Hi

 When I use the read.table function with header = T, I notice that it 
 gives me the variable names along the top as I expect.  But, when I then 
 attempt an analysis, e.g. regression, it doesn't recognize the variable 
 names.  Am I missing a step.  Thank you

 David

   Are you assigning the result of read.table() to a data frame.  And then 
 do you refer to that data frame in your call to lm()?  If that does not 
 solve the problem, you may want to show us the code you are using.

 Chuck

 [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html


 -- 
 Chuck Cleland, Ph.D.
 NDRI, Inc.
 71 West 23rd Street, 8th floor
 New York, NY 10010
 tel: (212) 845-4495 (Tu, Th)
 tel: (732) 512-0171 (M, W, F)
 fax: (917) 438-0894


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question about read.table

2006-05-11 Thread Chuck Cleland
David Kaplan wrote:
 Here is what I'm doing
 
 birthweight - read.table(c:/bw.dat, header = T)
 summary(glm(low~age,binomial))
 Error in eval(expr, envir, enclos) : object low not found


Try this:

birthweight - read.table(c:/bw.dat, header = TRUE)
summary(glm(low ~ age, family=binomial, data=birthweight))

 Thanks all!
 
 
 - Original Message - From: Chuck Cleland [EMAIL PROTECTED]
 To: David Kaplan [EMAIL PROTECTED]
 Cc: r-help@stat.math.ethz.ch
 Sent: Thursday, May 11, 2006 1:53 PM
 Subject: Re: [R] Newbie question about read.table
 
 
 David Kaplan wrote:
 Hi

 When I use the read.table function with header = T, I notice that it 
 gives me the variable names along the top as I expect.  But, when I 
 then attempt an analysis, e.g. regression, it doesn't recognize the 
 variable names.  Am I missing a step.  Thank you

 David

   Are you assigning the result of read.table() to a data frame.  And 
 then do you refer to that data frame in your call to lm()?  If that 
 does not solve the problem, you may want to show us the code you are 
 using.

 Chuck

 [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html


 -- 
 Chuck Cleland, Ph.D.
 NDRI, Inc.
 71 West 23rd Street, 8th floor
 New York, NY 10010
 tel: (212) 845-4495 (Tu, Th)
 tel: (732) 512-0171 (M, W, F)
 fax: (917) 438-0894

 
 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question about read.table

2006-05-11 Thread Sean O'Riordain
Hi David,

you might need to either:
a) attach(birthweight)
or
b) glm(low~age,binomial, data=birthweight)

refer ?attach / ?glm

cheers,
Sean

On 11/05/06, David Kaplan [EMAIL PROTECTED] wrote:
 Here is the code with the error

  birthweight - read.table(c:/bw.dat, header = T)
  summary(glm(low~age,binomial))
 Error in eval(expr, envir, enclos) : object low not found
 


 The read.table function works fine and when look at the data it shows the
 variable names across the top.  The data come from SPSS which I read out
 into a .dat file.

 Thanks


 - Original Message -
 From: Sean O'Riordain [EMAIL PROTECTED]
 To: David Kaplan [EMAIL PROTECTED]
 Sent: Thursday, May 11, 2006 1:46 PM
 Subject: Re: [R] Newbie question about read.table


 Hi David,
 Can you show us the code that you're trying to use?
 cheers,
 Sean

 On 11/05/06, David Kaplan [EMAIL PROTECTED] wrote:
  Hi
 
  When I use the read.table function with header = T, I notice that it gives
  me the variable names along the top as I expect.  But, when I then attempt
  an analysis, e.g. regression, it doesn't recognize the variable names.  Am
  I missing a step.
 
  Thank you
 
  David
 
 
  [[alternative HTML version deleted]]
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide!
  http://www.R-project.org/posting-guide.html
 



__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question about read.table

2006-05-11 Thread David Kaplan
Thanks all.  I'll give the various suggestions a try.

Best

David


- Original Message - 
From: Sean O'Riordain [EMAIL PROTECTED]
To: David Kaplan [EMAIL PROTECTED]; r-help r-help@stat.math.ethz.ch
Sent: Thursday, May 11, 2006 2:05 PM
Subject: Re: [R] Newbie question about read.table


Hi David,

you might need to either:
a) attach(birthweight)
or
b) glm(low~age,binomial, data=birthweight)

refer ?attach / ?glm

cheers,
Sean

On 11/05/06, David Kaplan [EMAIL PROTECTED] wrote:
 Here is the code with the error

  birthweight - read.table(c:/bw.dat, header = T)
  summary(glm(low~age,binomial))
 Error in eval(expr, envir, enclos) : object low not found
 


 The read.table function works fine and when look at the data it shows the
 variable names across the top.  The data come from SPSS which I read out
 into a .dat file.

 Thanks


 - Original Message -
 From: Sean O'Riordain [EMAIL PROTECTED]
 To: David Kaplan [EMAIL PROTECTED]
 Sent: Thursday, May 11, 2006 1:46 PM
 Subject: Re: [R] Newbie question about read.table


 Hi David,
 Can you show us the code that you're trying to use?
 cheers,
 Sean

 On 11/05/06, David Kaplan [EMAIL PROTECTED] wrote:
  Hi
 
  When I use the read.table function with header = T, I notice that it 
  gives
  me the variable names along the top as I expect.  But, when I then 
  attempt
  an analysis, e.g. regression, it doesn't recognize the variable names. 
  Am
  I missing a step.
 
  Thank you
 
  David
 
 
  [[alternative HTML version deleted]]
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide!
  http://www.R-project.org/posting-guide.html
 



__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question about read.table

2006-05-11 Thread David Kaplan
This worked!  Thanks!


- Original Message - 
From: Chuck Cleland [EMAIL PROTECTED]
To: David Kaplan [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Sent: Thursday, May 11, 2006 1:58 PM
Subject: Re: [R] Newbie question about read.table


 David Kaplan wrote:
 Here is what I'm doing

 birthweight - read.table(c:/bw.dat, header = T)
 summary(glm(low~age,binomial))
 Error in eval(expr, envir, enclos) : object low not found


 Try this:

 birthweight - read.table(c:/bw.dat, header = TRUE)
 summary(glm(low ~ age, family=binomial, data=birthweight))

 Thanks all!


 - Original Message - From: Chuck Cleland 
 [EMAIL PROTECTED]
 To: David Kaplan [EMAIL PROTECTED]
 Cc: r-help@stat.math.ethz.ch
 Sent: Thursday, May 11, 2006 1:53 PM
 Subject: Re: [R] Newbie question about read.table


 David Kaplan wrote:
 Hi

 When I use the read.table function with header = T, I notice that it 
 gives me the variable names along the top as I expect.  But, when I 
 then attempt an analysis, e.g. regression, it doesn't recognize the 
 variable names.  Am I missing a step.  Thank you

 David

   Are you assigning the result of read.table() to a data frame.  And 
 then do you refer to that data frame in your call to lm()?  If that does 
 not solve the problem, you may want to show us the code you are using.

 Chuck

 [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html


 -- 
 Chuck Cleland, Ph.D.
 NDRI, Inc.
 71 West 23rd Street, 8th floor
 New York, NY 10010
 tel: (212) 845-4495 (Tu, Th)
 tel: (732) 512-0171 (M, W, F)
 fax: (917) 438-0894




 -- 
 Chuck Cleland, Ph.D.
 NDRI, Inc.
 71 West 23rd Street, 8th floor
 New York, NY 10010
 tel: (212) 845-4495 (Tu, Th)
 tel: (732) 512-0171 (M, W, F)
 fax: (917) 438-0894


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Newbie question: setting rgl.surface plot attributes

2006-04-12 Thread Joseph Retzer
I don't seem to be able to label the x, y or z axis when creating a 3d chart
using rgl.surface. I'd like to have them parallel to the axis line and move
with the graph when rotated. Can this be done?
 
Many thanks,
J. Retzer
 

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question: setting rgl.surface plot attributes

2006-04-12 Thread Duncan Murdoch
Joseph Retzer wrote:
 I don't seem to be able to label the x, y or z axis when creating a 3d chart
 using rgl.surface. I'd like to have them parallel to the axis line and move
 with the graph when rotated. Can this be done?

rgl.surface is a low level function for drawing a surface.  It's more 
like the lines() or points() functions in standard R graphics than like 
persp().  With the current release of rgl, you can get scales using the 
rgl.bbox function, but you'll need to manually label the axes yourself.

However, this situation will change soon.  I've been adding a number of 
features to rgl, so there's now a persp3d() function in the unreleased 
version.  I'm not sure when the release date will be, but hopefully not 
too far in the future.  If you want to test an unreleased version, 
contact me off-list.

Duncan Murdoch

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Newbie question about SQL and data sources

2006-03-24 Thread Rex Eastbourne
Hi,

I just downloaded R, and am wondering about data sources.

Where do people typically get their data for analysis? It seems to me
most people would have their data somehow automatically gathered and
stored in an SQL database (e.g. MySQL), but this seems not to be the
case. Does everyone just use the plain-text tab-separated values
format? If so, how are these tables typically created in the first
place? I store a lot of data automatically in MySQL databases--is
there another good way of aggregating data for statistical analysis
that I might be unaware of?

Thank you,

Rex

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question about SQL and data sources

2006-03-24 Thread David Whiting
Hi Rex,

Take a look at the Data Import/Export manual that ships with R to get a
feel for some of your options. I use a variety of techniques depending
on what I am doing. Quite often I use MySQL, accessing my tables via
RODBC. Other times text files are most appropriate. Then on other
occasions I am given datasets in DBF, stata, spss, or some other format
and use the foreign package to import them.

When I have tables of data that I know are not going to change I often
save them as Rdata files, document them and make a simple package of
them so that I can load them quickly and I have the information I need
about the dataset and variables to hand (very useful months later when
I've forgotten what half the variables represent). 

Dave


On Fri, 2006-03-24 at 23:13 -0500, Rex Eastbourne wrote:
 Hi,
 
 I just downloaded R, and am wondering about data sources.
 
 Where do people typically get their data for analysis? It seems to me
 most people would have their data somehow automatically gathered and
 stored in an SQL database (e.g. MySQL), but this seems not to be the
 case. Does everyone just use the plain-text tab-separated values
 format? If so, how are these tables typically created in the first
 place? I store a lot of data automatically in MySQL databases--is
 there another good way of aggregating data for statistical analysis
 that I might be unaware of?
 
 Thank you,
 
 Rex
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question: grouping rows

2006-03-10 Thread Matthew Scholz
Thanks for your response, Christos, but when I try this:

 new = old[old$q.D1  0.05,]

I get the following warning (and what I'm trying to do fails):

Warning message:
 not meaningful for factors in: Ops.factor(old$q.D1, 0.05)

I've tried to bone up on the topic of factors and searching R help,
but I'm still not sure why my data is being converted to that class
nor do I know how to undo the conversion or work around it. Thanks
again in advance of your advice. Any suggestions?

Matt

On 3/9/06, Christos Hatzis [EMAIL PROTECTED] wrote:
 You can try:

 new.dataframe - my.dataframe[my.dataframe$p.value  0.05, ]

 This will select all columns.  Alternatively, you can specify the columns
 that you want after the ,.

 -Christos

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Matthew Scholz
 Sent: Thursday, March 09, 2006 5:18 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] newbie question: grouping rows

 Hi all,

 I have a very simple question that I can't seem to find the answer to.
 How do I extract rows that meet a certain criteria  from a data frame and
 group them into a new data frame? For example, if I want to make a new data
 frame that only includes rows of data for which the p values (given by one
 of the columns in the data frame) are less than a certain value, how do I do
 this? It seems that there should be a simple function that does this. I
 looked into getGroups from the nmle package, but am not sure how to
 construct the form argument correctly or even if it's the appropriate way to
 tackle this.

 Thanks in advance of your answer,

 Matt

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html




__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question: grouping rows

2006-03-10 Thread Thomas Lumley
On Fri, 10 Mar 2006, Matthew Scholz wrote:

 Thanks for your response, Christos, but when I try this:

 new = old[old$q.D1  0.05,]

 I get the following warning (and what I'm trying to do fails):

 Warning message:
  not meaningful for factors in: Ops.factor(old$q.D1, 0.05)

 I've tried to bone up on the topic of factors and searching R help,
 but I'm still not sure why my data is being converted to that class
 nor do I know how to undo the conversion or work around it. Thanks
 again in advance of your advice. Any suggestions?


How to undo the conversion is FAQ 7.10

-thomas




 Matt

 On 3/9/06, Christos Hatzis [EMAIL PROTECTED] wrote:
 You can try:

 new.dataframe - my.dataframe[my.dataframe$p.value  0.05, ]

 This will select all columns.  Alternatively, you can specify the columns
 that you want after the ,.

 -Christos

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Matthew Scholz
 Sent: Thursday, March 09, 2006 5:18 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] newbie question: grouping rows

 Hi all,

 I have a very simple question that I can't seem to find the answer to.
 How do I extract rows that meet a certain criteria  from a data frame and
 group them into a new data frame? For example, if I want to make a new data
 frame that only includes rows of data for which the p values (given by one
 of the columns in the data frame) are less than a certain value, how do I do
 this? It seems that there should be a simple function that does this. I
 looked into getGroups from the nmle package, but am not sure how to
 construct the form argument correctly or even if it's the appropriate way to
 tackle this.

 Thanks in advance of your answer,

 Matt

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html




 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Thomas Lumley   Assoc. Professor, Biostatistics
[EMAIL PROTECTED]   University of Washington, Seattle

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question: grouping rows

2006-03-10 Thread Christos Hatzis
As Thomas suggested the solution is in the R-FAQ which is worth reading
anyway:

as.numeric(as.character(old$q.D1))  0.05

If you try the above without the 'as.character()' you will see why this is
necessary.

-Christos 

-Original Message-
From: Matthew Scholz [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 10, 2006 7:41 PM
To: [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] newbie question: grouping rows

Thanks for your response, Christos, but when I try this:

 new = old[old$q.D1  0.05,]

I get the following warning (and what I'm trying to do fails):

Warning message:
 not meaningful for factors in: Ops.factor(old$q.D1, 0.05)

I've tried to bone up on the topic of factors and searching R help, but I'm
still not sure why my data is being converted to that class nor do I know
how to undo the conversion or work around it. Thanks again in advance of
your advice. Any suggestions?

Matt

On 3/9/06, Christos Hatzis [EMAIL PROTECTED] wrote:
 You can try:

 new.dataframe - my.dataframe[my.dataframe$p.value  0.05, ]

 This will select all columns.  Alternatively, you can specify the 
 columns that you want after the ,.

 -Christos

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Matthew Scholz
 Sent: Thursday, March 09, 2006 5:18 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] newbie question: grouping rows

 Hi all,

 I have a very simple question that I can't seem to find the answer to.
 How do I extract rows that meet a certain criteria  from a data frame 
 and group them into a new data frame? For example, if I want to make a 
 new data frame that only includes rows of data for which the p values 
 (given by one of the columns in the data frame) are less than a 
 certain value, how do I do this? It seems that there should be a 
 simple function that does this. I looked into getGroups from the nmle 
 package, but am not sure how to construct the form argument correctly 
 or even if it's the appropriate way to tackle this.

 Thanks in advance of your answer,

 Matt

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html




__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] newbie question: grouping rows

2006-03-09 Thread Matthew Scholz
Hi all,

I have a very simple question that I can't seem to find the answer to.
How do I extract rows that meet a certain criteria  from a data frame
and group them into a new data frame? For example, if I want to make a
new data frame that only includes rows of data for which the p values
(given by one of the columns in the data frame) are less than a
certain value, how do I do this? It seems that there should be a
simple function that does this. I looked into getGroups from the nmle
package, but am not sure how to construct the form argument correctly
or even if it's the appropriate way to tackle this.

Thanks in advance of your answer,

Matt

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question: grouping rows

2006-03-09 Thread Augusto.Sanabria
Matt,

Have a look at subset specially the examples
at the end.

I use it a lot.

Hope it helps,

Augusto



Augusto Sanabria. MSc, PhD.
Mathematical Modeller
Risk Research Group
Geospatial  Earth Monitoring Division
Geoscience Australia (www.ga.gov.au)
Cnr. Jerrabomberra Av.  Hindmarsh Dr.
Symonston ACT 2609
Ph. (02) 6249-9155
 
 


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Matthew Scholz
Sent: Friday, 10 March 2006 9:18 AM
To: r-help@stat.math.ethz.ch
Subject: [R] newbie question: grouping rows


Hi all,

I have a very simple question that I can't seem to find the answer to. How do
I extract rows that meet a certain criteria  from a data frame and group them
into a new data frame? For example, if I want to make a new data frame that
only includes rows of data for which the p values (given by one of the
columns in the data frame) are less than a certain value, how do I do this?
It seems that there should be a simple function that does this. I looked into
getGroups from the nmle package, but am not sure how to construct the form
argument correctly or even if it's the appropriate way to tackle this.

Thanks in advance of your answer,

Matt

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question: grouping rows

2006-03-09 Thread Christos Hatzis
You can try:

new.dataframe - my.dataframe[my.dataframe$p.value  0.05, ]

This will select all columns.  Alternatively, you can specify the columns
that you want after the ,.

-Christos 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Matthew Scholz
Sent: Thursday, March 09, 2006 5:18 PM
To: r-help@stat.math.ethz.ch
Subject: [R] newbie question: grouping rows

Hi all,

I have a very simple question that I can't seem to find the answer to.
How do I extract rows that meet a certain criteria  from a data frame and
group them into a new data frame? For example, if I want to make a new data
frame that only includes rows of data for which the p values (given by one
of the columns in the data frame) are less than a certain value, how do I do
this? It seems that there should be a simple function that does this. I
looked into getGroups from the nmle package, but am not sure how to
construct the form argument correctly or even if it's the appropriate way to
tackle this.

Thanks in advance of your answer,

Matt

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question: grouping rows

2006-03-09 Thread Vayssières , Marc
?subset

Marc

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Matthew Scholz
Sent: Thursday, March 09, 2006 2:18 PM
To: r-help@stat.math.ethz.ch
Subject: [R] newbie question: grouping rows

Hi all,

I have a very simple question that I can't seem to find the answer to.
How do I extract rows that meet a certain criteria  from a data frame and group 
them into a new data frame? For example, if I want to make a new data frame 
that only includes rows of data for which the p values (given by one of the 
columns in the data frame) are less than a certain value, how do I do this? It 
seems that there should be a simple function that does this. I looked into 
getGroups from the nmle package, but am not sure how to construct the form 
argument correctly or even if it's the appropriate way to tackle this.

Thanks in advance of your answer,

Matt

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] R-newbie-question, fixed effects panel model, large number of observations

2006-02-11 Thread Thomas Wilde
Hi,

I'm trying to fit a fixed effect (LSDV) panelmodel with R. I have a dataset
with y as dependent, x1x2 as indeps, t as time index and i as an
id-variable for each individual. There are three observations for each
individual (t=1, t=2, t=3).

I want to try a simple regression, but with individual intercepts:

-
# reading in some data ...

mydata - read.csv(...)
attach(mydata)

# fit modell

mymodel - lm(y ~ -1 + factor(i) + x1 + x2)
summary(mymodel)
-

Works fine when the size of my dataset doesn't exceed about n=5000
observations, but I have some more. Can I do a partitioned regression with
R, are there any other options already implemented in R ?

Thanks,
Thomas

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] R-newbie-question, fixed effects panel model, large number of observations

2006-02-11 Thread ronggui
This is one function I wrote.
http://sociology.yculblog.com/post.794856.html



2006/2/12, Thomas Wilde [EMAIL PROTECTED]:
 Hi,

 I'm trying to fit a fixed effect (LSDV) panelmodel with R. I have a dataset
 with y as dependent, x1x2 as indeps, t as time index and i as an
 id-variable for each individual. There are three observations for each
 individual (t=1, t=2, t=3).

 I want to try a simple regression, but with individual intercepts:

 -
 # reading in some data ...

 mydata - read.csv(...)
 attach(mydata)

 # fit modell

 mymodel - lm(y ~ -1 + factor(i) + x1 + x2)
 summary(mymodel)
 -

 Works fine when the size of my dataset doesn't exceed about n=5000
 observations, but I have some more. Can I do a partitioned regression with
 R, are there any other options already implemented in R ?

 Thanks,
 Thomas

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html



--
黄荣贵
Deparment of Sociology
Fudan University

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

[R] Newbie question on using friedman.test()

2006-01-17 Thread Bill Kules
I am trying to use the friedman.test() on a data frame, d, but
I am receiving the following error message:


 d
   AW HS IAC WA
1   6  8   3  5
2   2  2   3  6
3   7  7   8  3
4   8  5   4  5

20  2  5   2  7
21  7  7   6  7
22  7  8   6  8
23  6  8   4  5
24  5  7   5  2
 friedman.test(d)
Error in any(is.na(groups)) : argument groups is missing, with no default

I think I just need to convert the data frame to a matrix, and then
friedman.test() will get the roups and blocks automatically.

Question 1) Is my understanding correct?

Question 2) What R function will convert the data frame to the matrix I
need?
I'm still figuring out the matrix functions, and I would appreciate any
pointers or examples.  The help() section is sometimes a bit terse...

Thanks in advance from a Newbie,
Bill

PS - to recreate the above data frame d:
d -
structure(list(AW = as.integer(c(6, 2, 7, 8, 8, 8, 7, 5, 3, 6, 
8, 7, 6, 4, 8, 7, 8, 7, 7, 2, 7, 7, 6, 5)), HS = as.integer(c(8, 
2, 7, 5, 4, 5, 7, 7, 2, 8, 4, 7, 8, 7, 6, 7, 5, 8, 8, 5, 7, 8, 
8, 7)), IAC = as.integer(c(3, 3, 8, 4, 7, 5, 8, 3, 4, 3, 7, 4, 
6, 5, 6, 7, 8, 6, 8, 2, 6, 6, 4, 5)), WA = as.integer(c(5, 6, 
3, 5, 3, 6, 7, 8, 3, 5, 6, 7, 7, 7, 7, 6, 4, 7, 8, 7, 7, 8, 5, 
2))), .Names = c(AW, HS, IAC, WA), row.names = c(1, 
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24
), class = data.frame)


Bill Kules
Principal, Takoma Software, Inc., Takoma Park, MD
  www.takomasoftware.com
Ph.D. Candidate, University of Maryland Human-Computer Interaction Lab
  www.cs.umd.edu/hcil

[EMAIL PROTECTED]
(301) 405-2725 voice
(301) 891-7271 voice + voicemail
(301) 891-7273 fax
(301) 755-7982 mobile


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question on using friedman.test()

2006-01-17 Thread Robert Baer
?friedman.test

Says:
Description:
Performs a Friedman rank sum test with unreplicated blocked data.

Usage:
friedman.test(y, ...)

  y: either a numeric vector of data values, or a data matrix.

So assuming your data, d, is unreplicated blocked data, perhaps
 d=as.matrix(d)
 friedman.test(d)
or simply,
friedman.test(as.matrix(d))
???




Robert W. Baer, Ph.D.
Associate Professor
Department of Physiology
A. T. Still University of Health Science
800 W. Jefferson St.
Kirksville, MO 63501-1497 USA
- Original Message - 
From: Bill Kules [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Tuesday, January 17, 2006 12:16 PM
Subject: [R] Newbie question on using friedman.test()


 I am trying to use the friedman.test() on a data frame, d, but
 I am receiving the following error message:


  d
AW HS IAC WA
 1   6  8   3  5
 2   2  2   3  6
 3   7  7   8  3
 4   8  5   4  5
 
 20  2  5   2  7
 21  7  7   6  7
 22  7  8   6  8
 23  6  8   4  5
 24  5  7   5  2
  friedman.test(d)
 Error in any(is.na(groups)) : argument groups is missing, with no
default

 I think I just need to convert the data frame to a matrix, and then
 friedman.test() will get the roups and blocks automatically.

 Question 1) Is my understanding correct?

 Question 2) What R function will convert the data frame to the matrix I
 need?
 I'm still figuring out the matrix functions, and I would appreciate any
 pointers or examples.  The help() section is sometimes a bit terse...

 Thanks in advance from a Newbie,
 Bill

 PS - to recreate the above data frame d:
 d -
 structure(list(AW = as.integer(c(6, 2, 7, 8, 8, 8, 7, 5, 3, 6,
 8, 7, 6, 4, 8, 7, 8, 7, 7, 2, 7, 7, 6, 5)), HS = as.integer(c(8,
 2, 7, 5, 4, 5, 7, 7, 2, 8, 4, 7, 8, 7, 6, 7, 5, 8, 8, 5, 7, 8,
 8, 7)), IAC = as.integer(c(3, 3, 8, 4, 7, 5, 8, 3, 4, 3, 7, 4,
 6, 5, 6, 7, 8, 6, 8, 2, 6, 6, 4, 5)), WA = as.integer(c(5, 6,
 3, 5, 3, 6, 7, 8, 3, 5, 6, 7, 7, 7, 7, 6, 4, 7, 8, 7, 7, 8, 5,
 2))), .Names = c(AW, HS, IAC, WA), row.names = c(1,
 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24
 ), class = data.frame)

 
 Bill Kules
 Principal, Takoma Software, Inc., Takoma Park, MD
   www.takomasoftware.com
 Ph.D. Candidate, University of Maryland Human-Computer Interaction Lab
   www.cs.umd.edu/hcil

 [EMAIL PROTECTED]
 (301) 405-2725 voice
 (301) 891-7271 voice + voicemail
 (301) 891-7273 fax
 (301) 755-7982 mobile
 

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Newbie question--locally weighted regression

2006-01-04 Thread Thomas L Jones

I have a dataset, a time series comprising count data at five minute
intervals. These are the number of people who voted at a particular
voting place during a recent election. The next step is to smooth the
data and estimate a demand vs time-of-day function; the problem is of
interest in preventing long lines at voting places. I am using the R
Project software.

However, I am not a statistician, and I am somewhat baffled by how to
do the smoothing. These are integers with roughly Poisson
distribution, and the use of a least-squares regression would create
large errors. Apparently something called a link function factors
into the equation somehow.

Question: Do I want a link function? If so, do I want a logarithmic
link function? Unless I change my mind, I will use lowess or loess for
the smoothing; how do I tell it to use a link function?

Doc

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question--locally weighted regression

2006-01-04 Thread Gregory Snow
Using a gam model (package gam, possibly others) will take care of the
link function (and variance function) for you and allow using loess to
fit the data.  Here is a quick example to get you started, though you
should read up on gam models yourself as well.

library(gam)

x - seq(0,1, length=250)
y - rpois(250, (sin(x*2*pi)+1.2)*3)

plot(x,y)
lines(x,(sin(x*2*pi)+1.2)*3, col='blue')

fit - gam(y~lo(x), family=poisson)

lines(x, predict(fit, data.frame(x=x), type='response'), col='green')

fit2 - gam(y~lo(x, span=0.75, degree=2), family=poisson)
lines(x, predict(fit2, data.frame(x=x), type='response'), col='red')


Hope this helps,


-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Thomas L Jones
 Sent: Wednesday, January 04, 2006 2:11 AM
 To: R-project help
 Subject: [R] Newbie question--locally weighted regression
 
 
 I have a dataset, a time series comprising count data at five 
 minute intervals. These are the number of people who voted at 
 a particular voting place during a recent election. The next 
 step is to smooth the data and estimate a demand vs 
 time-of-day function; the problem is of interest in 
 preventing long lines at voting places. I am using the R 
 Project software.
 
 However, I am not a statistician, and I am somewhat baffled 
 by how to do the smoothing. These are integers with roughly 
 Poisson distribution, and the use of a least-squares 
 regression would create large errors. Apparently something 
 called a link function factors into the equation somehow.
 
 Question: Do I want a link function? If so, do I want a 
 logarithmic link function? Unless I change my mind, I will 
 use lowess or loess for the smoothing; how do I tell it to 
 use a link function?
 
 Doc
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] newbie question

2005-09-15 Thread tom wright
Can someone tell me how I create a vector of numbers where the step
isn't 1? 
i.e. x-(0.0,0.5,1.0,1.5)

Thanks
tom

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question

2005-09-15 Thread vincent
tom wright a écrit :
 Can someone tell me how I create a vector of numbers 
  where the step isn't 1?
 i.e. x-(0.0,0.5,1.0,1.5)

seq(a, b, 0.5)
?seq
hih

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question about beta distribution

2005-03-20 Thread Gabor Grothendieck
 faisal99 at inf.its-sby.edu writes:

: 
: hi everyone,
: I'm still a newbie in statistics,
: 
: I have a question about beta distribution, that is,
: 
: On the ref/tutorials I've found on the net, why beta distribution always
: have value p(x) more than 1?


Consider the uniform distribution on the interval (0, 1/a) whose 
probability density graph is a horizontal line at a.  If a  1 then 
the probability density is greater than 1 for every point of its support
showing the the density can indeed exceed 1.

: As I know, any probability density function always have value not more
: than 1?
: 
: is there any one who can explain to me, I'm not statistics people, but I
: need to code that needing some of this distribution function.
:

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] newbie question about beta distribution

2005-03-19 Thread faisal99
hi everyone,
I'm still a newbie in statistics,

I have a question about beta distribution, that is,

On the ref/tutorials I've found on the net, why beta distribution always
have value p(x) more than 1?
As I know, any probability density function always have value not more
than 1?

is there any one who can explain to me, I'm not statistics people, but I
need to code that needing some of this distribution function.

thx before

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question about beta distribution

2005-03-19 Thread Roger D. Peng
A probability density must integrate to 1.  The specific values of the density 
can be either more or less than 1.

-roger
[EMAIL PROTECTED] wrote:
hi everyone,
I'm still a newbie in statistics,
I have a question about beta distribution, that is,
On the ref/tutorials I've found on the net, why beta distribution always
have value p(x) more than 1?
As I know, any probability density function always have value not more
than 1?
is there any one who can explain to me, I'm not statistics people, but I
need to code that needing some of this distribution function.
thx before
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question regarding graphing of Princomp object

2005-01-15 Thread Tobias Verbeke
On Sat, 15 Jan 2005 05:39:00 +0100
List account [EMAIL PROTECTED] wrote:

 Greetings,
 
 I am working on a stylometric analysis of some latin texts; one of the  
 latest stylometric techniques involves using principal components  
 analysis.  Not being a statistician, I can't really fully rely on PCA  
 as my primary tool, since I don't really understand the statistics  
 behind the PCA technique.  Nevertheless, the ability to use PCA and  
 graph the results has been marvelously helpful as a preliminary  
 technique to determine what kinds of stylometric variables are worth  
 pursuing as indicators of authorship.
 
 For instance, I'm doing the following...  I have a set of data for  
 approximately 120 different latin works, about half of which are by St.  
 Thomas Aquinas, and the other half are by various other authors in the  
 Thomistic tradition, some known and some anonymous.  My data for  
 frequencies of prepositions looks like the following:
 
 A,AD,CIRCA,CUM,DE,  (total of 10 variables)
 1,0.00967667222531036,0.0208124884194923,0.00142671854734112,0.004863813 
 22957198,0.00758291643505651 ...
 2,0.00874917700292081,0.0217315416668508,0.00133005165549453,0.004379007 
 27772451,0.00537323193714733 
 3,0.0064258378627327,0.0280901956627422,0.00178739176045295,0.0043058230 
 9573329,0.00821688482105979 
 4,0.00706850368364528,0.027446604903448,0.000821141574836712,0.004617615 
 47172807,0.00812783899774761 
 5,0.010214039424891,0.015409971157808,0.000745993537614122,0.00584650749 
 246416,0.00475787738815518 
 6,0.00952534711010655,0.0180981595092025,0.00125928317726832,0.005150145 
 30190507,0.00447206974491443 ...
  (and so on for the rest of the 120 works)
 
 The works are numbered such that works 100 and below are by St. Thomas,  
 those from 101 to 117 are of dubious authenticity, and those from 118  
 to 179 are by other authors.
 
 When I perform a biplot, on the results of the princomp() function, I  
 get a nice graph that plots the 120 works on the two principal  
 component axes (I've figured out how to get rid of the red arrows  
 already).  Given that the data points tend to jumble together, I'd like  
 some way to color the different categories of works in the biplot, so  
 that data points for works 1-100 are red, those from 101-117 are blue,  
 and those from 118 to 179 are green (for instance).

You can use the `col' argument in the biplot call. In this case, I
would do something like 

biplot(mydata, col = c(rep(red, 100), rep(blue, 17), rep(green, 62)))

For a list of built-in color names, you can type colors() at the R prompt.
For more information on biplot, type ?biplot

VaRiis modis bene fit.

HTH,
Tobias

 I've included a sample of the output that I'm currently getting, in  
 case it's helpful to anybody.  BTW, I am running RAqua (for the Mac),  
 version 1.8.1.
 
 Thanks in advance for any help!
 
 -Erik Norvelle
 erik (at) norvelle (dot) org
 Facultad de Filosofía y Letras
 Universidad de Navarra
 Pamplona, Navarra, España
 


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Newbie question regarding graphing of Princomp object

2005-01-14 Thread List account
Greetings,
I am working on a stylometric analysis of some latin texts; one of the  
latest stylometric techniques involves using principal components  
analysis.  Not being a statistician, I can't really fully rely on PCA  
as my primary tool, since I don't really understand the statistics  
behind the PCA technique.  Nevertheless, the ability to use PCA and  
graph the results has been marvelously helpful as a preliminary  
technique to determine what kinds of stylometric variables are worth  
pursuing as indicators of authorship.

For instance, I'm doing the following...  I have a set of data for  
approximately 120 different latin works, about half of which are by St.  
Thomas Aquinas, and the other half are by various other authors in the  
Thomistic tradition, some known and some anonymous.  My data for  
frequencies of prepositions looks like the following:

A,AD,CIRCA,CUM,DE,  (total of 10 variables)
1,0.00967667222531036,0.0208124884194923,0.00142671854734112,0.004863813 
22957198,0.00758291643505651 ...
2,0.00874917700292081,0.0217315416668508,0.00133005165549453,0.004379007 
27772451,0.00537323193714733 
3,0.0064258378627327,0.0280901956627422,0.00178739176045295,0.0043058230 
9573329,0.00821688482105979 
4,0.00706850368364528,0.027446604903448,0.000821141574836712,0.004617615 
47172807,0.00812783899774761 
5,0.010214039424891,0.015409971157808,0.000745993537614122,0.00584650749 
246416,0.00475787738815518 
6,0.00952534711010655,0.0180981595092025,0.00125928317726832,0.005150145 
30190507,0.00447206974491443 ...
 (and so on for the rest of the 120 works)

The works are numbered such that works 100 and below are by St. Thomas,  
those from 101 to 117 are of dubious authenticity, and those from 118  
to 179 are by other authors.

When I perform a biplot, on the results of the princomp() function, I  
get a nice graph that plots the 120 works on the two principal  
component axes (I've figured out how to get rid of the red arrows  
already).  Given that the data points tend to jumble together, I'd like  
some way to color the different categories of works in the biplot, so  
that data points for works 1-100 are red, those from 101-117 are blue,  
and those from 118 to 179 are green (for instance).

I've included a sample of the output that I'm currently getting, in  
case it's helpful to anybody.  BTW, I am running RAqua (for the Mac),  
version 1.8.1.

Thanks in advance for any help!
-Erik Norvelle
erik (at) norvelle (dot) org
Facultad de Filosofía y Letras
Universidad de Navarra
Pamplona, Navarra, España


prepositions.pdf
Description: Adobe PDF document
 __
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

[R] Newbie question: plotting regression models

2004-11-03 Thread adelmaas
Greetings.
Is there any way to get R to take a regression model object and draw a 
plot of the regression function?  How about overlaying that plot over a 
scatterplot of the actual data?  Thanks in advance for any help anyone 
can provide.

Aaron
-
Aaron Solomon (ben Saul Joseph) Adelman
E-mail:  [EMAIL PROTECTED]
Web site:  http://people.musc.edu/~adelmaas/
AOL Instant Messenger  Yahoo! Messenger:  Hiergargo
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question: plotting regression models

2004-11-03 Thread Duncan Murdoch
On Wed, 3 Nov 2004 10:12:53 -0500, [EMAIL PROTECTED] wrote :

Greetings.

Is there any way to get R to take a regression model object and draw a 
plot of the regression function?  How about overlaying that plot over a 
scatterplot of the actual data?  Thanks in advance for any help anyone 
can provide.

Lots of functions in R can adapt themselves to complex objects in a
sensible way.  (These are called generic functions.)  The usual way to
draw a straight line would be to use abline(), and it can handle
linear model objects:

# fake some data
x - 1:10
y - rnorm(10)

# fit it and plot it.

fit - lm(y ~ x)
plot(x, y)
abline(fit)

If you've fit a more complicated model (e.g. a quadratic), you need a
different method (because abline only works on straight lines).  Then
use

fit - lm(y ~ x + I(x^2))
plot(x, y)
lines(predict(fit))

(This would work for the original one, too.)

Duncan Murdoch

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question: plotting regression models

2004-11-03 Thread Sundar Dorai-Raj

[EMAIL PROTECTED] wrote:
Greetings.
Is there any way to get R to take a regression model object and draw a 
plot of the regression function?  How about overlaying that plot over a 
scatterplot of the actual data?  Thanks in advance for any help anyone 
can provide.

Aaron
Hi Aaron,
What type of regression function are your referring to? Linear model? 
Non-linear model? The term regression is to ambiguous to really answer 
your question. However, typically you should be able to do something like:

fit - lm(y ~ x)
yhat - predict(fit)
plot(x, y, ylim = range(c(y, yhat)))
lines(x, yhat)
If you are not using lm please provide more information than you already 
have. You should read Introduction to R or any of the recommended 
texts listed on the R website. Also read the posting guide.

--sundar
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Newbie question: plotting regression models

2004-11-03 Thread Andy Bunn
Welcome to R.

You can start by looking at the predict function for the regression model you are 
using (e.g., ?predict.lm if you are using a linear model).

Then do something like so:

data(cars)
cars.lm - lm(dist ~ speed, cars)
dist.pred - predict(cars.lm)
plot(cars$speed, cars$dist, ylim = c(-2, 120))
lines(cars$speed, dist.pred, col = red, lwd = 2)


HTH, Andy

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question: plotting regression models

2004-11-03 Thread Douglas Bates
Regarding plotting a regression fit - for a simple linear regression 
model the abline function adds the fitted line to a plot.

plot(optden ~ carb, Formaldehyde)
abline(fm1 - lm(optden ~ carb, Formaldehyde))
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question about the use of lm and anova

2004-10-27 Thread Henric Nilsson
At 12:54 2004-10-26 -0700, Sandie Peters wrote:
[...]
Several questions:
1.  Why do we get a different ANOVA answer when we switch the order of
the explanatory variables , e.g. ComponentA ~ Parent + Plot vs
ComponentA ~ Plot + Parent?
2.  Why are the Sum Sq and F ratios calculated by this ANOVA method
different than those that are calculated by SAS JMP?
It's in the FAQ:
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-does-the-output-from-anova_0028_0029-depend-on-the-order-of-factors-in-the-model_003f
Also, see the `anova.lm' help page for a nice example.
If you want test based on so called Type II and III sums of squares, but 
don't want to compute them yourself (by use of `anova' and `drop1' as the 
FAQ suggests), John Fox's excellent `car' package has got an `Anova' function.

HTH,
Henric
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Newbie question about the use of lm and anova

2004-10-26 Thread Sandie Peters
Version of R: Windows Version 2.0.0
 
The experimental design contains two plant lines - a control (C) and a
mutant (M)  - grown out three separate times in plots A, B, C.  
The design is unbalanced:
In plot A,  9 control plants were grown with 29 mutant plants.  
In plot B,  8 control plants were grown with 20 mutant plants.
In plot C,  8 control plants were grown with 22  mutant plants.
The dependent variable, component A was collected three times from each
plant in each plot and then averaged and normalized to the plot's
control plants. There are thus 96 sample relative averages.
 
The null hypothesis:
component A for mutant = component A for control.
 
What we want to know:  
1.  Is there a difference in componentA between control and mutant plant
lines at the 0.05 significance level across plots?
 
2.  How do we determine this difference using R?
 
Currently, the statistical method we are choosing is ANOVA using R.
 
 plotData - read.table('PlotData.txt', header=TRUE)
 names(plotData)
[1] Parent ComponentA Plot  
 
 summary(lm(ComponentA ~ Parent + Plot, plotData))
 
Call:
lm(formula = ComponentA ~ Parent + Plot, data = plotData)
 
Residuals:
   Min 1Q Median 3QMax 
-16.423623  -4.778514   0.006824   4.555770  17.196949 
 
Coefficients:
 Estimate Std. Error t value Pr(|t|)
(Intercept)   99.1750 1.6349  60.661   2e-16 ***
ParentMutant   1.5394 1.5821   0.9730.333
PlotB -0.2747 1.6942  -0.1620.872
PlotC -0.3042 1.6603  -0.1830.855
---
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 
 
Residual standard error: 6.795 on 92 degrees of freedom
Multiple R-Squared: 0.01084,Adjusted R-squared: -0.02142 
F-statistic: 0.3359 on 3 and 92 DF,  p-value: 0.7994 
 
#Why do I get a different ANOVA result when I switch the formula order?
 
 anova(lm(ComponentA ~ Parent + Plot, plotData))
Analysis of Variance Table
 
Response: ComponentA
  Df Sum Sq Mean Sq F value Pr(F)
Parent 1   44.644.6  0.9657 0.3283
Plot   21.9 1.0  0.0210 0.9792
Residuals 92 4248.446.2   
 anova(lm(ComponentA ~ Plot + Parent, plotData))
Analysis of Variance Table
 
Response: ComponentA
  Df Sum Sq Mean Sq F value Pr(F)
Plot   22.8 1.4  0.0305 0.9700
Parent 1   43.743.7  0.9468 0.3331
Residuals 92 4248.446.2   


Several questions:
 
1.  Why do we get a different ANOVA answer when we switch the order of
the explanatory variables , e.g. ComponentA ~ Parent + Plot vs
ComponentA ~ Plot + Parent?
 
2.  Why are the Sum Sq and F ratios calculated by this ANOVA method
different than those that are calculated by SAS JMP? 
 
SourceNparmDFSum of SquareF Ratio   Prob  F
Parent1 143.7219960.94680.3331
Plot  2 21.939821 0.02100.9792
 
Thank you,
 
Sandie Peters
Informatics research scientist
Exelixis Plant Sciences


 
 
 

[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie Question: Spatial Autocorrelation with R Tutorial?

2004-08-27 Thread Roger Bivand
On Wed, 25 Aug 2004, Jeff Hollister wrote:

 Howdy All,
 
 I am looking for some good tutorials (books, websites, whatever) for
 calculating/testing for Spatial Autocorrelation using R.
 
 Specifically, I am wanting to test for autocorrelation of a number of
 variables measured at a set of discrete locations.
 

From your signature line, Environmental Data, spatial autocorrelation 
could mean a number of things, depending on whether the variables could be 
measurements of a continuous surface of values at your discrete locations, 
or whether the discrete locations are spatial entities formed as areal 
aggregations of some kind. Since you mention spdep below, I'm assuming 
that the data you are working on refer to spatial entities, for which 
Moran's I would be a reasonable choice of test. If the variable of 
interest isn't of this form, then other packages are more relevant (see R 
spatial projects link below).

 Up to this point I have been exploring the spdep package and I can get
 moran.test to work, but I am concerned that somewhere along the line I
 may not be doing things correctly.  Hence my request for a tutorial so
 that I may brush up on my autocorrelation basics, specifically
 autocorrelation with R, and reassure myself that the results I am
 getting aren't bogus.

Admittedly, the help page for moran.test() simply refers to Cliff, A. D., 
Ord, J. K. 1981 Spatial processes, Pion, p. 21 as the original source, and 
the sids vignette (see the foot of the output of help(package=spdep) to 
locate it on your system) is incomplete. My guess is however that if your 
data are for spatial entities, theb constructing a sensible 
neighbour weights is at least 75% of the work - you will also see this in 
Virgilio Gómez-Rubio's DCluster package, and the existing sids 
vignette does cover that a little. Completing and improving this vignette 
is on my TODO list.

If you are unsure of the result, and want to stay within the R framework, 
consider calculating Moran's I using DCluster, or gearymoran() in ade4. 
Beyond that, you could access the GeoDa software (Windows, not R) and 
documentation at http://sal.agecon.uiuc.edu/csiss/geoda.html, the site 
also housing the R spatial projects web pages:

http://agec221.agecon.uiuc.edu/csiss/Rgeo/

Please contact me off-list, or on the R-sig-geo list if you feel that 
would help.

Best wishes,

Roger Bivand

 
 Thanks in advance for any suggestions!
 
 Jeff Hollister
   
 *
 Jeffrey William Hollister  
 Ph.D. Candidate  
 Environmental Data Center   
 Department of Natural Resources Science  
 University of Rhode Island   
 office: (401) 874 5054
 fax: (401) 874 4561
 cell: (401)556 4087
 http://www.edc.uri.edu/personal/jeff/home/jwh_cv_full.htm
 
 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: [EMAIL PROTECTED]

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] newbie question: how to read a file into a matrix

2004-08-26 Thread Gaby Aguilera
I am trying to read a file with 8 columns and about 200 rows into a
matrix.  I tried something like:
x-matrix(data=data.txt, nrow=200, ncol=8) but this produces a
matrix with data.txt in it.  Is there a way to read the data in?

Any pointers in the right direction would be appreciated.  Thank you!

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question: how to read a file into a matrix

2004-08-26 Thread Sundar Dorai-Raj

Gaby Aguilera wrote:
I am trying to read a file with 8 columns and about 200 rows into a
matrix.  I tried something like:
x-matrix(data=data.txt, nrow=200, ncol=8) but this produces a
matrix with data.txt in it.  Is there a way to read the data in?
Any pointers in the right direction would be appreciated.  Thank you!
You should read R Data Import/Export (and the posting guide).
http://cran.r-project.org/doc/manuals/R-data.pdf
What you are looking for is ?read.table or ?scan. Also read ?matrix 
while you are at it.

x - matrix(scan(data.txt), nrow = 200, ncol = 8)
--sundar
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question: how to read a file into a matrix

2004-08-26 Thread Ernesto Jardim

On Thu, 2004-08-26 at 16:47, Gaby Aguilera wrote:
 I am trying to read a file with 8 columns and about 200 rows into a
 matrix.  I tried something like:
 x-matrix(data=data.txt, nrow=200, ncol=8) but this produces a
 matrix with data.txt in it.  Is there a way to read the data in?
 
 Any pointers in the right direction would be appreciated.  Thank you!
 

Hi,

Read the R manuals ... and use function read.table or similar.

EJ

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] newbie question: how to read a file into a matrix

2004-08-26 Thread Rau, Roland
Hi,

-Original Message-
From:   [EMAIL PROTECTED]
[SMTP:[EMAIL PROTECTED] On Behalf Of Gaby Aguilera
Sent:   Thursday, August 26, 2004 5:47 PM
To: [EMAIL PROTECTED]
Subject:[R] newbie question: how to read a file into a
matrix

 matrix with data.txt in it.  Is there a way to read the data in?
 
 Any pointers in the right direction would be appreciated.  Thank you!
 
The pointer in the right direction is the bottom of each message:
read the posting guide. And there it says you should at least read the
relevant section in An Introduction to R which is shipped with every
distribution of R. So please read section 7 there.
What you probably want to do is:
### assuming you are working on Windows
x - read.table(c:\\mydatafolder\\data.txt, sep=,, header=TRUE)
# depending on your separator and whether you have variable names 

For some more information you may also check the R Data
Import/Export Manual also included in every distribution of R.

Best,
Roland




+
This mail has been sent through the MPI for Demographic Rese...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question: how to read a file into a matrix

2004-08-26 Thread Arne Henningsen
Please read the R Data Import/Export manual. 
It should be on your harddisk and it is also available from  
http://cran.r-project.org/doc/manuals/R-data.pdf

Arne

On Thursday 26 August 2004 17:47, Gaby Aguilera wrote:
 I am trying to read a file with 8 columns and about 200 rows into a
 matrix.  I tried something like:
 x-matrix(data=data.txt, nrow=200, ncol=8) but this produces a
 matrix with data.txt in it.  Is there a way to read the data in?

 Any pointers in the right direction would be appreciated.  Thank you!

 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

-- 
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
[EMAIL PROTECTED]
http://www.uni-kiel.de/agrarpol/ahenningsen/

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Newbie Question: Spatial Autocorrelation with R Tutorial?

2004-08-25 Thread Jeff Hollister
Howdy All,

I am looking for some good tutorials (books, websites, whatever) for 
calculating/testing for Spatial Autocorrelation using R.

Specifically, I am wanting to test for autocorrelation of a number of variables 
measured at a set of discrete locations.

Up to this point I have been exploring the spdep package and I can get moran.test 
to work, but I am concerned that somewhere along the line I may not be doing things 
correctly.  Hence my request for a tutorial so that I may brush up on my 
autocorrelation basics, specifically autocorrelation with R, and reassure myself that 
the results I am getting aren't bogus.

Thanks in advance for any suggestions!

Jeff Hollister
  
*
Jeffrey William Hollister  
Ph.D. Candidate  
Environmental Data Center   
Department of Natural Resources Science  
University of Rhode Island   
office: (401) 874 5054
fax: (401) 874 4561
cell: (401)556 4087
http://www.edc.uri.edu/personal/jeff/home/jwh_cv_full.htm

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] *** NEWBIE QUESTION *** QUANTILE FUNCTIONS

2004-06-11 Thread Pier Luca Lanzi
Dear all, 

sorry this will sound as naive as it can be.

I need to know whether there is a closed analytical form (even
approximated) to the quantile function for the Binomial?

and for the Poisson?

if not, what is the best citation to use when stating this?

Thank you, 

Pier Luca

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] *** NEWBIE QUESTION *** QUANTILE FUNCTIONS

2004-06-11 Thread Sundar Dorai-Raj

Pier Luca Lanzi wrote:
Dear all, 

sorry this will sound as naive as it can be.
I need to know whether there is a closed analytical form (even
approximated) to the quantile function for the Binomial?
and for the Poisson?
if not, what is the best citation to use when stating this?
Thank you, 

Pier Luca
Hi Pier,
?qbinom, ?qpois
--sundar
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] newbie question on clustering performance

2004-03-20 Thread Xin Gong
May I ask you some questions on clustering analysis?

How do I get jacard score from cluster object?
 or after I call kmanes or pam function how do I know which number of 
clusters
sounds the best.

Another question on heatmap, if you do not mind, how do I retrive the 
name of
rows when some area is hot.

Thanks in adavance,

Xin Gong





__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] R newbie question

2004-03-04 Thread Michael


Hi all

I have just started using R (1.8.1) on Mac OS X  am very excited about the
potential of such a flexible system with such good graphics potential  so
many useful packages available. Congratulations to all the developers  I
hope to be contributing some packages myself in the near future, once I have
got my head around what is required.

It will take me some time to convert seamlessly from the syntax of STATA
which I have used for many years, but which continues to ignore the requests
of its' users for better graphical output (e.g. 3D contour  surface
plotting).  I am still working my way through the R documentation.

I can see that scatterplot matrices are available (via pairs etc.) as well
as 2D kernel density estimates  contour plots - though I am still getting
used to all the options that can be specified.  My question is: is it
possible to use some options to produce the scatterplot format but with 2D
KDE contour plots in each pane rather than the points themselves?

A secondary question is: how can I define a different 'colour table' for a
contour plot e.g. one based on 'heat' so that low values are black, up
through blue, green, red, orange, yellow  white.

Many thanks  please feel free to reply directly to my email
([EMAIL PROTECTED])

Michael Hopkins

 
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

  _/_/   _/_/_/   Hopkins Research Ltd
 _/_/   _/_/
_/_/_/_/   _/_/_/Virtual RD Solutions
   _/_/   _/   _/
  _/_/   _/ _/   Tel: 0781 3467 381 (UK)
   
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

`All models are wrong, but some are useful' - George Box

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Newbie question: histogram

2004-02-05 Thread Simon Fear
It's not world shattering but for the record the following is not true:

 -Original Message-
 From: John Fox [mailto:[EMAIL PROTECTED]
 (snip)
 In particular, although using with() is perhaps less ambiguous, it is 
 necessary to repeat it for each command.

You can group as many commands as you like, as in

 df - data.frame(x=1:10, y=1:10)
 with(df, {print(x)
+ print(y)})
 [1]  1  2  3  4  5  6  7  8  9 10
 [1]  1  2  3  4  5  6  7  8  9 10  
 
Simon Fear 
Senior Statistician 
Syne qua non Ltd 
Tel: +44 (0) 1379 69 
Fax: +44 (0) 1379 65 
email: [EMAIL PROTECTED] 
web: http://www.synequanon.com 
  
Number of attachments included with this message: 0 
  
This message (and any associated files) is confidential and\...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question: histogram

2004-02-04 Thread Felix Eschenburg
Hello,
it looks like this is what you want.

year - c(1970:1980)
 snow - sample(10,length(year),replace=T)
 snow
 [1]  3  3  3  4  8  3  2  6  6  6 10
 year
 [1] 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980
 mydata - data.frame(year,snow)
 attach(mydata)
 barplot(snow,names.arg=year,las=2)

for a histogram of snow you might try something like this
hist(snow,breaks=c((min(snow)-0.5):(max(snow)+0.5)))

Felix (who is a newbie himself, so excuse me please if i didnt get your 
problem)


Am Mittwoch, 4. Februar 2004 12:41 schrieb Philippe de Rochambeau:
 Hello,

 how do you create a histogram with a data frame?

 year snow.cover
 1970 6.5
 1971 12.0
 1972 14.9
 1973 10.0
 1974 10.7
 1975 7.9
 ...

 mydata=data.frame(year=c(1970,...),snow.cover=c(6.5,...))

 hist(mydata) does not work.

 Many thanks.

 PR

 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question: histogram

2004-02-04 Thread John Fox
Dear Philippe,

I suppose that you want a histogram for snow.cover and not for year. There 
are several ways to proceed; two are

hist(mydata$snow.cover)

and

attach(mydata)
hist(snow.cover)
More generally, it's a good idea to read the introductory manual that comes 
with R (or a book that introduces R). See, in particular, the section on 
lists and data frames in the Introduction to R.

I hope that this helps,
 John
At 12:41 PM 2/4/2004 +0100, Philippe de Rochambeau wrote:
Hello,

how do you create a histogram with a data frame?

year snow.cover
1970 6.5
1971 12.0
1972 14.9
1973 10.0
1974 10.7
1975 7.9
...
mydata=data.frame(year=c(1970,...),snow.cover=c(6.5,...))

hist(mydata) does not work.

Many thanks.
-
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: [EMAIL PROTECTED]
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question: histogram

2004-02-04 Thread James MacDonald
You don't make a histogram with a data.frame. You have to pass a vector
of numeric values to hist(). If you want to make a histogram using a
*column* of a df, you have to subset the df in the call to hist.

hist(mydata[,1]) -or- hist(mydata[,year])
hist(mydata[,2]) - or- hist(mydata[,snow.cover])

HTH,

Jim

James W. MacDonald
Affymetrix and cDNA Microarray Core
University of Michigan Cancer Center
1500 E. Medical Center Drive
7410 CCGC
Ann Arbor MI 48109
734-647-5623

 Philippe de Rochambeau [EMAIL PROTECTED] 02/04/04 06:41AM 
Hello,

how do you create a histogram with a data frame?

year snow.cover
1970 6.5
1971 12.0
1972 14.9
1973 10.0
1974 10.7
1975 7.9
...

mydata=data.frame(year=c(1970,...),snow.cover=c(6.5,...))

hist(mydata) does not work.

Many thanks.

PR

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help 
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question: histogram

2004-02-04 Thread Uwe Ligges
Philippe de Rochambeau wrote:

Hello,

how do you create a histogram with a data frame?

year snow.cover
1970 6.5
1971 12.0
1972 14.9
1973 10.0
1974 10.7
1975 7.9
...
mydata=data.frame(year=c(1970,...),snow.cover=c(6.5,...))

hist(mydata) does not work.
I guess you are not going to create a histogram but a barplot as in:

barplot(mydata$snow.cover, mydata$year, names = mydata$year)

Uwe Ligges


Many thanks.

PR

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question: histogram

2004-02-04 Thread Martin Maechler
 JohnF == John Fox [EMAIL PROTECTED]
 on Wed, 04 Feb 2004 09:20:43 -0500 writes:

JohnF Dear Philippe, I suppose that you want a histogram
JohnF for snow.cover and not for year. There are several
JohnF ways to proceed; two are

JohnF hist(mydata$snow.cover)

JohnF and

JF attach(mydata)
JF hist(snow.cover)

Actually, attaching data frames is a bit discouraged these days.
The modern R way for this (and more complicated situations) is

  with(mydata,  hist(snow.cover) )
   

JohnF More generally, it's a good idea to read the
JohnF introductory manual that comes with R (or a book that
JohnF introduces R). See, in particular, the section on
JohnF lists and data frames in the Introduction to R.

definitely!

Martin

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question: histogram

2004-02-04 Thread John Fox
Dear Martin,

At 06:07 PM 2/4/2004 +0100, Martin Maechler wrote:
 JohnF == John Fox [EMAIL PROTECTED]
 on Wed, 04 Feb 2004 09:20:43 -0500 writes:
JohnF Dear Philippe, I suppose that you want a histogram
JohnF for snow.cover and not for year. There are several
JohnF ways to proceed; two are
JohnF hist(mydata$snow.cover)

JohnF and

JF attach(mydata)
JF hist(snow.cover)
Actually, attaching data frames is a bit discouraged these days.
The modern R way for this (and more complicated situations) is
  with(mydata,  hist(snow.cover) )

Although I'm aware of (some of) the problems and possibly confusing 
situations that can arise from attaching a data frame, I believe that, 
especially for novice users, there's an advantage in doing so. In 
particular, although using with() is perhaps less ambiguous, it is 
necessary to repeat it for each command.

Regards,
 John
JohnF More generally, it's a good idea to read the
JohnF introductory manual that comes with R (or a book that
JohnF introduces R). See, in particular, the section on
JohnF lists and data frames in the Introduction to R.
definitely!

Martin
-
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: [EMAIL PROTECTED]
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Newbie question: histogram

2004-02-04 Thread Douglas Bates
John Fox [EMAIL PROTECTED] writes:

 At 06:07 PM 2/4/2004 +0100, Martin Maechler wrote:
   JohnF == John Fox [EMAIL PROTECTED]
   on Wed, 04 Feb 2004 09:20:43 -0500 writes:
 
  JohnF Dear Philippe, I suppose that you want a histogram
  JohnF for snow.cover and not for year. There are several
  JohnF ways to proceed; two are
 
  JohnF hist(mydata$snow.cover)
 
  JohnF and
 
  JF attach(mydata)
  JF hist(snow.cover)
 
 Actually, attaching data frames is a bit discouraged these days.
 The modern R way for this (and more complicated situations) is
 
with(mydata,  hist(snow.cover) )
 
 
 Although I'm aware of (some of) the problems and possibly confusing
 situations that can arise from attaching a data frame, I believe that,
 especially for novice users, there's an advantage in doing so. In
 particular, although using with() is perhaps less ambiguous, it is
 necessary to repeat it for each command.

But with any version of R compiled with the readline library and with
the Windows GUI and with ESS for emacs you can use the arrow keys to
retrieve the last line typed then edit it.  Repeating information from
earlier lines is not terribly difficult.

I use the 
 with(datafr, func(colname))
paradigm in live sessions for introductory classes and I don't find it
overly cumbersome.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] newbie question on contrasts and aov

2004-01-29 Thread Wolfgang Pauli
In the meantime I figured out that the Difference-contrast is not quite what I 
was looking for. But I still have two questions

1) Why do I get different results for Helmert contrasts in SPSS and R. I guess 
the contrast matrixes of Helmert are about the same in SPSS and R. I probably 
make a mistake as i am a newbie to R. I thought that it might be, because I 
have a repaeted measures design. That's why I put the Error(sub) in the 
formula of aov. 

2)
I tried to make my own contrast matrix, to compute comparisons between 
adjacent factor levels, i.e. 1-2, 2-3 and 3-4. My matrix looks like this:
 [,1] [,2] [,3]
[1,]100
[2,]   -110
[3,]0   -11
[4,]00   -1

But then I get the same result as with contr.helmert(4). What is wrong I 
really don't get it!

Thank you,

Wolfgang Pauli

On Sunday January 11 2004 18:07, you wrote:
 Notice  `SPKType III Sum of Squares'.  I don't believe your contrasts are
 orthogonal, and R's are sequential sum of squares.

 Also, are you sure these are the same contrasts?  I presume this is
 contr.sdif from MASS (in which case it is churlish not to credit it), and
 SPSS's contrasts look more like Helmert contrasts from their labelling.

 Since it appears all your treatments are within subjects you do seem to be
 making life difficult for yourself. Although I would have done a simple
 fixed-effects analysis, applying summary.lm to the bottom stratum would
 give you simple t-tests for each contrast, including actual estimates of
 the magnitudes.

 On Sun, 11 Jan 2004, Wolfgang Pauli wrote:
  I try to move from SPSS to R/S and am trying to reproduce the results of
  SPSS in R. I calculated a one-way anova with spk as experimental factor
  and erp as depended variable.
  The result of the Anova are the same concearning the mean square, F and p
  values. But I also wanted to caculate the contr.sdif(4) contrast on spk.
  The results are completely different now. I hope anybody can help me.
 
  Thanks, Wolfgang
 
  This is what I get in SPSS:
  Tests of Within-Subjects Contrasts
  Measure: MEASURE_1
  Source  SPKType III Sum of Squares  df  Mean Square F  
   Sig.
  SPK Level 2 vs. Level 1 3,493   1   3,493   2,026   ,178
  Level 3 vs. Previous20,358  1   20,358  10,168  ,007
  Level 4 vs. Previous18,808  1   18,808  15,368  ,002
  Error(SPK)  Level 2 vs. Level 1 22,414  13  1,724
  Level 3 vs. Previous26,030  13  2,002
  Level 4 vs. Previous15,911  13  1,224
 
  This is the result in R:
  Error: sub
Df Sum Sq Mean Sq F value Pr(F)
  Residuals 13 205.79   15.83
 
  Error: Within
Df Sum Sq Mean Sq F valuePr(F)
  spk3 29.425   9.808  9.4467 8.055e-05 ***
  spk: p   1  1.747   1.747  1.6821 0.2022649
  spk: q   1 13.572  13.572 13.0719 0.0008479 ***
  spk: r   1 14.106  14.106 13.5861 0.0006915 ***
  Residuals 39 40.493   1.038
  ---
  Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
 
 
 
  Spk.df - data.frame(sub,spk,erp)
  subset(Spk.df, subset=(sub!=14oddball  sub!=18odd  sub!=19odd 
  sub!=20oddball)) - Spk.selected.df
  contrasts(Spk.selected.df$spk) - contr.sdif(4)
  aov(erp ~ spk + Error(sub), data=Spk.selected.df) - Spk.aov
  summary(Spk.aov,data=Spk.selected.df,split=list(spk=list(p=1,q=2,r=3)))
 
  this is the the beginning of the dataframe, which I use:
   sub  spkerp
  1  10oddball spk1  2.587
  2  11oddball spk1 -0.335
  3  12oddball spk1  5.564
  5  15oddball spk1  0.691
  6  17oddball spk1 -1.846
  10 21oddball spk1  1.825
  11 22oddball spk1  0.370
  12  2oddball spk1  3.234
  13  3oddball spk1  1.462
  14  5oddball spk1  2.535
  15  6oddball spk1  9.373
  16  7oddball spk1  2.132
  17  8oddball spk1 -0.518
  18  9oddball spk1  2.450
  19 10oddball spk2  2.909
  20 11oddball spk2  0.708
  21 12oddball spk2  4.684
  23 15oddball spk2  3.599
  ...
 
  __
  [EMAIL PROTECTED] mailing list
  https://www.stat.math.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide!
  http://www.R-project.org/posting-guide.html

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] newbie question on contrasts and aov

2004-01-11 Thread Wolfgang Pauli
I try to move from SPSS to R/S and am trying to reproduce the results of SPSS 
in R. I calculated a one-way anova with spk as experimental factor and erp 
as depended variable. 
The result of the Anova are the same concearning the mean square, F and p 
values. But I also wanted to caculate the contr.sdif(4) contrast on spk. The 
results are completely different now. I hope anybody can help me.

Thanks, Wolfgang

This is what I get in SPSS:
Tests of Within-Subjects Contrasts
Measure: MEASURE_1 
Source  SPKType III Sum of Squares  df  Mean Square F   Sig.
SPK Level 2 vs. Level 1 3,493   1   3,493   2,026   ,178
Level 3 vs. Previous20,358  1   20,358  10,168  ,007
Level 4 vs. Previous18,808  1   18,808  15,368  ,002
Error(SPK)  Level 2 vs. Level 1 22,414  13  1,724   
Level 3 vs. Previous26,030  13  2,002  
 
Level 4 vs. Previous15,911  13  1,224  
 

This is the result in R:
Error: sub
  Df Sum Sq Mean Sq F value Pr(F)
Residuals 13 205.79   15.83

Error: Within
  Df Sum Sq Mean Sq F valuePr(F)
spk3 29.425   9.808  9.4467 8.055e-05 ***
spk: p   1  1.747   1.747  1.6821 0.2022649
spk: q   1 13.572  13.572 13.0719 0.0008479 ***
spk: r   1 14.106  14.106 13.5861 0.0006915 ***
Residuals 39 40.493   1.038
---
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1



Spk.df - data.frame(sub,spk,erp)
subset(Spk.df, subset=(sub!=14oddball  sub!=18odd  sub!=19odd  
sub!=20oddball)) - Spk.selected.df
contrasts(Spk.selected.df$spk) - contr.sdif(4)
aov(erp ~ spk + Error(sub), data=Spk.selected.df) - Spk.aov
summary(Spk.aov,data=Spk.selected.df,split=list(spk=list(p=1,q=2,r=3)))

this is the the beginning of the dataframe, which I use:
 sub  spkerp
1  10oddball spk1  2.587
2  11oddball spk1 -0.335
3  12oddball spk1  5.564
5  15oddball spk1  0.691
6  17oddball spk1 -1.846
10 21oddball spk1  1.825
11 22oddball spk1  0.370
12  2oddball spk1  3.234
13  3oddball spk1  1.462
14  5oddball spk1  2.535
15  6oddball spk1  9.373
16  7oddball spk1  2.132
17  8oddball spk1 -0.518
18  9oddball spk1  2.450
19 10oddball spk2  2.909
20 11oddball spk2  0.708
21 12oddball spk2  4.684
23 15oddball spk2  3.599
...

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Newbie question

2003-11-16 Thread Gopal Annasundaram
I'm trying to find a good open source software to do sales forecasting using Holt 
Winters and Box Jenkins time series algorithm. Somebody pointed me that R is the best 
open source available for statistical computing. Are there functions to do Holt 
Winters and Box Jenkins time series prediction in R? If there is none, can some one 
point me a good GNU/freeware to do the sales forecasting using the above algorithms?


Appreciate your help.

Thanks,
Gopal

[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Newbie question

2003-11-16 Thread Dirk Eddelbuettel
On Sun, Nov 16, 2003 at 07:25:14PM -0800, Gopal Annasundaram wrote:
 I'm trying to find a good open source software to do sales forecasting using Holt 
 Winters and Box Jenkins time series algorithm. Somebody pointed me that R is the 
 best open source available for statistical computing. Are there functions to do Holt 
 Winters and Box Jenkins time series prediction in R? If there is none, can some one 
 point me a good GNU/freeware to do the sales forecasting using the above algorithms?

Try help(library=ts) once you have a prompt. R does both Holt-Winters and
Arima.  Using ts objects is not entirely trivial, though.

Dirk

-- 
Those are my principles, and if you don't like them... well, I have others.
-- Groucho Marx

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Newbie question

2003-11-16 Thread Spencer Graves
R can apparently handle it, according to www.r-project.org - search 
- R site search. 

hope this helps.  spencer graves

Gopal Annasundaram wrote:

I'm trying to find a good open source software to do sales forecasting using Holt Winters and Box Jenkins time series algorithm. Somebody pointed me that R is the best open source available for statistical computing. Are there functions to do Holt Winters and Box Jenkins time series prediction in R? If there is none, can some one point me a good GNU/freeware to do the sales forecasting using the above algorithms?

Appreciate your help.

Thanks,
Gopal
	[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] newbie question: fitting power law

2003-08-14 Thread Douglas Bates
Thomas Hoffmann [EMAIL PROTECTED] writes:

 Dear R-helpers, dear Andrew
 
 Andrew C. Ward schrieb:
 
 Dear Thomas,
 
  I wonder if you have any NAs in xy$x or xy$y.
 
 The Dataframe looks like the following:
   xy
x  y
 1 3.0  121.50951
 2 2.0   30.61258
 3 4.0  323.14837
 4 8.2 3709.92471
 For testing reasons I calculated y by:
   y - 2.9 x^3.4

Did you read the help page for nls that emphasizes

 *Do not use 'nls' on artificial zero-residual data.*

and explains why?

In any case, the best way to fit such a model to these data is to use
the plinear algorithm for partially linear models.  Either

 nls(y ~ x^exp(logpow), data=xy, start = c(logpow=0.1), alg='plinear',trace = TRUE)
2661838 :   0.1000 281.0589 
87270.38 :  0.9550582 15.4392528 
1573.086 : 1.181199 3.903272 
1.645442 : 1.222351 2.929585 
2.301169e-06 : 1.223774 2.900035 
1.483770e-11 : 1.223775 2.90 
1.483769e-11 : 1.223775 2.90 
Nonlinear regression model
  model:  y ~ x^exp(logpow) 
   data:  xy 
  logpow .lin 
1.223775 2.90 
 residual sum-of-squares:  1.483769e-11 

or

 nls(y ~ exp(log(x) * pow), data=xy, start = c(pow=1.1), alg = 'plinear', trace = 
 TRUE)
2684530 :   1.1000 283.5010 
408828.2 :  2.045211 47.930710 
3.73 : 2.848788 9.185464 
857.465 : 3.293871 3.622750 
1.307911 : 3.395685 2.926367 
3.723389e-06 : 3.33 2.900044 
1.483772e-11 : 3.4 2.9 
1.483769e-11 : 3.4 2.9 
Nonlinear regression model
  model:  y ~ exp(log(x) * pow) 
   data:  xy 
 pow .lin 
 3.4  2.9 
 residual sum-of-squares:  1.483769e-11 

 Also, I think
 you could take logs of your equation and end up with a
 linear expression?
 
 if I use:
 
 plot (x,y)
 abline lm ( log(y)~log(x),xy)
 
 the line does not seem to fit the plotted datapoints at all. While the
 fitted exponent seems to be okay, the obtained intercept value is
 wrong.

That's because your plot is in the x,y scale and the line is in the
log(x), log(y) scale.  You need to convert back to the original scale
to put the line on the plot.

-- 
Douglas Bates[EMAIL PROTECTED]
Statistics Department608/262-2598
University of Wisconsin - Madisonhttp://www.stat.wisc.edu/~bates/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] newbie question: fitting power law

2003-08-14 Thread Thomas Hoffmann
Dear R-Helpers,

I try  to fit my x and y vector-data with a power law using a the 
following command:

test - nls(y ~ A*x^B, xy, start=list(A=0.5,B=0.8))

and I get the error message:

Error in numericDeriv(form[[3]], names(ind), env) :
   Missing value or an Infinity produced when evaluating the model
Does anybody know whats wrong? (it´s probably a simple newbie-error)

Thanks in advance

Thomas H.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] newbie question: fitting power law

2003-08-08 Thread Thomas Hoffmann
Dear R-helpers, dear Andrew

Andrew C. Ward schrieb:

Dear Thomas,

I wonder if you have any NAs in xy$x or xy$y. 

The Dataframe looks like the following:
 xy
  x  y
1 3.0  121.50951
2 2.0   30.61258
3 4.0  323.14837
4 8.2 3709.92471
For testing reasons I calculated y by:
 y - 2.9 x^3.4
Also, I think
you could take logs of your equation and end up with a
linear expression?
if I use:

plot (x,y)
abline lm ( log(y)~log(x),xy)
the line does not seem to fit the plotted datapoints at all. While the 
fitted exponent seems to be okay, the obtained intercept value is wrong.

Thanks for your answer.

Thomas H.

 

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] newbie question on dist

2002-12-19 Thread Saurav Pathak
hi,

i have just begun using R, so please bear with me.

i am trying to use cmdscale and display the result.  i read the data
using read.table(), calculate the proximity matrix using dist() and
the display the result using the cmdscale().  this is very fine.

in addition, i want the display to distinguish between two classes
of records in my data.  i have my data records marked as 1 or 0.
so i want to display 1's and 0's.  how may i do that?

i use the following code:


 fj - read.table(fj)
  names(fj)
[1] V1 V2 V3 V4 V5 # V5 contains the class mark (1 or 0)
 #
 # since i dont want the class attribute in the distance matrix
 # i create another data.frame dropping it.  but how do i pass it
 # so that I may use it while plotting?
 fjN - data.frame(V1=fj$V1, V2=fj$V2, V3=fj$V3, V4=fj$V4)
 library(mva)
 fjNDist - dist(fjN, method=euclidean)
 fjCMDS - cmdscale(fjNDist)
 plot(x, y, type=n, main=cmdscale(fjNDist))
 text(x, y, ., cex=0.8)


any help will be much appreciated.

thanks,
saurav

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help