Re: [R] problem for installing rgdal

2012-07-10 Thread Prof Brian Ripley

On 10/07/2012 17:35, stanislas rebaudet wrote:

Hello,

I run [R] 2.14 on Mac OS 10.6 and I've been desperately trying to install rpy2 
in order to compute spatial statistics on QGIS 1.7.3.
rpy2 is dependent upon the rgdal [R]package that I've been unable to install in 
spite of up to date versions of GDAL and PROJ.
More precisely, [R] console writes "Error: gdal-config not found". As a matter of fact, 
typing "gdal.config" on a Terminal shell doesn't work either...

Yet, the file is actually present in 
/Library/Frameworks/GDAL.framework/Versions/1.9/Programs
I then tryed to follow suggestions with:  
--configure-args='--with-gdal-config=/Library/Frameworks/GDAL.framework/Versions/1.9/Programs/gdal-config'
I received "no such file or directory"

I also found this option described here 
(http://www.r-bloggers.com/installing-rgdal-on-mac-os-x-2/), but couldn't get 
through it...



First, there is an OS X binary available for rgdal.

Second, please ask either on R-sig-mac (this is Mac-specific) or 
R-sig-geo (which is the list for that specific packages) about how to 
install from source on OS X if you really need to.



As anyone an idea?
Thanks for your help

stan

[[alternative HTML version deleted]]



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


PLEASE do (and note what it says about HTML mail).

--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] How to connect .mdb file

2012-07-10 Thread Mikhail Titov
imnew  writes:

> Hi, I'm currently having some problem connect .mdb file into R. 
> I've installed the RODBC packages and I do the code this way: 
>
> channel <- odbcConnectAccess("C:/Users/Documents/XYZ")
>
> I have a total of 5 tables in the .mdb database. any one can help me with
> how to get the tables in ?

You are one step away. Use sqlFetch(channel, "table_name") to fetch a
table into a data.frame as is. Or use sqlQuery(channel, sql) . Lookup
those functions in the manual.

-- 
Mikhail

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


Re: [R] Extracting arithmetic mean for specific values from multiple .txt-files

2012-07-10 Thread vimmster
Dear Rui,

1) With test subject I mean each file (I have posted three similar files
above (2, 50 and 1112), but each test subject has one exact file (which
differs of course! --> 2, 50 an 1112 are the same file but I renamed it for
the problem described ans solved above). In this file the vpNum is always
the same (for each test subject of course; example: for test subject 44 it
is always vpNum = 44). The examples above (2, 50 and 1112) are in fact all
the second test subject's file (vpNum always "2").

2) With "trials" or "trialCount" I mean the number of trials (149 in your
example, and 151 in the examples 2, 50 and 1112). But the number of trials
differs between subjects, because in the examples below (vpNum = 3, 43 and
63) it is 152 (for vpNum = 3), 150 (for vpNum = 43) and 157 (for vpNum =
63).

http://r.789695.n4.nabble.com/file/n4636106/XYZ_3.txt XYZ_3.txt 
http://r.789695.n4.nabble.com/file/n4636106/XYZ_43.txt XYZ_43.txt 
http://r.789695.n4.nabble.com/file/n4636106/XYZ_63.txt XYZ_63.txt 

3) I mean the number of correct answers given per test subject (for example
for test subject 3 in the previous example (5 rows above) we have 152 trials
and 4 trials that are not correct, which means 148 correct trials (with the
categorical value "1")). So in R this would be the ratio of:
> 148/152
[1] 0.9736842

The wanted output should (if possible) look like this (here only for vpNum =
3 !!!):
vpNum trial OR trialCount correct (reactions) ratio (which means: number
correct / trialCount)
3  152  148 
0.9736842

The final output should look like this:
vpNum trial OR trialCount correct (reactions) ratio (which means: number
correct / trialCount)
1  n  n 
 
x
2  n  n 
 
x
3  152  148 
 
0.9736842
and so on until vpNum = 65 (In my question before I forgot to ask for the
column "vpNum", sorry about that!).

I hope this makes it more clear!

Thanks for your time and help!

Kind regards 

--
View this message in context: 
http://r.789695.n4.nabble.com/Extracting-arithmetic-mean-for-specific-values-from-multiple-txt-files-tp4635809p4636106.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] combining numeric vector and column in a data frame

2012-07-10 Thread Rui Barradas

Hello,

Here are two ways of doing it.


df1 <- read.table(text="
fileNametype   status
b   N   alive
a   Tdead
d   N   alive
c   T   dead
f   Nalive
e  Tdead
", header=TRUE)
df1

my.numeric.vec <- scan(text="2 1 4 9 10 3")
names(my.numeric.vec) <- letters[1:6]

# A way
j <- df1
j$my.numeric.vec <- sapply(df1$f, function(y)
my.numeric.vec[ names(my.numeric.vec) %in% y ])
j  # See it

# Another way
merge(df1, data.frame(fileName=names(my.numeric.vec), 
my.numeric.vec=my.numeric.vec))



Hope this helps,

Rui Barradas

Em 10-07-2012 23:38, Adrian Johnson escreveu:

Hi:
I am trying to map column names of a matrix to another data frame and
get values in a different column of data frame


I have a matrix m.


my.numeric vec <- m[1,]



my.numeric.vec

a b cd   ef
2 1 49   10  3



##  my data frame = df1


df1


fileNametype   status
b   N   alive
a   Tdead
d   N   alive
c   T   dead
f   Nalive
e  Tdead


I want to combine as.numeric.vec and df1 and create j with correct
filename and type and numeric value


j


my.numeric.vectype
a 2   T
b 1  N
c 4  T
d 9  N
e 10 T
f 3  N

How can I combine my.numeric.vec and df1$type

when I try:

df1[df1$fileName %in% names(my.numeric.vec),2]

I get wrong answer.


thanks in advance.

Adrian

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



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


Re: [R] How to connect .mdb file

2012-07-10 Thread Jeff Newmiller
Are you sure XYZ is the name of the MDB file? Perhaps you are being fooled by 
the default filename display that omits the extension?
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

imnew  wrote:

>Hi, I'm currently having some problem connect .mdb file into R. 
>I've installed the RODBC packages and I do the code this way: 
>
>channel <- odbcConnectAccess("C:/Users/Documents/XYZ")
>channel
>
>and it gave me this :
>RODBC Connection 3
>Details:
>case=nochange
>DBQ=C:\USers\JieYi\Documents\NYP\IPP\GCR
>Driver={Microsoft Access Driver (*.mdb)}
>DriverId=25
>FIL=MS Access
>MaxBufferSize=2048
>PageTimeout=5
>UID=admin
>
>I have a total of 5 tables in the .mdb database. any one can help me
>with
>how to get the tables in ?
>
>--
>View this message in context:
>http://r.789695.n4.nabble.com/How-to-connect-mdb-file-tp4636083.html
>Sent from the R help mailing list archive at Nabble.com.
>
>__
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] HELP me please with import of csv to R

2012-07-10 Thread R. Michael Weylandt
On Tue, Jul 10, 2012 at 4:23 PM, FJ M  wrote:

> 3) attach the data so that the headers become objects that contain the data
> attach(v_data)

This is a discouraged practice as it leads to difficult to trace
errors and non-local effects. Some "big names" of the R universe
suggest it [I think V of V&R mentioned it in Nashville] but others are
just as strongly against, particularly for beginners.

Beter is to make use of formula= and data= arguments when available,
and with/within elsewise.

Best,
Michael

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


Re: [R] The following object(s) are masked from ‘package:stats’

2012-07-10 Thread Charlie Friedemann
David,

That message is not an error. It is simply telling you that there are
functions named qqnorm an qqplot in the extRemes package that are "masking"
functions of the same name in the stats package. Functions in a package
being loaded with the same names as functions in a package already loaded
will mask those previously loaded functions.

This means that if you call qqplot() or qqnorm() you will be using the
versions found in the extRemes package.  If you wanted to use the version of
qqplot in stats, you would have to call it by qualifying the namespace:

stats::qqplot

In any case, the package extRemes is loading properly for you and you can
begin to use it.

--
View this message in context: 
http://r.789695.n4.nabble.com/The-following-object-s-are-masked-from-package-stats-tp4636079p4636085.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] The following object(s) are masked from ‘package:stats’

2012-07-10 Thread David
My apologies in advance as this seem like an easy thing to fix.

I am quite new to using R. I am doing my thesis at the moment and I am
trying to use the extremes package. However, when I try to access it I get
this message:

The following object(s) are masked from ‘package:stats’:
> library( extRemes)
Loading required package: tcltk
Loading Tcl/Tk interface ... done
Loading required package: ismev
Loading required package: Lmoments
Attaching package: ‘extRemes’
The following object(s) are masked from ‘package:stats’:
qqnorm, qqplot

I looked back on some of the older post about this problem. Apparently it
has something to do with the order of the packages.

> search()
 [1] ".GlobalEnv""package:extRemes"  "package:Lmoments" 
"package:ismev" "package:tcltk" "package:stats"
"package:graphics"  "package:grDevices"
 [9] "package:utils" "package:datasets"  "package:methods"   "Autoloads"

"package:base" 
> attach(stats)
Error in attach(stats) : object 'stats' not found

However, I still could not get it working.

Thanks for any help in advance
David



--
View this message in context: 
http://r.789695.n4.nabble.com/The-following-object-s-are-masked-from-package-stats-tp4636079.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to use external image with R plot?

2012-07-10 Thread Manish Gupta
Hi, 

I need to position arrow according to content of data dynamically. let's say
i have vector c(2,3,56,9) and i need to put arrow at 56 dynamically.  How
can i use above method.

Regards

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-use-external-image-with-R-plot-tp4635959p4636088.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Read vector as multi-dimensional data in R by row

2012-07-10 Thread arun
Hi HJ,

No problem.

By changing the order of numbers in both perm and dim, you can create different 
combinations
A.K.



- Original Message -
From: "yhj...@googlemail.com" 
To: arun 
Cc: 
Sent: Tuesday, July 10, 2012 7:25 PM
Subject: Re: [R] Read vector as multi-dimensional data in R by row

Dear arun,

That code works. Thanks so much for the hints!

Best wishes,
HJ


Sent using BlackBerry® from Orange

-Original Message-
From: arun 
Date: Mon, 9 Jul 2012 22:12:03 
To: HJ YAN
Reply-To: arun 
Cc: R help
Subject: Re: [R] Read vector as multi-dimensional data in R by row

Hi,

Try this:
b1<-aperm(array(a,dim=c(5,2,2)),perm=c(2,1,3))
> b1
, , 1

 [,1] [,2] [,3] [,4] [,5]
[1,]    1    2    3    4    5
[2,]    6    7    8    9   10

, , 2

 [,1] [,2] [,3] [,4] [,5]
[1,]   11   12   13   14   15
[2,]   16   17   18   19   20

A.K.



- Original Message -
From: HJ YAN 
To: r-help@r-project.org
Cc: 
Sent: Monday, July 9, 2012 7:25 PM
Subject: [R] Read vector as multi-dimensional data in R by row

Dear R users


Say I wanted to read a vector into R as multi-dimensional array by row,
e.g.

a<-c(1:20)

> b<-array(a,dim=c(2,5,2))
> b
, , 1

     [,1] [,2] [,3] [,4] [,5]
[1,]    1    3    5    7    9
[2,]    2    4    6    8   10

, , 2

     [,1] [,2] [,3] [,4] [,5]
[1,]   11   13   15   17   19
[2,]   12   14   16   18   20


But actually I wanted...

     [,1] [,2] [,3] [,4] [,5]
[1,]    1    2    3    4    5
[2,]    6    7    8    9   10

, , 2

     [,1] [,2] [,3] [,4] [,5]
[1,]   11   12   13   14   15
[2,]   16   17   18   19   20


I checked '?array' but there is not an argument or something  like
'byrow=T' as the one in 'matrix'.

Could anyone help please?

Many thanks in advance!

HJ

    [[alternative HTML version deleted]]

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

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


[R] How to connect .mdb file

2012-07-10 Thread imnew
Hi, I'm currently having some problem connect .mdb file into R. 
I've installed the RODBC packages and I do the code this way: 

channel <- odbcConnectAccess("C:/Users/Documents/XYZ")
channel

and it gave me this :
RODBC Connection 3
Details:
case=nochange
DBQ=C:\USers\JieYi\Documents\NYP\IPP\GCR
Driver={Microsoft Access Driver (*.mdb)}
DriverId=25
FIL=MS Access
MaxBufferSize=2048
PageTimeout=5
UID=admin

I have a total of 5 tables in the .mdb database. any one can help me with
how to get the tables in ?

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-connect-mdb-file-tp4636083.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] -1.1 - 0.1 + 1.2 is NOT null! Why?

2012-07-10 Thread arun
Hi,

Perl:
perl -e 'print -1.1-0.1+1.2. "\n";'
-2.22044604925031e-16
perl -e 'print -1.2-0.2+1.4. "\n";'
0


A.K.




- Original Message -
From: massimodisasha 
To: ollestrat ; r-help@r-project.org
Cc: 
Sent: Tuesday, July 10, 2012 6:23 PM
Subject: Re: [R] -1.1 - 0.1 + 1.2 is NOT null! Why?

Il 7/10/12 4:17 PM, ollestrat ha scritto:
> Hello,
>
> I fear its a stupid question,..but here it is:
>
> If I do this simple calculation with the R  console, I surprisingly do not
> get a zero. Why?
>
>   -1.1-0.1+1.2
> [1] -2.220446e-16
>
>
> greetings, Ole
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/1-1-0-1-1-2-is-NOT-null-Why-tp4636053.html
> Sent from the R help mailing list archive at Nabble.com.
>     [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
...

Python :
>>> -1.1-0.1+1.2
-2.220446049250313e-16
>>> -1.2-0.2+1.4
0.0
>>>

R :
> -1.1-0.1+1.2
[1] -2.220446e-16
> -1.2-0.2+1.4
[1] 0
>

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


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


Re: [R] combining numeric vector and column in a data frame

2012-07-10 Thread arun
Hi Try this:
df1<-read.table(text="
 fileName    type  status
 b  N  alive
 a  T    dead
 d  N  alive
 c  T  dead
 f  N    alive
 e  T    dead
 ",sep="",header=TRUE)
mynumeric.vec<-c(a=2,b=1,c=4,d=9,e=10,f=3)
mynumeric.df<-data.frame(key=names(mynumeric.vec),Val=mynumeric.vec)
 j<-merge(df1,mynumeric.df,by.x="fileName",by.y="key")
 j<-j[,c(1,4,2)]

colnames(j)<-c("fileName","mynumeric.vec","type")
 j
  fileName mynumeric.vec type
1    a 2    T
2    b 1    N
3    c 4    T
4    d 9    N
5    e    10    T
6    f 3    N


A.K.




- Original Message -
From: Adrian Johnson 
To: r-help 
Cc: 
Sent: Tuesday, July 10, 2012 6:38 PM
Subject: [R] combining numeric vector and column in a data frame

Hi:
I am trying to map column names of a matrix to another data frame and
get values in a different column of data frame


I have a matrix m.

> my.numeric vec <- m[1,]

> my.numeric.vec
a     b     c    d   e    f
2     1     4    9   10  3



##  my data frame = df1

> df1

fileName    type   status
b               N       alive
a               T        dead
d               N       alive
c               T       dead
f               N        alive
e              T        dead


I want to combine as.numeric.vec and df1 and create j with correct
filename and type and numeric value

>j

my.numeric.vec    type
a 2   T
b 1  N
c 4  T
d 9  N
e 10 T
f 3  N

How can I combine my.numeric.vec and df1$type

when I try:

df1[df1$fileName %in% names(my.numeric.vec),2]

I get wrong answer.


thanks in advance.

Adrian

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


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


Re: [R] R-help Digest, Vol 113, Issue 13

2012-07-10 Thread Terry Therneau
 Re: Skipping lines and incomplete rows (arun)
   61. Re: calculating the difference between days? (arun)
   62. Re: estimation of NA by predict command (eliza botto)
   63. Times Series Data using GLS (MRB305)
   64. Need HELP: how find and use a csv file? (Faradj Koliev)
   65. Re: estimation of NA by predict command (arun)
   66. Changing x-axis values displayed on histogram (jlwoodard)
   67. Re: Package 'MASS' (polr): Error in svd(X) : infinite or
   missing values in 'x' (Rune Haubo)
   68. Re: HELP me please with import of csv to R (Sarah Goslee)
   69. Understanding cenros Error (Rich Shepard)
   70. Re: Need HELP: how find and use a csv file? (Sarah Goslee)
   71. Re: calculating the difference between days? (C W)
   72. Re: Need HELP: how find and use a csv file? (Rich Shepard)
   73. Re: calculating the difference between days? (C W)
   74. Re: Changing x-axis values displayed on histogram (Sarah Goslee)
   75. Re: Use of Sappy and Tappy for Mathematical Calculation
   (R. Michael Weylandt)
   76. Re: calculating the difference between days? (Jorge I Velez)
   77. Re: Specify model with polynomial interaction terms up   to
   degree n (William Dunlap)
   78. Re: Changing x-axis values displayed on histogram (jlwoodard)
   79. Re: R code help to change table format (Rui Barradas)
   80. Re: Need HELP: how find and use a csv file?
   (R. Michael Weylandt)
   81. Re: Need HELP: how find and use a csv file? (mlell08)
   82. Re: Mann-Whitney by group (Oxenstierna)
   83. Download large file from https url with progress meter
   (Gregory Jefferis)
   84. -1.1 - 0.1 + 1.2 is NOT null! Why? (ollestrat)
   85. Re: estimation of NA by predict command (eliza botto)
   86. Re: -1.1 - 0.1 + 1.2 is NOT null! Why? (Richard M. Heiberger)
   87. Re: -1.1 - 0.1 + 1.2 is NOT null! Why? (William Dunlap)


--

Message: 1
Date: Tue, 10 Jul 2012 18:11:53 +0800
From: Jie Tang
To: r-help@r-project.org
Subject: [R] how can I show the xlab and ylab information while using
layout
Message-ID:

Content-Type: text/plain; charset="iso-8859-1"

hi  R-users:
   I want to draw three plot into one figure by layout and the script has
been shown below.
  But I find R does  not show  the xlab and ylab information  completely as
shown the figure attached.
How can I midify the script.? thank you .

xxlab<-paste(cpmd," (",ro,"%)",sep=" ")
yylab<-paste(rfmd," (",co,"%)",sep=" ")
par(mar=c(3,3,1,1))
#layout(matrix(c(2,0,1,3),2,2,byrow=TRUE),widths=lcm(30),
heights=lcm(25),TRUE)
layout(matrix(c(2,0,1,3),2,2,byrow=TRUE),c(5,1),c(1,5),TRUE)
layout.show(3)
plot(data_cpmd,data_rfmd,xlab=xxlab,ylab=yylab,xlim=XX,ylim=YY,asp=1)
abline(1,1)
#rug(side=1,jitter(data_cpmd,5))
#rug(side=2,jitter(data_rfmd,5))
#plot(homo_ana$dism16cpmd,homo_ana$dism16rfmd,main=mtitle,xlab=xxlab,ylab=yylab,xlim=XX,ylim=YY,asp=1)

par(mar=c(0,3,1,1))
barplot(data_cpmd, axes=FALSE, ylim=YY, space=0)
par(mar=c(3,0,1,1))
barplot(data_rfmd, axes=FALSE,main=mtitle, xlim=XX, space=0, horiz=TRUE)

#boxplot(data_cpmd,horizontal = TRUE,xlim=XX,ylim=YY,outline=ifout, xaxt =
"n")
#par(mar=c(3,0,1,1))
#boxplot(data_rfmd,xlim=XX,ylim=YY,outline=ifout,yaxt = "n")
-- next part --
A non-text attachment was scrubbed...
Name: homo_jawt_pgtwhr24.png
Type: image/png
Size: 9100 bytes
Desc: not available
URL:<https://stat.ethz.ch/pipermail/r-help/attachments/20120710/754cabcd/attachment-0001.png>

--

Message: 2
Date: Tue, 10 Jul 2012 06:58:20 -0400
From: Sarah Goslee
To: Jie Tang, r-help
Subject: Re: [R] how can I show the xlab and ylab information while
using   layout
Message-ID:

Content-Type: text/plain

The margins you specified aren't large enough to hold the information
you're trying to put in them, so you need to make them larger.

Sarah

On Tuesday, July 10, 2012, Jie Tang wrote:


hi  R-users:
   I want to draw three plot into one figure by layout and the script has
been shown below.
  But I find R does  not show  the xlab and ylab information  completely as
shown the figure attached.
How can I midify the script.? thank you .

xxlab<-paste(cpmd," (",ro,"%)",sep=" ")
yylab<-paste(rfmd," (",co,"%)",sep=" ")
par(mar=c(3,3,1,1))
#layout(matrix(c(2,0,1,3),2,2,byrow=TRUE),widths=lcm(30),
heights=lcm(25),TRUE)
layout(matrix(c(2,0,1,3),2,2,byrow=TRUE),c(5,1),c(1,5),TRUE)
layout.show(3)
plot(data_cpmd,data_rfmd,xlab=xxlab,ylab=yylab,xlim=XX,ylim=YY,asp=1)
abline(1,1)
#rug(side=1,jitter(data_cpmd,5))
#rug(side=2,jitter(data_rfmd,5))

#plot(homo_ana$dism16cpmd,homo_ana$dism16rfmd,main=mtitle,xlab=xxlab,ylab=yylab,xlim=XX,ylim=YY,asp=1)

par(mar=c(0,3,1,1))
barplot(data_cpmd, axes=FALSE, ylim=YY, space=0)
par(mar=c(

Re: [R] RGL 3D curvilinear shapes

2012-07-10 Thread PatGauthier
Well I've figures out a painful way of doing it with triangles 3d, as
suggested in another post by Duncan Murdoch. 

The code is disgusting, but it works. 

x <- c(0,0.75,75.75,150.75,225.75,300.75,375.75,450.75,525.75,600.75,675.75,
675.75,0,
   0,0.5,50.5,100.5,150.5,200.5,250.5,300.5,350.5,400.5,450.5, 450.5,0,
  
0,0.25,25.25,50.25,75.25,100.25,125.25,150.25,175.25,200.25,225.25,225.25,0) 
y <- c(0,0.05,4.91,9.78,14.64,19.51,24.38,29.24,34.11,38.97,43.84, 43.84,0,
   0,0.1,9.83,19.56,29.29,39.02,48.75,58.48,68.21,77.94,87.67, 87.67,0,
   0,0.15,14.74,29.34,43.93,58.53,73.13,87.72,102.32,116.91,131.51,
131.51,0) 
z <- c(0,0.05,0.55,0.7,0.78,0.83,0.87,0.9,0.92,0.93,0.94,0.0,0,
   0,0.32,0.59,0.77,0.87,0.93,0.96,0.98,0.99,1,0,0,0,
   0,0.39,0.66,0.82,0.9,0.95,0.97,0.99,0.99,1,0,0,0) 

dat <- data.frame(x = x, y = y, z = z, ID = c(rep(c(1,2,3),each=13))) 

x1 <- x[1:13]
y1 <- y[1:13]
z1 <- z[1:13]

x2 <- x[14:26]
y2 <- y[14:26]
z2 <- z[14:26]

x3 <- x[27:39]
y3 <- y[27:39]
z3 <- z[27:39]  

t1 <- triangulate(as(cbind(x1,z1), "gpc.poly"))
t2 <- triangulate(as(cbind(x2,z2), "gpc.poly"))
t3 <- triangulate(as(cbind(x3,z3), "gpc.poly"))

yfit1 <- predict(lm(y1~ x1 + z1), newdata = data.frame(x1 = t1[,1], z1 =
t1[,2]))
yfit2 <- predict(lm(y2~ x2 + z2), newdata = data.frame(x2 = t2[,1], z2 =
t2[,2]))
yfit3 <- predict(lm(y3~ x3 + z3), newdata = data.frame(x3 = t3[,1], z3 =
t3[,2]))

plot3d(dat, type = "n", ylab = "", xlab = "", zlab = "", axes = F, ylim =
c(0,200)) 
axes3d(edge = c("x--", "y-+", "z--"), nticks = 5, ylim = c(0,200)) 
bbox3d(color = c("black", "white"), lit = F, back = "line")

lines3d(x1, y1, z1)
lines3d(x2, y2, z2)
lines3d(x3, y3, z3)

triangles3d(x= t1[,1], y= yfit1, z= t1[,2], lit = F, col = "white", front =
"fill", lwd = 10)
triangles3d(x= t2[,1], y= yfit2, z= t2[,2], lit = F, col = "white", front =
"fill", lwd = 10)
triangles3d(x= t3[,1], y= yfit3, z= t3[,2], lit = F, col = "white", front =
"fill", lwd = 10)



PatGauthier wrote
> 
> 
> I'm trying to simply fill in the area under a curve using RGL. Here' the
> set up:
> 
> 
> 
> Any ideas/tips on how to do this?
> 
> 

PatGauthier wrote
> 
> Dear useRs, 
> 
> I'm trying to simply fill in the area under a curve using RGL. Here' the
> set up:
> 
> x <- c(0.75,75.75,150.75,225.75,300.75,375.75,450.75,525.75,600.75,675.75,
>0.5,50.5,100.5,150.5,200.5,250.5,300.5,350.5,400.5,450.5,
>0.25,25.25,50.25,75.25,100.25,125.25,150.25,175.25,200.25,225.25)
> y <- c(0.05,4.91,9.78,14.64,19.51,24.38,29.24,34.11,38.97,43.84,
>0.1,9.83,19.56,29.29,39.02,48.75,58.48,68.21,77.94,87.67,
>0.15,14.74,29.34,43.93,58.53,73.13,87.72,102.32,116.91,131.51)
> z <- c(0.05,0.55,0.7,0.78,0.83,0.87,0.9,0.92,0.93,0.94,
>0,0.32,0.59,0.77,0.87,0.93,0.96,0.98,0.99,1,
>0,0.39,0.66,0.82,0.9,0.95,0.97,0.99,0.99,1)
> 
> dat <- data.frame(x = x, y = y, z = z, ID = c(rep(c(1,2,3),each=10)))
> 
> plot3d(dat, type = "n", ylab = "", xlab = "", zlab = "", axes = F, ylim =
> c(0,200))
> lines3d(dat[1:10,])
> lines3d(dat[11:20,])
> lines3d(dat[21:30,])
> 
> axes3d(edge = c("x--", "y-+", "z--"), nticks = 5, ylim = c(0,200))
> bbox3d(color = c("black", "white"), lit = F, back = "line")
> 
> Any ideas/tips on how to do this?
> 
> thanks in advance, 
> 
> Patrick
> 

--
View this message in context: 
http://r.789695.n4.nabble.com/RGL-3D-curvilinear-shapes-tp4636011p4636057.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] -1.1 - 0.1 + 1.2 is NOT null! Why?

2012-07-10 Thread Erdal Karaca
german "Null" == english "zero" :-)

2012/7/10 Rolf Turner 

>
>
> In addition to taking cognisance of Richard Heiberger's reply you
> should also learn to distinguish between the concept of "null" and
> "zero".  They are not at all the same thing.
>
> cheers,
>
> Rolf Turner
>
>
> On 11/07/12 08:17, ollestrat wrote:
>
>> Hello,
>>
>> I fear its a stupid question,..but here it is:
>>
>> If I do this simple calculation with the R  console, I surprisingly do not
>> get a zero. Why?
>>
>>   -1.1-0.1+1.2
>> [1] -2.220446e-16
>>
>>
>> greetings, Ole
>>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] HELP me please with import of csv to R

2012-07-10 Thread FJ M

Try putting the data into some kind of object. I'm not sure what R does with 
the data from read.csv. I always
 
1) read the data into an object
2) print the data out
3) attach the data so that the headers become objects that contain the data
4) and yes, print the data out using ls
5) check the output file just in case one of 1-4 throw an error.
 
 
v_data <- 
read.table("C:\\Users\\Frank\\Options\\CBOE\\VZ\\2012\\VZ_2012_03_Summary_V0_R.TXT",header=T)
v_data
attach(v_data)
ls(v_data)
 

GL
 
Frank
Chicago, IL
 
 
> Date: Tue, 10 Jul 2012 09:48:04 -0700
> From: farad...@gmail.com
> To: r-help@r-project.org
> Subject: [R] HELP me please with import of csv to R
> 
> Hey, 
> 
> I am having problems with importing a csv file to R. 
> 
> I could read the file by typing: 
> read.csv(file="/Users/kama/Desktop/skatter.csv", header=TRUE, sep=";")
> 
> However, i can not analyze the "skatter" - for ex, when i type: skatter
> = read.csv("skatter.csv")
> 
> i get this message: 
> 
> Error in file(file, "rt") : cannot open the connection
> In addition: Warning message:
> In file(file, "rt") :
> 
> What i need is to import this file and analyze it using for example
> histogram. 
> 
> I have Mac(update) and the file is saved in csv file... and I'm quite new
> user of R. 
> 
> 
> 
> Thank you very much! 
> 
> 
> 
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/HELP-me-please-with-import-of-csv-to-R-tp4636019.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
  
[[alternative HTML version deleted]]

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


Re: [R] ifelse help

2012-07-10 Thread Jeff Newmiller
You failed to tell us any of: the actual code you used, the data you were 
working with, or the actual error you got. Your "pseudo-code" looks okay to me, 
so I suggest you read the Posting Guide and try again. (Anything other than a 
complete reproducible example of your problem is unlikely to elicit useful 
responses. Pseudo-code is definitely "other".)
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Jeff  wrote:

>
>I'm sure this is easy, but I'm new to R and can't find any example of 
>the following.
>
>Here's what I'm trying to do in pseudo-code.
>
>data$newvar <- ifelse(data$oldvar1 == 8, 1,data$oldvar2)
>
>In other words, if the existing variable equals 8, then the new 
>variable should equal 1, otherwise the new variable should equal the 
>value of another existing variable.
>
>I've tried to follow the examples given on the web and in the R 
>manuals, and each time I get errors or unexpected values.
>
>Thanks
>
>Jeff
>
>__
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] ifelse help

2012-07-10 Thread Jeff

At 07:41 PM 7/10/2012, you wrote:


Seems to work for me:

> x <- data.frame(old1 = sample(c(1,2,8), 10, TRUE), old2 = 1:10)
> x$new <- ifelse(x$old1 == 8, 1, x$old2)
> x



Thanks Jim and Dan. The problem ended up with a missing values issue 
that threw me off. When your post confirmed that my code was right 
all along, I finally figured out the real problem.


Jeff

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


Re: [R] ifelse help

2012-07-10 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Jeff
> Sent: Tuesday, July 10, 2012 5:26 PM
> To: r-help
> Subject: [R] ifelse help
> 
> 
> I'm sure this is easy, but I'm new to R and can't find any example of
> the following.
> 
> Here's what I'm trying to do in pseudo-code.
> 
> data$newvar <- ifelse(data$oldvar1 == 8, 1,data$oldvar2)
> 
> In other words, if the existing variable equals 8, then the new
> variable should equal 1, otherwise the new variable should equal the
> value of another existing variable.
> 
> I've tried to follow the examples given on the web and in the R
> manuals, and each time I get errors or unexpected values.
> 
> Thanks
> 
> Jeff
> 

Rather than tell us that you tried some examples and they didn't work, show us 
what you tried (i.e. a reproducible example as requested in the posting guide) 
so that we can play along at home. :-)  

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204


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


Re: [R] ifelse help

2012-07-10 Thread jim holtman
Seems to work for me:

> x <- data.frame(old1 = sample(c(1,2,8), 10, TRUE), old2 = 1:10)
> x$new <- ifelse(x$old1 == 8, 1, x$old2)
> x
   old1 old2 new
1 11   1
2 22   2
3 23   3
4 84   1
5 15   5
6 86   1
7 87   1
8 28   8
9 29   9
101   10  10


On Tue, Jul 10, 2012 at 8:26 PM, Jeff  wrote:
>
> I'm sure this is easy, but I'm new to R and can't find any example of the
> following.
>
> Here's what I'm trying to do in pseudo-code.
>
> data$newvar <- ifelse(data$oldvar1 == 8, 1,data$oldvar2)
>
> In other words, if the existing variable equals 8, then the new variable
> should equal 1, otherwise the new variable should equal the value of another
> existing variable.
>
> I've tried to follow the examples given on the web and in the R manuals, and
> each time I get errors or unexpected values.
>
> Thanks
>
> Jeff
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

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


[R] ifelse help

2012-07-10 Thread Jeff


I'm sure this is easy, but I'm new to R and can't find any example of 
the following.


Here's what I'm trying to do in pseudo-code.

data$newvar <- ifelse(data$oldvar1 == 8, 1,data$oldvar2)

In other words, if the existing variable equals 8, then the new 
variable should equal 1, otherwise the new variable should equal the 
value of another existing variable.


I've tried to follow the examples given on the web and in the R 
manuals, and each time I get errors or unexpected values.


Thanks

Jeff

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


Re: [R] HELP me please with import of csv to R

2012-07-10 Thread peter dalgaard

On Jul 11, 2012, at 01:24 , Sarah Goslee wrote:

> That is silly, but I have learned something. Thanks.
> 
(The silliest bit was when someone decided that numeric data files should use 
locale-dependent conventions, notably decimal separators...)

> Though honestly, I've never seen the advantage of read.csv() over the more 
> versatile read.table().

It's mainly that other software likes to write such files, so it is convenient 
with a simple function to read them. Same thing with read.delim(). There's also 
a point in trying to get all settings right, especially quotes and comments can 
throw users off.

> 
> Sarah
> 
> On Tuesday, July 10, 2012, peter dalgaard wrote:
> 
> On Jul 10, 2012, at 21:44 , Sarah Goslee wrote:
> >
> > But note that if sep=";" then you don't have a csv file and should
> > properly use read.table() instead.
> 
> That's not actually true. In a substantial part of the world, csv files are 
> semicolon separated. That's what read.csv2() is for. (Yes, it is silly, 
> please don't get me started...)
> 
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Email: pd@cbs.dk  Priv: pda...@gmail.com
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> Sarah Goslee
> http://www.stringpage.com
> http://www.sarahgoslee.com
> http://www.functionaldiversity.org

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


Re: [R] HELP me please with import of csv to R

2012-07-10 Thread Sarah Goslee
That is silly, but I have learned something. Thanks.

Though honestly, I've never seen the advantage of read.csv() over the more
versatile read.table().

Sarah

On Tuesday, July 10, 2012, peter dalgaard wrote:

>
> On Jul 10, 2012, at 21:44 , Sarah Goslee wrote:
> >
> > But note that if sep=";" then you don't have a csv file and should
> > properly use read.table() instead.
>
> That's not actually true. In a substantial part of the world, csv files
> are semicolon separated. That's what read.csv2() is for. (Yes, it is silly,
> please don't get me started...)
>
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Email: pd@cbs.dk   Priv: pda...@gmail.com 
>
>
>
>
>
>
>
>
>

-- 
Sarah Goslee
http://www.stringpage.com
http://www.sarahgoslee.com
http://www.functionaldiversity.org

[[alternative HTML version deleted]]

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


[R] combining numeric vector and column in a data frame

2012-07-10 Thread Simon Knapp
combined <- data.frame(mnv=my.numeric.vec[df1$fileName], type=df1$type)
sorted <- combined[order(rownames(combined)),]




On Wed, Jul 11, 2012 at 8:38 AM, Adrian Johnson
 wrote:
> Hi:
> I am trying to map column names of a matrix to another data frame and
> get values in a different column of data frame
>
>
> I have a matrix m.
>
>> my.numeric vec <- m[1,]
>
>> my.numeric.vec
> a b cd   ef
> 2 1 49   10  3
>
>
>
> ##  my data frame = df1
>
>> df1
>
> fileNametype   status
> b   N   alive
> a   Tdead
> d   N   alive
> c   T   dead
> f   Nalive
> e  Tdead
>
>
> I want to combine as.numeric.vec and df1 and create j with correct
> filename and type and numeric value
>
>>j
>
> my.numeric.vectype
> a 2   T
> b 1  N
> c 4  T
> d 9  N
> e 10 T
> f 3  N
>
> How can I combine my.numeric.vec and df1$type
>
> when I try:
>
> df1[df1$fileName %in% names(my.numeric.vec),2]
>
> I get wrong answer.
>
>
> thanks in advance.
>
> Adrian
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Extracting arithmetic mean for specific values from multiple .txt-files

2012-07-10 Thread vimmster
Dear Rui,

1) With test subject I mean each file (I have posted three similar files
above (2, 50 and 1112), but each test subject has one exact file (which
differs of course! --> 2, 50 an 1112 are the same file but I renamed it for
the problem described ans solved above). In this file the vpNum is always
the same (for each test subject of course; example: for test subject 44 it
is always vpNum = 44). The examples above (2, 50 and 1112) are in fact all
the second test subject's file (vpNum always "2").

2) With "trials" or "trialCount" I mean the number of trials (149 in your
example, and 151 in the examples 2, 50 and 1112). But the number of trials
differs between subjects, because in the examples below (vpNum = 3, 43 and
63) it is 152 (for vpNum = 3), 150 (for vpNum = 43) and 157 (for vpNum =
63).

http://r.789695.n4.nabble.com/file/n4636074/Fluencyflanker_3.txt
Fluencyflanker_3.txt 
http://r.789695.n4.nabble.com/file/n4636074/Fluencyflanker_43.txt
Fluencyflanker_43.txt 
http://r.789695.n4.nabble.com/file/n4636074/Fluencyflanker_63.txt
Fluencyflanker_63.txt 

3) I mean the number of correct answers given per test subject (for example
for test subject 3 in the previous example (5 rows above) we have 152 trials
and 4 trials that are not correct, which means 148 correct trials (with the
categorical value "1")). So in R this would be the ratio of:
> 148/152
[1] 0.9736842

The wanted output should (if possible) look like this (here only for vpNum =
3 !!!):
vpNum   trial OR trialCount correct (reactions) ratio (which means: 
number
correct / trialCount)
3   152 148 
 0.9736842

The final output should look like this:
vpNum   trial OR trialCount correct (reactions) ratio (which means: 
number
correct / trialCount)
1n   n  
 x
2n   n  
 x
3152 148
 0.9736842
and so on until vpNum = 65 (In my question before I forgot to ask for the
column "vpNum", sorry about that!).

I hope this makes it more clear!

Thanks for your time and help!

Kind regards

--
View this message in context: 
http://r.789695.n4.nabble.com/Extracting-arithmetic-mean-for-specific-values-from-multiple-txt-files-tp4635809p4636074.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] combining numeric vector and column in a data frame

2012-07-10 Thread Adrian Johnson
Hi:
I am trying to map column names of a matrix to another data frame and
get values in a different column of data frame


I have a matrix m.

> my.numeric vec <- m[1,]

> my.numeric.vec
a b cd   ef
2 1 49   10  3



##  my data frame = df1

> df1

fileNametype   status
b   N   alive
a   Tdead
d   N   alive
c   T   dead
f   Nalive
e  Tdead


I want to combine as.numeric.vec and df1 and create j with correct
filename and type and numeric value

>j

my.numeric.vectype
a 2   T
b 1  N
c 4  T
d 9  N
e 10 T
f 3  N

How can I combine my.numeric.vec and df1$type

when I try:

df1[df1$fileName %in% names(my.numeric.vec),2]

I get wrong answer.


thanks in advance.

Adrian

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


[R] FastRWeb Examples

2012-07-10 Thread Roy Mendelssohn
Hi All:

I just got FastRWeb up and working, and I am hoping someone might have some 
example scripts that demonstrate some more complicate interactions between the 
URL and the service.  In particular, where multiple arguments are being passed 
to the function and one argument might be a URL itself  (that is a reference to 
another service, such as a data service), and both data and graphics might be 
passed back to the browser.

If this is the wrong mail-list to be be posting this, my apologies and I would 
appreciate being pointed to the correct one.

Thanks,

-Roy M.



**
"The contents of this message do not reflect any position of the U.S. 
Government or NOAA."
**
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
1352 Lighthouse Avenue
Pacific Grove, CA 93950-2097

e-mail: roy.mendelss...@noaa.gov (Note new e-mail address)
voice: (831)-648-9029
fax: (831)-648-8440
www: http://www.pfeg.noaa.gov/

"Old age and treachery will overcome youth and skill."
"From those who have been given much, much will be expected" 
"the arc of the moral universe is long, but it bends toward justice" -MLK Jr.

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


Re: [R] -1.1 - 0.1 + 1.2 is NOT null! Why?

2012-07-10 Thread massimodisasha

Il 7/10/12 4:17 PM, ollestrat ha scritto:

Hello,

I fear its a stupid question,..but here it is:

If I do this simple calculation with the R  console, I surprisingly do not
get a zero. Why?

  -1.1-0.1+1.2
[1] -2.220446e-16


greetings, Ole

--
View this message in context: 
http://r.789695.n4.nabble.com/1-1-0-1-1-2-is-NOT-null-Why-tp4636053.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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

...

Python :
>>> -1.1-0.1+1.2
-2.220446049250313e-16
>>> -1.2-0.2+1.4
0.0
>>>

R :
> -1.1-0.1+1.2
[1] -2.220446e-16
> -1.2-0.2+1.4
[1] 0
>

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


Re: [R] HELP me please with import of csv to R

2012-07-10 Thread peter dalgaard

On Jul 10, 2012, at 21:44 , Sarah Goslee wrote:
> 
> But note that if sep=";" then you don't have a csv file and should
> properly use read.table() instead.

That's not actually true. In a substantial part of the world, csv files are 
semicolon separated. That's what read.csv2() is for. (Yes, it is silly, please 
don't get me started...)

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


Re: [R] Mann-Whitney by group

2012-07-10 Thread R. Michael Weylandt
Untested, I think you need to lapply() over thing with some sort of extractor:

lapply(thing, function(x) x[['p.value']])

Michael

On Jul 10, 2012, at 3:45 PM, Oxenstierna  wrote:

> This works very well--thanks so much.
> 
> By way of extension:  how would one extract elements from the result object?
> 
> For example:
> 
> thing<=apply(Dtb[,3:10], 2, function(x) wilcox.test(x~Dtb$Group))
> 
> summary(thing)$p.value
> 
> Does not provide a list of p-values as it would in a regression object. 
> Ideally, I would like to be able to extract the W score and p-value by
> A,B,C,...
> 
> Any ideas greatly appreciated!
> 
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Mann-Whitney-by-group-tp4635618p4636055.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] -1.1 - 0.1 + 1.2 is NOT null! Why?

2012-07-10 Thread Rolf Turner

But R-ish NULL is *NOT* equal to R-ish zero, and that's
what counts here.

 cheers,

 Rolf Turner

On 11/07/12 09:19, Erdal Karaca wrote:
> german "Null" == english "zero" :-)
>
> 2012/7/10 Rolf Turner  >
>
>
>
> In addition to taking cognisance of Richard Heiberger's reply you
> should also learn to distinguish between the concept of "null" and
> "zero".  They are not at all the same thing.
>
> cheers,
>
> Rolf Turner
>
>
> On 11/07/12 08:17, ollestrat wrote:
>
> Hello,
>
> I fear its a stupid question,..but here it is:
>
> If I do this simple calculation with the R  console, I
> surprisingly do not
> get a zero. Why?
>
>   -1.1-0.1+1.2
> [1] -2.220446e-16
>
>
> greetings, Ole
>
>

[[alternative HTML version deleted]]

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


[R] Thanks! RE: boxplot with "cut"

2012-07-10 Thread Vining, Kelly
Thanks for your help, Rui! That works and will save me a lot of trouble. 

--Kelly

-Original Message-
From: Rui Barradas [mailto:ruipbarra...@sapo.pt] 
Sent: Tuesday, July 10, 2012 2:24 AM
To: Vining, Kelly
Cc: r-help@r-project.org
Subject: Re: [R] boxplot with "cut"

Hello,

Maybe this iss what you're looking for. GD is your data.frame.



multi.boxplot <- function(x, by, ...){
x <- as.data.frame(x)
sp <- split(x, by)
len <- length(sp) - 1
n <- ncol(x)
n1 <- n + 1
boxplot(x[[ 1 ]] ~ by, at = 0:len*n1 + 1,
xlim = c(0, (len + 1)*n1), ylim = range(unlist(x)), xaxt = "n", 
...)
for(i in seq_len(n)[-1])
boxplot(x[[i]] ~ by, at = 0:len*n1 + i, xaxt = "n", add = TRUE, 
...)
axis(1, at = 0:len*n1 + n1/2, labels = names(sp), tick = TRUE) }

cols <- grep("ReadCount", names(GD))
multi.boxplot(GD[, cols], cut(GD$GeneDensity, breaks=10))


If this is it and you don't like those x-axis tick lables, use 
as.integer(cut(...etc...)).

Hope this helps,

Rui Barradas

Em 09-07-2012 20:51, Vining, Kelly escreveu:
> Dear UseRs,
> I'm making box plots from a data set that looks like this:
>
>
>Chr Start   End GeneDensity ReadCount_Explant ReadCount_Callus 
> ReadCount_Regen
> 1   1 1 1  107.82 1.2431.047   
> 1.496
> 2   1 10001 2  202.50 0.8350.869   
> 0.456
> 3   1 20001 3  158.80 1.8131.529   
> 1.131
> 4   1 30001 4  100.53 1.7311.752   
> 1.610
> 5   1 40001 5  100.53 3.0562.931   
> 3.631
> 6   1 50001 6  100.53 1.9602.013   
> 2.459
>
> I'm breaking the "GeneDensity" column into deciles, then making a box plot of 
> the relationship between the GeneDensity parameter and each of the three 
> "ReadCount" columns. Here's an example of one of my boxplot commands:
>
> boxplot(GeneDensity$ReadCount_Explant ~ 
> cut(GeneDensitySorted$GeneDensity, breaks=10), ylim=c(0,40), 
> ylab="RPKM", xlab="GENE DENSITY (LOW -> HIGH)", main="INTERNODE 
> EXPLANT")
>
> Right now, I'm making three separate graphs: one for each of the three 
> "ReadCount" columns. I'd like to put all three sets on one graph, so that 
> each decile is represented by three boxes, one for each ReadCount category, 
> but don't know how to make that work. I tried this:
>
> boxplot(GeneDensitySorted$ReadCount_Explant ~ 
> cut(GeneDensitySorted$GeneDensity, breaks=10), 
> GeneDensitySorted$ReadCount_Callus ~ 
> cut(GeneDensitySorted$GeneDensity, breaks=10), 
> GeneDensitySorted$ReadCount_Regen ~ cut(GeneDensitySorted$GeneDensity, 
> breaks=10), ylim=c(0,40), ylab="RPKM", xlab="GENE DENSITY (LOW -> 
> HIGH)")
>
> Not surprisingly, I got this error:
>
> Error in as.data.frame.default(data) :
>cannot coerce class '"formula"' into a data.frame
>
> Does anyone know how to accomplish this box plot?
>
> Any help is much appreciated.
>
> --Kelly V.
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] -1.1 - 0.1 + 1.2 is NOT null! Why?

2012-07-10 Thread Rolf Turner



In addition to taking cognisance of Richard Heiberger's reply you
should also learn to distinguish between the concept of "null" and
"zero".  They are not at all the same thing.

cheers,

Rolf Turner

On 11/07/12 08:17, ollestrat wrote:

Hello,

I fear its a stupid question,..but here it is:

If I do this simple calculation with the R  console, I surprisingly do not
get a zero. Why?

  -1.1-0.1+1.2
[1] -2.220446e-16


greetings, Ole


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


Re: [R] -1.1 - 0.1 + 1.2 is NOT null! Why?

2012-07-10 Thread William Dunlap
It is for the same reason that if you must work with numbers
stored with 2 significant decimal digits 1-(1/3+1/3+1/3)
is 0.01 (== 10 ^ -2).

Double precision numbers, supported by your computer
hardware and used by R, are stored using 52 significant
binary digits and 2^-52 is about -2.220446e-16.

(By the way, in R zero and NULL are different things: the former
is numeric and the latter is not.)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf Of ollestrat
> Sent: Tuesday, July 10, 2012 1:17 PM
> To: r-help@r-project.org
> Subject: [R] -1.1 - 0.1 + 1.2 is NOT null! Why?
> 
> Hello,
> 
> I fear its a stupid question,..but here it is:
> 
> If I do this simple calculation with the R  console, I surprisingly do not
> get a zero. Why?
> 
>  -1.1-0.1+1.2
> [1] -2.220446e-16
> 
> 
> greetings, Ole
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/1-1-0-1-1-2-is-NOT-
> null-Why-tp4636053.html
> Sent from the R help mailing list archive at Nabble.com.
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] -1.1 - 0.1 + 1.2 is NOT null! Why?

2012-07-10 Thread Richard M. Heiberger
This is the behavior of the floating point number representation.
Decimal fractions do not come out even in binary notation.
Please see FAQ 7.31

On Tue, Jul 10, 2012 at 4:17 PM, ollestrat  wrote:

> Hello,
>
> I fear its a stupid question,..but here it is:
>
> If I do this simple calculation with the R  console, I surprisingly do not
> get a zero. Why?
>
>  -1.1-0.1+1.2
> [1] -2.220446e-16
>
>
> greetings, Ole
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/1-1-0-1-1-2-is-NOT-null-Why-tp4636053.html
> Sent from the R help mailing list archive at Nabble.com.
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] Download large file from https url with progress meter

2012-07-10 Thread Gregory Jefferis
Dear useRs,

I would like to download a large (15Mb) file from a github https url with a 
progress meter. My first attempt was:

zip_url="https://github.com/jefferis/AnalysisSuite/zipball/master";
zip_file=tempfile()
> download.file(zip_url,zip_file)
Error in download.file(zip_url, zip_file) : unsupported URL scheme

Then I tried
install.packages("httr")
require(httr)

system.time(request<-GET(zip_url, config(ssl.verifypeer = FALSE)))
stop_for_status(request)
writeBin(content(request),zip_file)

   user  system elapsed 
  1.234   0.236  27.685 

I can't seem to find a way for the httr package to show progress. Can anyone 
suggest an alternative approach?

With many thanks,

Greg Jefferis.

--
Gregory Jefferis, PhD  
Division of Neurobiology   
MRC Laboratory of Molecular Biology,   
Hills Road,
Cambridge, CB2 0QH, UK.

http://www2.mrc-lmb.cam.ac.uk/group-leaders/h-to-m/g-jefferis
http://www.neuroscience.cam.ac.uk/directory/profile.php?gsxej2
http://flybrain.stanford.edu

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


[R] -1.1 - 0.1 + 1.2 is NOT null! Why?

2012-07-10 Thread ollestrat
Hello,

I fear its a stupid question,..but here it is:

If I do this simple calculation with the R  console, I surprisingly do not
get a zero. Why?  

 -1.1-0.1+1.2
[1] -2.220446e-16


greetings, Ole

--
View this message in context: 
http://r.789695.n4.nabble.com/1-1-0-1-1-2-is-NOT-null-Why-tp4636053.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


Re: [R] Mann-Whitney by group

2012-07-10 Thread Oxenstierna
This works very well--thanks so much.

By way of extension:  how would one extract elements from the result object?

For example:

thing<=apply(Dtb[,3:10], 2, function(x) wilcox.test(x~Dtb$Group))

summary(thing)$p.value

Does not provide a list of p-values as it would in a regression object. 
Ideally, I would like to be able to extract the W score and p-value by
A,B,C,...

Any ideas greatly appreciated!


--
View this message in context: 
http://r.789695.n4.nabble.com/Mann-Whitney-by-group-tp4635618p4636055.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Need HELP: how find and use a csv file?

2012-07-10 Thread mlell08
On 10.07.2012 20:11, Faradj Koliev wrote:
> However, when i enter:skatter.csv<-read.csv("skatter.csv", header=TRUE) i 
> get this message: 
> Error in file(file, "rt") : cannot open the connection 
> In addition: Warning message: 
> In file(file, "rt") : 
> I have tried with:   skatter.csv<-file.choose() and other codes to find the 
> file but it does not work. 

Could it be a problem with your Working directory? use getwd() to find
out whether your working directory is set to your Desktop where your
file seems to be and use setwd("/Path/to/Desktop") to go there if you
aren't. Then you can use read.csv() without an absolute path for your
file as you did above

Regards, Moritz

-- 
GnuPG Key: 0x7340821E

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


Re: [R] Need HELP: how find and use a csv file?

2012-07-10 Thread R. Michael Weylandt


On Jul 10, 2012, at 2:56 PM, Rich Shepard  wrote:

> On Tue, 10 Jul 2012, Faradj Koliev wrote:
> 
>> I got a csv file ( skater.csv) which i could read by typing:
>> read.csv(file="/Users/kama/Desktop/skatter.csv", header=TRUE, sep=";")
> 
>  Try:
> 
> skatter <- read.csv('/Users/kama/Desktop/skatter.csv', header = T, sep =
> ';')

That seems paradoxical...

Michael

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

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


Re: [R] R code help to change table format

2012-07-10 Thread Rui Barradas

Hello,

You should say what is the package you are using, EstimateS returns 
hundreds of hits. [ package sos, findFn() ].


As for the question, try


sp <- 1:5
ab <- c(3, 2, 2, 2, 4)
rep(sp, ab)


Hope this helps,

Rui Barradas

Em 10-07-2012 18:23, peziza escreveu:

I am trying to input an OTU table into EstimateS, however, the format of the
OTU table has to be changed to fit the format EstimateS will accept. In R, I
would like to change the format of the OTU table (from excel).  Here is what
I need to do, take Example 1 and create Example 2.  The problem is that I
have hundreds of OTUs, so I can't do this by hand (and I'd love to have a
code that I could use for different OTU tables).
Thanks!

Example 1 Example 2
Species Abundance Species
1 3   1
2 2   1
3 2   1
4 2   2
5 4   2

3

3

4

4

5
5

5

5

5


--
View this message in context: 
http://r.789695.n4.nabble.com/R-code-help-to-change-table-format-tp4636022.html
Sent from the R help mailing list archive at Nabble.com.

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



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


Re: [R] Changing x-axis values displayed on histogram

2012-07-10 Thread jlwoodard
Perfect!  Thanks so much, Sarah!

--
View this message in context: 
http://r.789695.n4.nabble.com/Changing-x-axis-values-displayed-on-histogram-tp4636032p4636051.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] calculating the difference between days?

2012-07-10 Thread Jorge I Velez
What's wrong with manipulating the results arun got?

dat3<-read.table(text="
Begin_date  End_date
01JAN2000:00:00:00:000  02FEB2002:00:00:00:000
24MAR2012:00:00:00:000  18MAY2012:00:00:00:000
01OCT2003:00:00:00:000  02FEB2004:00:00:00:000
01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
",sep="",header=TRUE)

dat3$Begin_date<-strptime(dat3[,1],format="%d%b%Y:%H:%M:%S")
dat3$End_date<-strptime(dat3[,2],format="%d%b%Y:%H:%M:%S")

# difference in days
result <- difftime(dat3[,1],dat3[,2])

# difference in seconds
ddays <- as.numeric(result/(24*3600))
ddays

HTH,
Jorge.-


On Tue, Jul 10, 2012 at 3:55 PM, C W <> wrote:

> When the days and time are identical, difftime() gives difference in secs.
>  I still want difference in days.
>
> Say, below my last row is identical
> dat3<-read.table(text="
> Begin_date  End_date
> 01JAN2000:00:00:00:000  02FEB2002:00:00:00:000
> 24MAR2012:00:00:00:000  18MAY2012:00:00:00:000
> 01OCT2003:00:00:00:000  02FEB2004:00:00:00:000
> 01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
> 01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
> 24DEC2012:00:00:00:000  24DEC2012:00:00:00:000
> ",sep="",header=TRUE)
>
> -M
>
> On Tue, Jul 10, 2012 at 1:52 PM, arun  wrote:
>
> > Hi,
> >
> > Try this:
> >
> > dat3<-read.table(text="
> > Begin_date  End_date
> > 01JAN2000:00:00:00:000  02FEB2002:00:00:00:000
> > 24MAR2012:00:00:00:000  18MAY2012:00:00:00:000
> > 01OCT2003:00:00:00:000  02FEB2004:00:00:00:000
> > 01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
> > 01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
> > ",sep="",header=TRUE)
> >
> > dat3$Begin_date<-strptime(dat3[,1],format="%d%b%Y:%H:%M:%S")
> > dat3$End_date<-strptime(dat3[,2],format="%d%b%Y:%H:%M:%S")
> >
> >  difftime(dat3[,1],dat3[,2])
> > Time differences in days
> > [1] -763.  -55. -124.0417  -32.  -32.
> > attr(,"tzone")
> > [1] ""
> >
> > A.K.
> >
> > - Original Message -
> > From: C W 
> > To: r-help 
> > Cc:
> > Sent: Tuesday, July 10, 2012 1:22 PM
> > Subject: [R] calculating the difference between days?
> >
> > Hi List,
> >
> > I have one column of beginning dates and one column of ending dates, I
> want
> > to find their difference.  And I want to ignore the trailing zeros,
> > basically everything after the first colon mark.
> >
> > Begin_date   End_date
> > 01JAN2000:00:00:00:000   02FEB2002:00:00:00:000
> > 24MAR2012:00:00:00:000   18MAY2012:00:00:00:000
> > 01OCT2003:00:00:00:000   02FEB2004:00:00:00:000
> > 01JAN2000:00:00:00:000   02FEB2000:00:00:00:000
> > 01JAN2000:00:00:00:000   02FEB2000:00:00:00:000
> >
> > Thanks,
> >
> > Mike
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Use of Sappy and Tappy for Mathematical Calculation

2012-07-10 Thread R. Michael Weylandt


On Jul 10, 2012, at 11:30 AM, "Nordlund, Dan (DSHS/RDA)"  
wrote:

>> -Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
>> project.org] On Behalf Of Rantony
>> Sent: Tuesday, July 10, 2012 3:17 AM
>> To: r-help@r-project.org
>> Subject: [R] Use of Sappy and Tappy for Mathematical Calculation
>> 
>> Hi,
>> 
>> i have a matrix like this,
>> 
>> ABCXYZ...   .
>> - --
>> 1220  ...   .
>> 2435  ...   .
>> 3040  ...   .
>> 
>> Here, i need to get
>>   Sum of each columns,
>>   Mean of each columns,
>>   median of each columns,
>>   mode of each columns,
>>   Standard deviation  of each columns,
>>   variance of each columns,
>>   range of each columns,
>>   count of each columns,
>>   max of each columns,
>>   min of each columns
>> 
>> Can i get output using sappy or tappy functions ? because there have
>> alots
>> of records.

I like Dan's solution a lot and it teaches inportant idioms, but I might 
suggest that you use the col***() functions from the MatrixStats package if 
speed/data-size is of issue. 

Best,
Michael


>> 
>> Could you please help me fast its kind of urgent !
>> 
>> - Thanks
>> Antony
>> 
> 
> Here is some code to get you started.  You can add in the other functions 
> that you want.  You will need to figure out what you want to do if there are 
> missing values.  There are built-in functions for most everything you want.  
> You get the range from the min and the max, and you need to decide what to do 
> if a variable has 2 or more modes (you  will also need to determine how you 
> are going to get the mode).
> 
> 
> # here is sample matrix
> mat <- matrix(1:100,nrow=10)
> colnames(mat) <- LETTERS[1:10]
> 
> # define summarize function
> summarize <- function(m) {
>  sums <- apply(m, 2, sum)
>  counts <- apply(m, 2, length)
>  means <- apply(m, 2, mean)
>  return(rbind(sums, counts, means))
> }
> 
> # summarize your matrix
> summarize(mat)
> 
> 
> Hope this is helpful,
> 
> Dan
> 
> Daniel J. Nordlund
> Washington State Department of Social and Health Services
> Planning, Performance, and Accountability
> Research and Data Analysis Division
> Olympia, WA 98504-5204
> 
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Specify model with polynomial interaction terms up to degree n

2012-07-10 Thread William Dunlap
a) Please supply some context in your mail message.  Not everyone reads R-help 
via nabble.

b) poly(raw=TRUE, x, degree=degree) was changed for 2.15.0 to allow it to output
a non-full-rank matrix.  See the NEWS file in 2.15.0 or after:
  > # in R-2.15.1
  > n <- news()
  > n[grepl("poly", n$Text),]
  Changes in version 2.15.0:  
  
  NEW FEATURES
  
  o   poly(raw = TRUE) no longer requires more unique points than the
  degree.  (Requested by John Fox.)
  ...

c) Error messages include the innermost R function call before the error.  To 
see more call traceback(),
which will show the call stack from the innermost call back to the call you 
made:

  > # in R-2.14.1
  > m <- matrix(1:6, ncol=2)
  > poly(m, degree=6, raw=TRUE)
  Error in poly(dots[[1L]], degree, raw = raw) :
'degree' must be less than number of unique points
  > traceback()
  6: stop("'degree' must be less than number of unique points")
  5: poly(dots[[1L]], degree, raw = raw)
  4: cbind(1, poly(dots[[1L]], degree, raw = raw))
  3: polym(V1 = 1:3, V2 = 4:6, degree = 6, raw = TRUE)
  2: do.call("polym", c(m, degree = degree, raw = raw))
  1: poly(m, degree = 6, raw = TRUE)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf Of YTP
> Sent: Tuesday, July 10, 2012 11:23 AM
> To: r-help@r-project.org
> Subject: Re: [R] Specify model with polynomial interaction terms up to degree 
> n
> 
> Yep, that code is verbatim what I typed in, using version 2.14 ... seems
> weird.
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Specify-model-with-
> polynomial-interaction-terms-up-to-degree-n-tp4635130p4636031.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Changing x-axis values displayed on histogram

2012-07-10 Thread Sarah Goslee
Hi,

Thanks for providing a small reproducible example.

You can disable the default axis and make your own custom version:

hist(histexample,breaks=bins, xaxt="n")
axis(1, at=seq(5.5, 15.5, by=2), labels=c("5-6", "7-8", "9-10",
"11-12", "13-14", "15-16"))

Sarah

On Tue, Jul 10, 2012 at 3:34 PM, jlwoodard  wrote:
> Is it possible to change the x-axis values in a histogram to reflect binned
> values?
>
> Here are my data:
>
> histexample<-c(6,7,7,8,8,8,9,9,9,9,9,10,10,10,10,10,10,10,11,11,11,11,11,11,12,12,12,12,13,13,13,14,14,14,15,16)
> hist(histexample)
>
> Now, I'll bin pairs of adjacent values together (e.g., 5-6, 7-8, 9-10,
> 11-12, 13-14, 15-16) using the following
>
> bins<-c(4.5,6.5,8.5,10.5,12.5,14.5,16.5)
> hist(histexample,breaks=bins)
>
> The displayed x-axis values are 6, 8, 10, 12, 14, and 16.  I'd like the
> x-axis values to reflect the values in each bin (e.g., 5-6, 7-8, 9-10,
> 11-12, 13-14, 15-16).  Any suggestions would be greatly appreciated!  Many
> thanks in advance.
>
> John
>


-- 
Sarah Goslee
http://www.functionaldiversity.org

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


Re: [R] calculating the difference between days?

2012-07-10 Thread C W
Actually, when specifying unit="days" inside difftime() will do.
-M

On Tue, Jul 10, 2012 at 3:55 PM, C W  wrote:

> When the days and time are identical, difftime() gives difference in secs.
>  I still want difference in days.
>
> Say, below my last row is identical
> dat3<-read.table(text="
> Begin_date  End_date
> 01JAN2000:00:00:00:000  02FEB2002:00:00:00:000
> 24MAR2012:00:00:00:000  18MAY2012:00:00:00:000
> 01OCT2003:00:00:00:000  02FEB2004:00:00:00:000
> 01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
> 01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
> 24DEC2012:00:00:00:000  24DEC2012:00:00:00:000
> ",sep="",header=TRUE)
>
> -M
>
> On Tue, Jul 10, 2012 at 1:52 PM, arun  wrote:
>
>> Hi,
>>
>> Try this:
>>
>> dat3<-read.table(text="
>> Begin_date  End_date
>> 01JAN2000:00:00:00:000  02FEB2002:00:00:00:000
>> 24MAR2012:00:00:00:000  18MAY2012:00:00:00:000
>> 01OCT2003:00:00:00:000  02FEB2004:00:00:00:000
>> 01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
>> 01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
>> ",sep="",header=TRUE)
>>
>> dat3$Begin_date<-strptime(dat3[,1],format="%d%b%Y:%H:%M:%S")
>> dat3$End_date<-strptime(dat3[,2],format="%d%b%Y:%H:%M:%S")
>>
>>  difftime(dat3[,1],dat3[,2])
>> Time differences in days
>> [1] -763.  -55. -124.0417  -32.  -32.
>> attr(,"tzone")
>> [1] ""
>>
>> A.K.
>>
>> - Original Message -
>> From: C W 
>> To: r-help 
>> Cc:
>> Sent: Tuesday, July 10, 2012 1:22 PM
>> Subject: [R] calculating the difference between days?
>>
>> Hi List,
>>
>> I have one column of beginning dates and one column of ending dates, I
>> want
>> to find their difference.  And I want to ignore the trailing zeros,
>> basically everything after the first colon mark.
>>
>> Begin_date   End_date
>> 01JAN2000:00:00:00:000   02FEB2002:00:00:00:000
>> 24MAR2012:00:00:00:000   18MAY2012:00:00:00:000
>> 01OCT2003:00:00:00:000   02FEB2004:00:00:00:000
>> 01JAN2000:00:00:00:000   02FEB2000:00:00:00:000
>> 01JAN2000:00:00:00:000   02FEB2000:00:00:00:000
>>
>> Thanks,
>>
>> Mike
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>

[[alternative HTML version deleted]]

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


Re: [R] Need HELP: how find and use a csv file?

2012-07-10 Thread Rich Shepard

On Tue, 10 Jul 2012, Faradj Koliev wrote:


I got a csv file ( skater.csv) which i could read by typing:
read.csv(file="/Users/kama/Desktop/skatter.csv", header=TRUE, sep=";")


  Try:

skatter <- read.csv('/Users/kama/Desktop/skatter.csv', header = T, sep =
';')

Rich

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


Re: [R] Need HELP: how find and use a csv file?

2012-07-10 Thread Sarah Goslee
You don't actually have to post more than once. Really.

skatter <- read.table(file.choose(), header=TRUE, sep=";")

or

skatter <- read.table(""/Users/kama/Desktop/skatter.csv", header=TRUE, sep=";")

or whatever the actual path to the file is.

As a new user of R, you should read the Introduction to R that came
with R, and also the R-help posting guide. Both are full of useful
information.

Sarah

On Tue, Jul 10, 2012 at 2:11 PM, Faradj Koliev  wrote:
> Hey,
>
> I am having some problems with importing a csv file into R and then saving it 
> for analyzing.
>
> I got a csv file ( skater.csv) which i could read by typing:
> read.csv(file="/Users/kama/Desktop/skatter.csv", header=TRUE, sep=";")
>
> However, when i enter:skatter.csv<-read.csv("skatter.csv", header=TRUE) i 
> get this message:
> Error in file(file, "rt") : cannot open the connection
> In addition: Warning message:
> In file(file, "rt") :
> I have tried with:   skatter.csv<-file.choose() and other codes to find the 
> file but it does not work.
> Please help me fix this problem, i have been sitting with this one in 4 
> hours..
>
>
>
> What i need is to import this file and analyze it using for example histogram.
>
> I have Mac(update) and the file is saved in csv file... and I'm quite new 
> user of R.
>

-- 
Sarah Goslee
http://www.functionaldiversity.org

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


Re: [R] calculating the difference between days?

2012-07-10 Thread C W
When the days and time are identical, difftime() gives difference in secs.
 I still want difference in days.

Say, below my last row is identical
dat3<-read.table(text="
Begin_date  End_date
01JAN2000:00:00:00:000  02FEB2002:00:00:00:000
24MAR2012:00:00:00:000  18MAY2012:00:00:00:000
01OCT2003:00:00:00:000  02FEB2004:00:00:00:000
01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
24DEC2012:00:00:00:000  24DEC2012:00:00:00:000
",sep="",header=TRUE)

-M

On Tue, Jul 10, 2012 at 1:52 PM, arun  wrote:

> Hi,
>
> Try this:
>
> dat3<-read.table(text="
> Begin_date  End_date
> 01JAN2000:00:00:00:000  02FEB2002:00:00:00:000
> 24MAR2012:00:00:00:000  18MAY2012:00:00:00:000
> 01OCT2003:00:00:00:000  02FEB2004:00:00:00:000
> 01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
> 01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
> ",sep="",header=TRUE)
>
> dat3$Begin_date<-strptime(dat3[,1],format="%d%b%Y:%H:%M:%S")
> dat3$End_date<-strptime(dat3[,2],format="%d%b%Y:%H:%M:%S")
>
>  difftime(dat3[,1],dat3[,2])
> Time differences in days
> [1] -763.  -55. -124.0417  -32.  -32.
> attr(,"tzone")
> [1] ""
>
> A.K.
>
> - Original Message -
> From: C W 
> To: r-help 
> Cc:
> Sent: Tuesday, July 10, 2012 1:22 PM
> Subject: [R] calculating the difference between days?
>
> Hi List,
>
> I have one column of beginning dates and one column of ending dates, I want
> to find their difference.  And I want to ignore the trailing zeros,
> basically everything after the first colon mark.
>
> Begin_date   End_date
> 01JAN2000:00:00:00:000   02FEB2002:00:00:00:000
> 24MAR2012:00:00:00:000   18MAY2012:00:00:00:000
> 01OCT2003:00:00:00:000   02FEB2004:00:00:00:000
> 01JAN2000:00:00:00:000   02FEB2000:00:00:00:000
> 01JAN2000:00:00:00:000   02FEB2000:00:00:00:000
>
> Thanks,
>
> Mike
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

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


[R] Understanding cenros Error

2012-07-10 Thread Rich Shepard

  Before reading water chemistry into a data frame I removed all missing
data. Yet when I try to run cenros() to summarize a specific chemical I get
an error that I do not understand:

with( subset(chem, param=='Ag'),  cenros(quant,ceneq1) )
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
  NA/NaN/Inf in 'y'

  I would like to learn what I did incorrectly so I can avoid these errors
in the future.

  The data frame structure is

str(chem)
'data.frame':   120309 obs. of  8 variables:
 $ site: Factor w/ 65 levels ";Influent","D-1",..: 2 2 2 2 2 2 ...
 $ sampdate: Date, format: "2007-12-12" "2007-12-12" ...
 $ preeq0  : logi  TRUE TRUE TRUE TRUE TRUE TRUE ...
 $ param   : Factor w/ 37 levels "Ag","Al","Alk_tot",..: 1 2 8 17 3 9 ...
 $ quant   : num  0 0.106 1 231 231 0.011 0 0.002 0 100 ...
 $ ceneq1  : logi  FALSE FALSE TRUE FALSE FALSE FALSE ...
 $ floor   : num  0 0.106 0 231 231 0.011 0 0 0 100 ...
 $ ceiling : Factor w/ 3909 levels "0.000","0.000)",..: 1 116 841 1771 ...

  I ran dput() on the data frame but cannot make sense of the output (a 5.5M
ASCII text file).

  Pointers appreciated.

Rich

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


Re: [R] HELP me please with import of csv to R

2012-07-10 Thread Sarah Goslee
Hi,

On Tue, Jul 10, 2012 at 12:48 PM, F86  wrote:
> Hey,
>
> I am having problems with importing a csv file to R.
>
> I could read the file by typing:
> read.csv(file="/Users/kama/Desktop/skatter.csv", header=TRUE, sep=";")

So that command does work?


> However, i can not analyze the "skatter" - for ex, when i type: skatter
> = read.csv("skatter.csv")

Then you need the above command, not what you type here:

skatter <- read.csv(file="/Users/kama/Desktop/skatter.csv",
header=TRUE, sep=";")

But note that if sep=";" then you don't have a csv file and should
properly use read.table() instead.

> i get this message:
>
> Error in file(file, "rt") : cannot open the connection
> In addition: Warning message:
> In file(file, "rt") :
>
> What i need is to import this file and analyze it using for example
> histogram.
>
> I have Mac(update) and the file is saved in csv file... and I'm quite new
> user of R.

That error means that R can't find the file where you told it to look.
Specifying the full and complete path as in your first example should
work.

If you're having problems with paths (which are a Mac issue and not at
all an R issue), you could also try

read.table(file.choose(), header=TRUE, sep=";")

I think that file.choose() should work on Mac.

The Intro to R document that came with R might also be of use.

Sarah

-- 
Sarah Goslee
http://www.functionaldiversity.org

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


Re: [R] Package 'MASS' (polr): Error in svd(X) : infinite or missing values in 'x'

2012-07-10 Thread Rune Haubo
Hi Jeremy,

I think Jessica is right that probably you could make polr converge
and produce a Hessian if the data are better scaled, but there might
also be other things not allowing you to get the Hessian/vcov. Could
be insightful if you showed us the result of
str(Jdata)

Also, I am thinking that perhaps the another implementation of ordinal
regression models might avoid the problem. You could try the ordinal
package (of which I am the author) -- the following should reproduce
the MASS::polr results:

install.packages(ordinal)
library(ordinal)
Global <- clm(JVeg5 ~  Elevation +  Lat_Y_pos + Coast_dist +
Stream_dist, data=Jdata)
summary(Global)

Another option would be Frank Harrell's lrm function in the rms package.

HTH,
Rune

On 9 July 2012 11:55, Jeremy Little  wrote:
> Hello,
>
> I am trying to run an ordinal logistic regression (polr) using the package
> 'MASS'.
>
> I have successfully run other regression classes (glm, multinom) without
> much problem, but with the 'polr' class I get the following error:
> " Error in svd(X) : infinite or missing values in 'x' "
> which appears when I run the "summary" command.
>
> The data file is large (585000 rows) and has no NA, - or blank values.
>
> My script (in brief) is as follows, with results:
>
> 
>> library(MASS)
>>
>> ## ADD DATA
>> Jdata<- read.delim("/Analysis/20120709 JLittle data file.txt", header=T)
>>
>> attach(Jdata)
>> names(Jdata)
>  [1] "POINTID" "Lat_Y_pos"   "JVeg5"   "Subregion"   "Rock_U_Nam"
> "Rock_Name"   "Elevation"   "Slope"   "Aspect"  "Hillshade"
> "Stream_dist" "Coast_dist"  "Coast_SE"
> [14] "Coast_E" "Wind_310""TPI" "Landform"
>>
>> Global <- polr(JVeg5 ~  Elevation +  Lat_Y_pos + Coast_dist + Stream_dist,
>> data=Jdata)
>>
>> summary(Global)
> Error in svd(X) : infinite or missing values in 'x'
>>
> ##Try with omit NA command
>> Global <- polr(JVeg5 ~  Elevation +  Lat_Y_pos + Coast_dist + Stream_dist,
>> data=Jdata, na.action = na.omit, Hess = TRUE)
>>
>> summary(Global)
> Error in svd(X) : infinite or missing values in 'x'
> 
>
> Does this imply an 'infinite value' and what would this mean?
>
> If anyone has any idea how to address this error, I would very much
> appreciate your response.
>
> Thank you in advance.
>
> Jeremy
>
> Date File Attachment (200 rows):
> http://r.789695.n4.nabble.com/file/n4635829/20120709_JLittle_data_file.txt
> 20120709_JLittle_data_file.txt
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Package-MASS-polr-Error-in-svd-X-infinite-or-missing-values-in-x-tp4635829.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Rune Haubo Bojesen Christensen

Ph.D. Student, M.Sc. Eng.
Phone: (+45) 45 25 33 63
Mobile: (+45) 30 26 45 54

DTU Informatics, Section for Statistics
Technical University of Denmark, Build. 305, Room 122,
DK-2800 Kgs. Lyngby, Denmark

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


[R] Need HELP: how find and use a csv file?

2012-07-10 Thread Faradj Koliev
Hey, 

I am having some problems with importing a csv file into R and then saving it 
for analyzing. 

I got a csv file ( skater.csv) which i could read by typing:
read.csv(file="/Users/kama/Desktop/skatter.csv", header=TRUE, sep=";") 

However, when i enter:skatter.csv<-read.csv("skatter.csv", header=TRUE) i 
get this message: 
Error in file(file, "rt") : cannot open the connection 
In addition: Warning message: 
In file(file, "rt") : 
I have tried with:   skatter.csv<-file.choose() and other codes to find the 
file but it does not work. 
Please help me fix this problem, i have been sitting with this one in 4 hours.. 



What i need is to import this file and analyze it using for example histogram. 

I have Mac(update) and the file is saved in csv file... and I'm quite new user 
of R. 



Thank you very much! 
[[alternative HTML version deleted]]

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


[R] Changing x-axis values displayed on histogram

2012-07-10 Thread jlwoodard
Is it possible to change the x-axis values in a histogram to reflect binned
values?

Here are my data:

histexample<-c(6,7,7,8,8,8,9,9,9,9,9,10,10,10,10,10,10,10,11,11,11,11,11,11,12,12,12,12,13,13,13,14,14,14,15,16)
hist(histexample)

Now, I'll bin pairs of adjacent values together (e.g., 5-6, 7-8, 9-10,
11-12, 13-14, 15-16) using the following

bins<-c(4.5,6.5,8.5,10.5,12.5,14.5,16.5)
hist(histexample,breaks=bins)

The displayed x-axis values are 6, 8, 10, 12, 14, and 16.  I'd like the
x-axis values to reflect the values in each bin (e.g., 5-6, 7-8, 9-10,
11-12, 13-14, 15-16).  Any suggestions would be greatly appreciated!  Many
thanks in advance.

John 

--
View this message in context: 
http://r.789695.n4.nabble.com/Changing-x-axis-values-displayed-on-histogram-tp4636032.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Times Series Data using GLS

2012-07-10 Thread MRB305
I am trying to use regression to determine the interaction between a couple
of variables while correcting for autocorrelation. Thus far, I have created
the code:
model <- gls(yvar~xvar1*xvar2, correlation = corARMA (p=2), method = "ML",
data = data)

I'm having a difficult time understanding the different correlation
structure classes and when to use the correct ones. Also, with regards to
"method", I am not sure if REML or ML is the correct option.

Thanks to anyone who can give me help with this. I really appreciate it.

--
View this message in context: 
http://r.789695.n4.nabble.com/Times-Series-Data-using-GLS-tp4636026.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] calculating the difference between days?

2012-07-10 Thread arun
Hi,

Try this:

dat3<-read.table(text="
Begin_date  End_date
01JAN2000:00:00:00:000  02FEB2002:00:00:00:000
24MAR2012:00:00:00:000  18MAY2012:00:00:00:000
01OCT2003:00:00:00:000  02FEB2004:00:00:00:000
01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
01JAN2000:00:00:00:000  02FEB2000:00:00:00:000
",sep="",header=TRUE)

dat3$Begin_date<-strptime(dat3[,1],format="%d%b%Y:%H:%M:%S")
dat3$End_date<-strptime(dat3[,2],format="%d%b%Y:%H:%M:%S")

 difftime(dat3[,1],dat3[,2])
Time differences in days
[1] -763.  -55. -124.0417  -32.  -32.
attr(,"tzone")
[1] ""

A.K.

- Original Message -
From: C W 
To: r-help 
Cc: 
Sent: Tuesday, July 10, 2012 1:22 PM
Subject: [R] calculating the difference between days?

Hi List,

I have one column of beginning dates and one column of ending dates, I want
to find their difference.  And I want to ignore the trailing zeros,
basically everything after the first colon mark.

Begin_date                           End_date
01JAN2000:00:00:00:000       02FEB2002:00:00:00:000
24MAR2012:00:00:00:000       18MAY2012:00:00:00:000
01OCT2003:00:00:00:000       02FEB2004:00:00:00:000
01JAN2000:00:00:00:000       02FEB2000:00:00:00:000
01JAN2000:00:00:00:000       02FEB2000:00:00:00:000

Thanks,

Mike

    [[alternative HTML version deleted]]

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


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


Re: [R] Skipping lines and incomplete rows

2012-07-10 Thread arun
Hello Ravi,

I was not aware that your dataset have special character "#" before NA.  If it 
was just plain NA, it would have worked.  So, It's not because of sep= ";".

See below:

#Without "#"
dat1<-read.table(text="
 Remove this line
 Remove this line
 Remove this line
 Time;Actual Speed;Actual Direction;Temp;Press;Value1;Value2
  ;[m/s];[°];°C;[hPa];[MWh];[MWh]
 1/1/2012;0.0;0;NA;NA;0.;0.
 1/2/2012;0.0;0;NA;NA;0.;0.
 1/3/2012;0.0;0;NA;NA;1.5651;2.2112
 1/4/2012;0.0;0;NA;NA;1.;2.
 1/5/2012;0.0;0;NA;NA;3.2578;7.5455
 ",sep=";",header=TRUE,fill=TRUE,skip=4,stringsAsFactors=FALSE)
> dat1
  Time Actual.Speed Actual.Direction Temp Press Value1 Value2
1 [m/s]  [°]   °C [hPa]  [MWh]  [MWh]
2 1/1/2012  0.0    0    0. 0.
3 1/2/2012  0.0    0    0. 0.
4 1/3/2012  0.0    0    1.5651 2.2112
5 1/4/2012  0.0    0    1. 2.
6 1/5/2012  0.0    0    3.2578 7.5455


#With "#": Reading data from the .txt file.  

# In the documentation 
(http://stat.ethz.ch/R-manual/R-devel/library/utils/html/read.table.html), 
comment.char="#" is an option in the read.table, but unfortunately it shows 
only blank columns after the first three columns.  


#I think Rui's method of reading header separately using readLines might be a 
good option.  Or if you know the columnheadings, then you can do this:

dat2<-read.table("dat2.txt",skip=4,col.names=c("Time","Actual Speed","Actual 
Direction", 
"Temp","Press","Value1","Value2"),fill=TRUE,sep=";",comment.char="c")
> dat2
  Time Actual.Speed Actual.Direction Temp Press Value1 Value2
1 [m/s]  [°]   °C [hPa]  [MWh]  [MWh]
2 1/1/2012  0.0    0  #NA   #NA 0. 0.
3 1/2/2012  0.0    0  #NA   #NA 0. 0.
4 1/3/2012  0.0    0  #NA   #NA 1.5651 2.2112
5 1/4/2012  0.0    0  #NA   #NA 1. 2.
6 1/5/2012  0.0    0  #NA   #NA 3.2578 7.5455


A.K.










- Original Message -
From: vioravis 
To: r-help@r-project.org
Cc: 
Sent: Tuesday, July 10, 2012 1:41 AM
Subject: Re: [R] Skipping lines and incomplete rows

Thanks a lot Rui and Arun.

The methods work fine with the data I gave but when I tried the two methods
with the following semi-colon separated data using sep = ";". Only the first
3 columnns are read properly rest of the columns are either empty or NAs.


**
Remove this line
Remove this line
Remove this line
Time;Actual Speed;Actual Direction;Temp;Press;Value1;Value2
;[m/s];[°];°C;[hPa];[MWh];[MWh]
1/1/2012;0.0;0;#N/A;#N/A;0.;0.
1/2/2012;0.0;0;#N/A;#N/A;0.;0.
1/3/2012;0.0;0;#N/A;#N/A;1.5651;2.2112
1/4/2012;0.0;0;#N/A;#N/A;1.;2.
1/5/2012;0.0;0;#N/A;#N/A;3.2578;7.5455
***

I used the following code:
dat1<-read.table("testInput.txt",sep=";",skip=3,fill=TRUE,header=TRUE) 
dat1<-dat1[-1,] 
row.names(dat1)<-1:nrow(dat1)

Could you please let me know what is wrong with this approach? 

Thank you.

Ravi

--
View this message in context: 
http://r.789695.n4.nabble.com/Skipping-lines-and-incomplete-rows-tp4635830p4635952.html
Sent from the R help mailing list archive at Nabble.com.

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


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


[R] R code help to change table format

2012-07-10 Thread peziza
I am trying to input an OTU table into EstimateS, however, the format of the
OTU table has to be changed to fit the format EstimateS will accept. In R, I
would like to change the format of the OTU table (from excel).  Here is what
I need to do, take Example 1 and create Example 2.  The problem is that I
have hundreds of OTUs, so I can't do this by hand (and I'd love to have a
code that I could use for different OTU tables). 
Thanks!

Example 1 Example 2
Species Abundance Species
1 3   1
2 2   1
3 2   1
4 2   2
5 4   2

3 

3

4

4

5 
5

5

5

5


--
View this message in context: 
http://r.789695.n4.nabble.com/R-code-help-to-change-table-format-tp4636022.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] problem for installing rgdal

2012-07-10 Thread stanislas rebaudet
Hello,

I run [R] 2.14 on Mac OS 10.6 and I've been desperately trying to install rpy2 
in order to compute spatial statistics on QGIS 1.7.3.
rpy2 is dependent upon the rgdal [R]package that I've been unable to install in 
spite of up to date versions of GDAL and PROJ.
More precisely, [R] console writes "Error: gdal-config not found". As a matter 
of fact, typing "gdal.config" on a Terminal shell doesn't work either...

Yet, the file is actually present in 
/Library/Frameworks/GDAL.framework/Versions/1.9/Programs
I then tryed to follow suggestions with:  
--configure-args='--with-gdal-config=/Library/Frameworks/GDAL.framework/Versions/1.9/Programs/gdal-config'
I received "no such file or directory"

I also found this option described here 
(http://www.r-bloggers.com/installing-rgdal-on-mac-os-x-2/), but couldn't get 
through it...

As anyone an idea? 
Thanks for your help

stan

[[alternative HTML version deleted]]

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


[R] HELP me please with import of csv to R

2012-07-10 Thread F86
Hey, 

I am having problems with importing a csv file to R. 

I could read the file by typing:   
read.csv(file="/Users/kama/Desktop/skatter.csv", header=TRUE, sep=";")

However, i can not analyze the "skatter" - for ex, when i type: skatter
= read.csv("skatter.csv")

i get this message: 

Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :

What i need is to import this file and analyze it using for example
histogram. 

I have Mac(update) and the file is saved in csv file... and I'm quite new
user of R. 



Thank you very much! 




--
View this message in context: 
http://r.789695.n4.nabble.com/HELP-me-please-with-import-of-csv-to-R-tp4636019.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Use of Sappy and Tappy for Mathematical Calculation

2012-07-10 Thread arun
Hi,

 dat1<-data.frame(ABC=c(12,24,30),XYZ=c(20,35,40))
 dat2<-as.matrix(dat1)
 #mean
 dat2mean<-apply(dat2,2,mean)
 dat2mean
  #   ABC  XYZ 
#22.0 31.7 
dat2sum<-apply(dat2,2,sum)
 dat2median<-apply(dat2,2,median)
 dat2max<-apply(dat2,2,max)
dat2min<-apply(dat2,2,min)

 dat2range<-apply(dat2,2,range)

dat2count<-apply(dat2,2,length)
dat2sd<-apply(dat2,2,sd)
dat2var<-apply(dat2,2,var)

A.K.



- Original Message -
From: Rantony 
To: r-help@r-project.org
Cc: 
Sent: Tuesday, July 10, 2012 6:16 AM
Subject: [R] Use of Sappy and Tappy for Mathematical Calculation

Hi,

i have a matrix like this,

ABC        XYZ    ..    .   .
-         --
12            20      ..    .   .
24            35      ..    .   .
30            40      ..    .   .

Here, i need to get 
                           Sum of each columns,
                           Mean of each columns, 
                           median of each columns,
                           mode of each columns, 
                           Standard deviation  of each columns, 
                           variance of each columns, 
                           range of each columns,
                           count of each columns,
                           max of each columns, 
                           min of each columns

Can i get output using sappy or tappy functions ? because there have alots
of records.

Could you please help me fast its kind of urgent !

- Thanks 
Antony 

--
View this message in context: 
http://r.789695.n4.nabble.com/Use-of-Sappy-and-Tappy-for-Mathematical-Calculation-tp4635969.html
Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] Specify model with polynomial interaction terms up to degree n

2012-07-10 Thread YTP
Yep, that code is verbatim what I typed in, using version 2.14 ... seems
weird. 

--
View this message in context: 
http://r.789695.n4.nabble.com/Specify-model-with-polynomial-interaction-terms-up-to-degree-n-tp4635130p4636031.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Predicted values for zero-inflated Poisson

2012-07-10 Thread Laura Lee
Alain-

Thanks again for your reply. Yes, the offset for effort is only in the count 
part of the model. Sorry I wasn't clear about why I was using 'sum'...my effort 
data set contains records of trips with the effort given for each trip. I 
thought using sum would get me the total number of turtles predicted for the 
new effort data. I did also log-transform the effort in the new effort data 
before applying predict (correct?). I will try the manual method as you 
recommended to help me understand the code.

Thanks,

Laura

From: Alain Zuur [via R] [mailto:ml-node+s789695n4636025...@n4.nabble.com]
Sent: Tuesday, July 10, 2012 1:52 PM
To: Lee, Laura
Subject: Re: Predicted values for zero-inflated Poisson

*Laura Lee* laura.lee at ncdenr.gov

/Tue Jul 10 18:27:16 CEST 2012/



I want to predict the number of turtles for different levels of effort and
combinations of covariates. So, for my dataset from which I built the model,
would I compare sum(predict(ZIP,type="response")) to the observed bycatch to
compare numbers? In order to predict for the new data (called effort), would
I use sum(predict(ZIP,newdata=effort,type="response"))? I want to be certain
I am understanding the coding--this is my first time using the predict
function.

Thanks,

Laura




Laura
Why do you use the sum? If you use:

PredY <- predict(ZIP, type = "response") then you have predicted values for 
each of the rows in your effort data frame.
Job done.

You have an offset in your model, isn't it? You will need to choose values for 
this in the data frame effort as well.
Also double check that the offset is only in the count partat least that is 
what I would do.
Note that using an offset means that you assume that if sampling effort is 
doubled, your fish (?) numbers double.




If you fully want to understand what predict is doing, try to do it manually. 
Below is R code from Chapter 7 (Zero Inflation and GLMM with R)






M3 <- zeroinfl(ParrotFish ~ Depth + Slope + SQDistRck + DistSed + Swell + Chla 
+ SST,
dist = "poisson", link = "logit",
data = PF2)

Betas.logistic <- coef(M3, model = "zero")
X.logistic <- model.matrix(M3, model = "zero")
eta.logistic   <- X.logistic %*% Betas.logistic
p  <- exp(eta.logistic) / (1 + exp(eta.logistic))

Betas.log  <- coef(M3, model = "count")
X.log  <- model.matrix(M3, model = "count")
eta.log<- X.log %*% Betas.log
mu <- exp(eta.log)

ExpY   <-  mu * (1 - p)
VarY   <- (1 - p) * (mu + p * mu^2)



Instead of using model.matrix(M3), you could specify your own data frame with 
covariates.
Your effort. Something like:

M4 <- zeroinfl(ParrotFish ~ Depth + Slope   | SST,
dist = "poisson", link = "logit",
data = PF2)

betapois <- coef(M4, model = "count")
betaBin  <- coef(M4, model = "zero")

MyDataPois <- data.frame(Depth = blah blah,
  Slope = Blah blah)
MyDataBin  <- data.frame(SST =  blah)

Xpois <- model.matrix(~ blah blah, data = MyDataPois)
Xbin  <- model.matrix(~ blah blah, data = MyDataBin)

eta.Pois <- Xpois %*% betapois
eta.Bin <- blah blah

mu = blah blah
pi = blah blah

ExpY = ...


Doing it like this means you fully understand it..:-)


Alain




--

Dr. Alain F. Zuur
First author of:

1. Analysing Ecological Data (2007).
Zuur, AF, Ieno, EN and Smith, GM. Springer. 680 p.
URL: www.springer.com/0-387-45967-7


2. Mixed effects models and extensions in ecology with R. (2009).
Zuur, AF, Ieno, EN, Walker, N, Saveliev, AA, and Smith, GM. Springer.
http://www.springer.com/life+sci/ecology/book/978-0-387-87457-9


3. A Beginner's Guide to R (2009).
Zuur, AF, Ieno, EN, Meesters, EHWG. Springer
http://www.springer.com/statistics/computational/book/978-0-387-93836-3


4. Zero Inflated Models and Generalized Linear Mixed Models with R. (2012) 
Zuur, Saveliev, Ieno.
http://www.highstat.com/book4.htm

Other books: http://www.highstat.com/books.htm


Statistical consultancy, courses, data analysis and software
Highland Statistics Ltd.
6 Laverock road
UK - AB41 6FN Newburgh
Tel: 0044 1358 788177
Email: [hidden email]
URL: www.highstat.com
URL: www.brodgar.com


[[alternative HTML version deleted]]

__
[hidden email] 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.
Dr. Alain F. Zuur
First author of:

1. Analysing Ecological Data (2007).
Zuur, AF, Ieno, EN and Smith, GM. Springer. 680 p.
URL: www.springer.com/0-387-45967-7

Re: [R] fill 0-row data.frame with 1 line of NAs

2012-07-10 Thread Rui Barradas

Hello,

Em 10-07-2012 18:59, Peter Ehlers escreveu:

On 2012-07-10 08:50, Brian Diggs wrote:

On 7/10/2012 7:53 AM, Peter Ehlers wrote:

On 2012-07-10 06:57, Rui Barradas wrote:

Hello,

If you write a function, it becomes less convoluted...


empty <- function(x){
 if(NROW(x) == 0){
 y <- rep(NA, NCOL(x))
 names(y) <- names(x)
 y
 }else x
}

(.xb <- iris[ iris$Species=='zz', ])
empty(.xb)


Both this and Liviu's original solution destroy the
factor nature of 'Species' (which may not matter, of
course). How about

(.xb <- iris[ iris$Species=='zz', ])
.xb <- .xb[1, ]   # this probably shouldn't work, but it does.


Using NA subscripting seems even better


Yes, you can subset with NA or any real number greater than 1.

Peter Ehlers



Good to know,  was completely unaware of this indexing possibility.

Rui Barradas



empty <- function(x) {
if(NROW(x) == 0) {
  x[NA,]
} else {
  x
}
}

It even preserves the factor nature of things:

  > empty(iris[iris$Specis=='zz',])
 Sepal.Length Sepal.Width Petal.Length Petal.Width Species
NA   NA  NA   NA  NA
  > str(empty(iris[iris$Specis=='zz',]))
'data.frame':   1 obs. of  5 variables:
   $ Sepal.Length: num NA
   $ Sepal.Width : num NA
   $ Petal.Length: num NA
   $ Petal.Width : num NA
   $ Species : Factor w/ 3 levels "setosa","versicolor",..: NA



?

Peter Ehlers




Hope this helps,

Rui Barradas

Em 10-07-2012 14:15, Liviu Andronic escreveu:

Dear all
Is there a simpler method to achieve the following: When I obtain an
empty data.frame after subsetting, I need for it to contain one line
of NAs. Here's a dummy example:

(.xb <- iris[ iris$Species=='zz', ])

[1] Sepal.Length Sepal.Width  Petal.Length Petal.Width  Species
<0 rows> (or 0-length row.names)

dim(.xb)

[1] 0 5

(.xa <- data.frame(matrix(rep(NA, ncol(.xb)), 1)))

 X1 X2 X3 X4 X5
1 NA NA NA NA NA

names(.xa) <- names(.xb)
(.xb <- .xa)

 Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1   NA  NA   NA  NA  NA


The solution I came up with is way too convoluted. Anything simpler?
Regards
Liviu




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








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


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


Re: [R] fill 0-row data.frame with 1 line of NAs

2012-07-10 Thread Peter Ehlers

On 2012-07-10 08:50, Brian Diggs wrote:

On 7/10/2012 7:53 AM, Peter Ehlers wrote:

On 2012-07-10 06:57, Rui Barradas wrote:

Hello,

If you write a function, it becomes less convoluted...


empty <- function(x){
 if(NROW(x) == 0){
 y <- rep(NA, NCOL(x))
 names(y) <- names(x)
 y
 }else x
}

(.xb <- iris[ iris$Species=='zz', ])
empty(.xb)


Both this and Liviu's original solution destroy the
factor nature of 'Species' (which may not matter, of
course). How about

(.xb <- iris[ iris$Species=='zz', ])
.xb <- .xb[1, ]   # this probably shouldn't work, but it does.


Using NA subscripting seems even better


Yes, you can subset with NA or any real number greater than 1.

Peter Ehlers



empty <- function(x) {
if(NROW(x) == 0) {
  x[NA,]
} else {
  x
}
}

It even preserves the factor nature of things:

  > empty(iris[iris$Specis=='zz',])
 Sepal.Length Sepal.Width Petal.Length Petal.Width Species
NA   NA  NA   NA  NA
  > str(empty(iris[iris$Specis=='zz',]))
'data.frame':   1 obs. of  5 variables:
   $ Sepal.Length: num NA
   $ Sepal.Width : num NA
   $ Petal.Length: num NA
   $ Petal.Width : num NA
   $ Species : Factor w/ 3 levels "setosa","versicolor",..: NA



?

Peter Ehlers




Hope this helps,

Rui Barradas

Em 10-07-2012 14:15, Liviu Andronic escreveu:

Dear all
Is there a simpler method to achieve the following: When I obtain an
empty data.frame after subsetting, I need for it to contain one line
of NAs. Here's a dummy example:

(.xb <- iris[ iris$Species=='zz', ])

[1] Sepal.Length Sepal.Width  Petal.Length Petal.Width  Species
<0 rows> (or 0-length row.names)

dim(.xb)

[1] 0 5

(.xa <- data.frame(matrix(rep(NA, ncol(.xb)), 1)))

 X1 X2 X3 X4 X5
1 NA NA NA NA NA

names(.xa) <- names(.xb)
(.xb <- .xa)

 Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1   NA  NA   NA  NA  NA


The solution I came up with is way too convoluted. Anything simpler?
Regards
Liviu




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








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


Re: [R] Extracting arithmetic mean for specific values from multiple .txt-files

2012-07-10 Thread Rui Barradas

Hello,

I'm glad it help.

As for this second question, you should explain yourself better.

1. What is a test subject, which column records its id? vpNum?
2. You say "divided per trials or trialCount". Does this mean per trial 
number (example: divide by 1, by 2, by 3, etc, by 149) or per number of 
trials (149 in the previous example)
3. 'correct' now seems to be categorical. Divide WHAT by trial or 
trialCount?


Hint: post a small data example with three or four subjects and the 
wanted output.


Rui Barradas

Em 10-07-2012 18:06, vimmster escreveu:

Dear Rui,

thank you very much.

Your solution works perfectly.

One last question:

I need to write a function, with ONE value (here: a ratio) for the correct
reactions divided per trials or trialCount, respectively, FOR EACH test
subject.

"/" means "divided by" in the following.

I need the ratio correct (reactions)/trial or correct
(reactions)/trialCount, respectively (because trial and trialCount are the
same WITHIN test SUBJECTS; BUT they differ in length between BETWEEN test
SUBJECTS!).

It would be very helpful, if I had a data frame in the end in R, with one
column for
"trialCount"/"trial", one column for "correct reactions"(= 1) AND (more
importantly) one column for "correct (= 1) answers / trialCount".

legend (just as additional information) for the variable "correct":
1 = correct reaction
2 = false reaction
3 = reaction too slow
4 = reaction too fast
5 = more than one button pressed
6 = no reaction within RT window

I would be very thankful for an answer!

Sorry for the questions, but I am doing this for the first time!

Kind regards

--
View this message in context: 
http://r.789695.n4.nabble.com/Extracting-arithmetic-mean-for-specific-values-from-multiple-txt-files-tp4635809p4636020.html
Sent from the R help mailing list archive at Nabble.com.

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



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


Re: [R] Predicted values for zero-inflated Poisson

2012-07-10 Thread Highland Statistics Ltd
*Laura Lee* laura.lee at ncdenr.gov 

/Tue Jul 10 18:27:16 CEST 2012/



I want to predict the number of turtles for different levels of effort and
combinations of covariates. So, for my dataset from which I built the model,
would I compare sum(predict(ZIP,type="response")) to the observed bycatch to
compare numbers? In order to predict for the new data (called effort), would
I use sum(predict(ZIP,newdata=effort,type="response"))? I want to be certain
I am understanding the coding--this is my first time using the predict
function.

Thanks,

Laura




Laura
Why do you use the sum? If you use:

PredY <- predict(ZIP, type = "response") then you have predicted values for 
each of the rows in your effort data frame.
Job done.

You have an offset in your model, isn't it? You will need to choose values for 
this in the data frame effort as well.
Also double check that the offset is only in the count partat least that is 
what I would do.
Note that using an offset means that you assume that if sampling effort is 
doubled, your fish (?) numbers double.




If you fully want to understand what predict is doing, try to do it manually. 
Below is R code from Chapter 7 (Zero Inflation and GLMM with R)






M3 <- zeroinfl(ParrotFish ~ Depth + Slope + SQDistRck + DistSed + Swell + Chla 
+ SST,
dist = "poisson", link = "logit",
data = PF2)

Betas.logistic <- coef(M3, model = "zero")
X.logistic <- model.matrix(M3, model = "zero")
eta.logistic   <- X.logistic %*% Betas.logistic
p  <- exp(eta.logistic) / (1 + exp(eta.logistic))

Betas.log  <- coef(M3, model = "count")
X.log  <- model.matrix(M3, model = "count")
eta.log<- X.log %*% Betas.log
mu <- exp(eta.log)

ExpY   <-  mu * (1 - p)
VarY   <- (1 - p) * (mu + p * mu^2)



Instead of using model.matrix(M3), you could specify your own data frame with 
covariates.
Your effort. Something like:

M4 <- zeroinfl(ParrotFish ~ Depth + Slope   | SST,
dist = "poisson", link = "logit",
data = PF2)

betapois <- coef(M4, model = "count")
betaBin  <- coef(M4, model = "zero")

MyDataPois <- data.frame(Depth = blah blah,
  Slope = Blah blah)
MyDataBin  <- data.frame(SST =  blah)

Xpois <- model.matrix(~ blah blah, data = MyDataPois)
Xbin  <- model.matrix(~ blah blah, data = MyDataBin)

eta.Pois <- Xpois %*% betapois
eta.Bin <- blah blah

mu = blah blah
pi = blah blah

ExpY = ...


Doing it like this means you fully understand it..:-)
   

Alain




-- 

Dr. Alain F. Zuur
First author of:

1. Analysing Ecological Data (2007).
Zuur, AF, Ieno, EN and Smith, GM. Springer. 680 p.
URL: www.springer.com/0-387-45967-7


2. Mixed effects models and extensions in ecology with R. (2009).
Zuur, AF, Ieno, EN, Walker, N, Saveliev, AA, and Smith, GM. Springer.
http://www.springer.com/life+sci/ecology/book/978-0-387-87457-9


3. A Beginner's Guide to R (2009).
Zuur, AF, Ieno, EN, Meesters, EHWG. Springer
http://www.springer.com/statistics/computational/book/978-0-387-93836-3


4. Zero Inflated Models and Generalized Linear Mixed Models with R. (2012) 
Zuur, Saveliev, Ieno.
http://www.highstat.com/book4.htm

Other books: http://www.highstat.com/books.htm


Statistical consultancy, courses, data analysis and software
Highland Statistics Ltd.
6 Laverock road
UK - AB41 6FN Newburgh
Tel: 0044 1358 788177
Email: highs...@highstat.com
URL: www.highstat.com
URL: www.brodgar.com


[[alternative HTML version deleted]]

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


Re: [R] R to winbugs interface

2012-07-10 Thread Uwe Ligges



On 09.07.2012 19:27, PRAGYA SUR wrote:

Yes that was the problem. Thank you very much. Can anyone tell me the
meaning of
The following object(s) are masked _by_ '.GlobalEnv':

 beta



It means you have two instances of "beta", one in your workspace 
('.GlobalEnv') and one that is probably in some data.frame that was 
attached to the search path.


Best,
Uwe Ligges



i was shown this notification after the results were printed.

On Mon, Jul 9, 2012 at 1:15 PM, Uwe Ligges
mailto:lig...@statistik.tu-dortmund.de>> wrote:



On 09.07.2012 18:19, PRAGYA SUR wrote:

I ran the same program in a different computer where it had run
proper a
week ago. This time around in the log file in WinBUGS the
program stopped
at a line which said :
save(C:/DOCUME~1/ADMINI~1/__LOCALS~1/Temp/RtmpU3u46p/log.__odc)
save(C:/DOCUME~1/ADMINI~1/__LOCALS~1/Temp/RtmpU3u46p/log.__txt)
and did not proceed any further.
Can anyone tell me what migh tbe the possible error here?


Although unstated, I guess it was finished and did not close because
you used bugs(., debug=TRUE)?

Uwe Ligges


On Mon, Jul 9, 2012 at 7:04 AM, S Ellison
mailto:s.elli...@lgcgroup.com>> wrote:



-Original Message-
Error in file(con, "wb") : cannot open the connection In
addition: Warning messages:
1: In file.create(to[okay]) :
cannot create file 'c:/Program
Files/WinBUGS14//System/Rsrc/__Registry_Rsave.odc', reason
'Permission denied'


This tells you that you do not have operating system
permission to create
a file in the program files area referred to.

2: In file(con, "wb") :
cannot open file 'c:/Program
Files/WinBUGS14//System/Rsrc/__Registry.odc':
Permission denied


.. and this tells you you don't have permission to open a
file for writing
(mode 'w' in the same location

Conclusion; you're trying to write to an area you don;t have
permission to
write to.

Either change the permissions for that area (insecure) or
use a different
file location for temporary files.


**__**__***
This email and any attachments are confidential. Any
u...{{dropped:11}}



R-help@r-project.org  mailing list
https://stat.ethz.ch/mailman/__listinfo/r-help

PLEASE do read the posting guide
http://www.R-project.org/__posting-guide.html

and provide commented, minimal, self-contained, reproducible code.





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


[R] calculating the difference between days?

2012-07-10 Thread C W
Hi List,

I have one column of beginning dates and one column of ending dates, I want
to find their difference.  And I want to ignore the trailing zeros,
basically everything after the first colon mark.

Begin_date   End_date
01JAN2000:00:00:00:000   02FEB2002:00:00:00:000
24MAR2012:00:00:00:000   18MAY2012:00:00:00:000
01OCT2003:00:00:00:000   02FEB2004:00:00:00:000
01JAN2000:00:00:00:000   02FEB2000:00:00:00:000
01JAN2000:00:00:00:000   02FEB2000:00:00:00:000

Thanks,

Mike

[[alternative HTML version deleted]]

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


Re: [R] Extracting arithmetic mean for specific values from multiple .txt-files

2012-07-10 Thread vimmster
Dear Rui,

thank you very much.

Your solution works perfectly.

One last question:

I need to write a function, with ONE value (here: a ratio) for the correct
reactions divided per trials or trialCount, respectively, FOR EACH test
subject.

"/" means "divided by" in the following.

I need the ratio correct (reactions)/trial or correct
(reactions)/trialCount, respectively (because trial and trialCount are the
same WITHIN test SUBJECTS; BUT they differ in length between BETWEEN test
SUBJECTS!).

It would be very helpful, if I had a data frame in the end in R, with one
column for
"trialCount"/"trial", one column for "correct reactions"(= 1) AND (more
importantly) one column for "correct (= 1) answers / trialCount".

legend (just as additional information) for the variable "correct":
1 = correct reaction
2 = false reaction
3 = reaction too slow
4 = reaction too fast
5 = more than one button pressed
6 = no reaction within RT window

I would be very thankful for an answer!

Sorry for the questions, but I am doing this for the first time!

Kind regards

--
View this message in context: 
http://r.789695.n4.nabble.com/Extracting-arithmetic-mean-for-specific-values-from-multiple-txt-files-tp4635809p4636020.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Questions about doing analysis based on time

2012-07-10 Thread Rui Barradas

Hello,

You can use cut.POSIXt from package base.

cut(dat$SunDate, breaks="30 mins")


Hope this helps,

Rui Barradas

Em 10-07-2012 13:43, APOCooter escreveu:

Thanks to everyone for their help so far.  It's been greatly appreciated.  I
have a new, but similar problem:

I have data that I have broken down by hour (median/mean for each hour).  I
would like to break it down further, by each half hour (0:00-0:29,
0:30-0:59, 1:00-1:29, 1:30-1:59, etc).  I thought cut.dates() from the chron
package would be able to do it, but I can't find anything in the chron
package documention.  I'm fairly certain that if I can figure out how to
break down the data by half hour that I can do all the other analysis just
fine (median/mean for each half hour, etc)


Here is a small sample of the data:


dput(head(SundayData, 100))

structure(list(SunDate = structure(c(1273377600, 1307851200,
1213502640, 1217736420, 1311480420, 1211688540, 1337487060, 1255839120,
1268543520, 1293945120, 1280635980, 1309061640, 1322975640, 1297574280,
1221970740, 1253420340, 1218946800, 1329024060, 1290316920, 1224994980,
1218342420, 1269750420, 1257658080, 1322371680, 1214108940, 1312086540,
1260077400, 1228023060, 1315110660, 1281241920, 1272774960, 1224995820,
1275194220, 1246768860, 1302410460, 1234071780, 1305434580, 1232257500,
1243140300, 1284871500, 1247373960, 1265521560, 1273985160, 1310273160,
1226209620, 1270356420, 1330235280, 1222577400, 1310878200, 1324187400,
1242535860, 1336279860, 1283057520, 1291528320, 1324187580, 1330840380,
1298786100, 1307854500, 1236491880, 1298786280, 1233468180, 1280034240,
1230444300, 1213506360, 1251608760, 1215320820, 1304226420, 1320556080,
1299391740, 1286687580, 1296972780, 1296972780, 1321164780, 1260684960,
1315113420, 1287292680, 1292134800, 1303017600, 1307251200, 1278825720,
1238304180, 1212902640, 1231655100, 1254029100, 1311485100, 1295159160,
1220160420, 1297578540, 1300599000, 1241933640, 1225604100, 1269149880,
1283665140, 1244958120, 1245562980, 1289716980, 1235890020, 1282456080,
1279432140, 1279432140), class = c("POSIXct", "POSIXt"), tzone = ""),
 SunTime = structure(c(1L, 1L, 2L, 3L, 3L, 4L, 5L, 6L, 6L,
 6L, 7L, 8L, 8L, 9L, 10L, 10L, 11L, 12L, 13L, 14L, 15L, 15L,
 16L, 16L, 17L, 17L, 18L, 19L, 19L, 20L, 21L, 22L, 22L, 23L,
 23L, 24L, 24L, 25L, 25L, 25L, 26L, 26L, 26L, 26L, 27L, 27L,
 28L, 29L, 29L, 29L, 30L, 30L, 31L, 31L, 32L, 32L, 33L, 33L,
 34L, 34L, 35L, 36L, 37L, 38L, 38L, 39L, 39L, 40L, 41L, 42L,
 42L, 42L, 42L, 43L, 44L, 45L, 46L, 46L, 46L, 47L, 48L, 49L,
 50L, 50L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L,
 60L, 60L, 61L, 62L, 63L, 63L), .Label = c("0:00", "0:04",
 "0:07", "0:09", "0:11", "0:12", "0:13", "0:14", "0:18", "0:19",
 "0:20", "0:21", "0:22", "0:23", "0:27", "0:28", "0:29", "0:30",
 "0:31", "0:32", "0:36", "0:37", "0:41", "0:43", "0:45", "0:46",
 "0:47", "0:48", "0:50", "0:51", "0:52", "0:53", "0:55", "0:58",
 "1:03", "1:04", "1:05", "1:06", "1:07", "1:08", "1:09", "1:13",
 "1:16", "1:17", "1:18", "1:20", "1:22", "1:23", "1:24", "1:25",
 "1:26", "1:27", "1:29", "1:30", "1:34", "1:35", "1:38", "1:39",
 "1:42", "1:43", "1:47", "1:48", "1:49", "1:52", "1:54", "1:55",
 "1:56", "1:57", "1:59", "10:00", "10:04", "10:07", "10:08",
 "10:09", "10:10", "10:11", "10:12", "10:14", "10:15", "10:16",
 "10:18", "10:20", "10:22", "10:23", "10:24", "10:25", "10:26",
 "10:27", "10:28", "10:30", "10:31", "10:32", "10:33", "10:34",
 "10:35", "10:36", "10:37", "10:38", "10:39", "10:40", "10:41",
 "10:43", "10:44", "10:45", "10:47", "10:48", "10:49", "10:50",
 "10:51", "10:53", "10:54", "10:55", "10:56", "10:58", "10:59",
 "11:01", "11:02", "11:05", "11:06", "11:07", "11:09", "11:10",
 "11:12", "11:14", "11:15", "11:16", "11:20", "11:21", "11:22",
 "11:23", "11:24", "11:26", "11:27", "11:29", "11:30", "11:31",
 "11:33", "11:34", "11:35", "11:36", "11:37", "11:38", "11:39",
 "11:40", "11:43", "11:44", "11:46", "11:47", "11:49", "11:52",
 "11:56", "11:58", "11:59", "12:00", "12:01", "12:02", "12:03",
 "12:04", "12:05", "12:06", "12:07", "12:08", "12:09", "12:10",
 "12:11", "12:13", "12:14", "12:15", "12:17", "12:19", "12:21",
 "12:22", "12:24", "12:25", "12:26", "12:27", "12:28", "12:30",
 "12:31", "12:32", "12:34", "12:36", "12:37", "12:38", "12:39",
 "12:41", "12:45", "12:46", "12:47", "12:48", "12:49", "12:50",
 "12:51", "12:53", "12:54", "12:55", "12:56", "12:57", "12:58",
 "12:59", "13:00", "13:01", "13:02", "13:03", "13:04", "13:05",
 "13:06", "13:07", "13:08", "13:09", "13:10", "13:12", "13:13",
 "13:14", "13:15", "13:17", "13:18", "13:19", "13:20", "13:21",
 "13:23", "13:25", "13:26", "13:27", "13:30", "13:31", "13:32",
 "13:34", "13:35", "13:36", "13:38", "13:39", "13:40", "13:44",
 "13:45", "13:46", "13:47", "13:48", "13:49", "13:50", "13:51",
 "13:52", "13:53", "13:54", "13:55", "13:57", "13:58", "1

Re: [R] Use of Sappy and Tappy for Mathematical Calculation

2012-07-10 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Rantony
> Sent: Tuesday, July 10, 2012 3:17 AM
> To: r-help@r-project.org
> Subject: [R] Use of Sappy and Tappy for Mathematical Calculation
> 
> Hi,
> 
> i have a matrix like this,
> 
> ABCXYZ...   .
> - --
> 1220  ...   .
> 2435  ...   .
> 3040  ...   .
> 
> Here, i need to get
>Sum of each columns,
>Mean of each columns,
>median of each columns,
>mode of each columns,
>Standard deviation  of each columns,
>variance of each columns,
>range of each columns,
>count of each columns,
>max of each columns,
>min of each columns
> 
> Can i get output using sappy or tappy functions ? because there have
> alots
> of records.
> 
> Could you please help me fast its kind of urgent !
> 
> - Thanks
> Antony
> 

Here is some code to get you started.  You can add in the other functions that 
you want.  You will need to figure out what you want to do if there are missing 
values.  There are built-in functions for most everything you want.  You get 
the range from the min and the max, and you need to decide what to do if a 
variable has 2 or more modes (you  will also need to determine how you are 
going to get the mode).

 
# here is sample matrix
mat <- matrix(1:100,nrow=10)
colnames(mat) <- LETTERS[1:10]

# define summarize function
summarize <- function(m) {
  sums <- apply(m, 2, sum)
  counts <- apply(m, 2, length)
  means <- apply(m, 2, mean)
  return(rbind(sums, counts, means))
}

# summarize your matrix
summarize(mat)


Hope this is helpful,

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204


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


Re: [R] Predicted values for zero-inflated Poisson

2012-07-10 Thread Laura Lee
I want to predict the number of turtles for different levels of effort and
combinations of covariates. So, for my dataset from which I built the model,
would I compare sum(predict(ZIP,type="response")) to the observed bycatch to
compare numbers? In order to predict for the new data (called effort), would
I use sum(predict(ZIP,newdata=effort,type="response"))? I want to be certain
I am understanding the coding--this is my first time using the predict
function.

Thanks,

Laura

-
Laura M. Lee
Senior Stock Assessment Scientist
North Carolina Division of Marine Fisheries
E-Mail: laura@ncdenr.gov
--
View this message in context: 
http://r.789695.n4.nabble.com/Predicted-values-for-zero-inflated-Poisson-tp4635861p4636016.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Help with vectors and rollapply

2012-07-10 Thread William Dunlap
It looks like you already have the zoo package loaded so you can use its 
na.locf(),
which replaces NA's with the last non-NA value.  Convert the 0s to NAs with
replace() and feed the result into na.locf():
  a  <- c(-2,0,0,0,1,0,0,3,0,0,-4)
  aOut <- c(-2,-2,-2,-2,1,1,1,3,3,3,-4)
  na.locf(replace(a, a==0, NA) )
  #  [1] -2 -2 -2 -2  1  1  1  3  3  3 -4
  all.equal(aOut, .Last.value)
  # [1] TRUE

If you need to treat NA and 0 differently you will need to do more work.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf Of Raghuraman Ramachandran
> Sent: Tuesday, July 10, 2012 8:23 AM
> To: r-help@r-project.org
> Subject: [R] Help with vectors and rollapply
> 
> Hello
> 
> I have a vector a =(-2,0,0,0,1,0,0,3,0,0,-4)
> 
> I want to replace all zeros into previous non-zero state. So for instance the 
> above
> vector should be converted into:
> 
> a= (-2,-2,-2,-2,1,1,1,3,3,3,-4)
> 
> I tried many things and finally concluded that probably(?) rollapply may be 
> the best
> way?
> 
> I tried
> f= function(x){
> ifelse(x==0,Lag(x),x)
> }
> 
> And then, rollappy(a,1,f) and that didn't work. Can someone help please?
> 
> Thx
> R
> 
> 
> Jefferies archives and monitors outgoing and incoming e-mail. The contents of 
> this
> email, including any attachments, are confidential to the ordinary user of 
> the email
> address to which it was addressed. If you are not the addressee of this email 
> you may
> not copy, forward, disclose or otherwise use it or any part of it in any form
> whatsoever. Since the confidentiality of Internet e-mail cannot be guaranteed,
> please do not include private or confidential information (such as account 
> numbers)
> or instructions requiring your authorization (such as orders or funds 
> transfers) in your
> e-mail communication to us. This email may be produced at the request of 
> regulators
> or in connection with civil litigation. Jefferies accepts no liability for 
> any errors or
> omissions arising as a result of transmission. Although this transmission and 
> any
> attachments are believed to be free of any virus or other defect that might 
> affect any
> computer system into which it is received and opened, it is the!
>   responsibility of the recipient to ensure that it is virus free and no 
> responsibility is
> accepted by Jefferies, its subsidiaries and affiliates, as applicable, for 
> any loss or
> damage arising in any way from its use. In the United Kingdom, Jefferies 
> operates as
> Jefferies International Limited; registered in England: no. 1978621; and 
> Jefferies
> Bache Limited; registered in England: no. 114226; registered office for both: 
> Vintners
> Place, 68 Upper Thames Street, London EC4V 3BJ. Jefferies International 
> Limited and
> Jefferies Bache Limited are authorised and regulated by the Financial Services
> Authority. If you received this transmission in error, please immediately 
> contact the
> sender and destroy the material in its entirety, whether in electronic or 
> hard copy
> format. Thank you.
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


[R] RGL 3D curvilinear shapes

2012-07-10 Thread PatGauthier
Dear useRs, 

I'm trying to simply fill in the area under a curve using RGL. Here' the set
up:

x <- c(0.75,75.75,150.75,225.75,300.75,375.75,450.75,525.75,600.75,675.75,
   0.5,50.5,100.5,150.5,200.5,250.5,300.5,350.5,400.5,450.5,
   0.25,25.25,50.25,75.25,100.25,125.25,150.25,175.25,200.25,225.25)
y <- c(0.05,4.91,9.78,14.64,19.51,24.38,29.24,34.11,38.97,43.84,
   0.1,9.83,19.56,29.29,39.02,48.75,58.48,68.21,77.94,87.67,
   0.15,14.74,29.34,43.93,58.53,73.13,87.72,102.32,116.91,131.51)
z <- c(0.05,0.55,0.7,0.78,0.83,0.87,0.9,0.92,0.93,0.94,
   0,0.32,0.59,0.77,0.87,0.93,0.96,0.98,0.99,1,
   0,0.39,0.66,0.82,0.9,0.95,0.97,0.99,0.99,1)

dat <- data.frame(x = x, y = y, z = z, ID = c(rep(c(1,2,3),each=10)))

plot3d(dat, type = "n", ylab = "", xlab = "", zlab = "", axes = F, ylim =
c(0,200))
lines3d(dat[1:10,])
lines3d(dat[11:20,])
lines3d(dat[21:30,])

axes3d(edge = c("x--", "y-+", "z--"), nticks = 5, ylim = c(0,200))
bbox3d(color = c("black", "white"), lit = F, back = "line")

Any ideas/tips on how to do this?

thanks in advance, 

Patrick

--
View this message in context: 
http://r.789695.n4.nabble.com/RGL-3D-curvilinear-shapes-tp4636011.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Count of elements in coulmns of a matrix

2012-07-10 Thread arun
Hi,

Try this:

list1<-list(ABC=c(2,5),XYZ=c(3,4,4,2),PQR=c(4,5,3))
> lapply(list1,function(x) length(x))
$ABC
[1] 2

$XYZ
[1] 4

$PQR
[1] 3

 list2<-lapply(list1,function(x) length(x))
 dat2<-data.frame(list2)
 dat2
  ABC XYZ PQR
1   2   4   3
A.K.



- Original Message -
From: Rantony 
To: r-help@r-project.org
Cc: 
Sent: Tuesday, July 10, 2012 8:31 AM
Subject: [R] Count of elements in coulmns of a matrix

Could you please tell me what is the function or method to get count of
elements in all the columns in a matrix ?

for eg :-

ABC      XYZ    PQR
--      -     --
2            3            4
               4           5
5            4           3
              2

Result will be like
ABC      XYZ    PQR
--      -     --
2             4            3

Could you please help me ?

--
View this message in context: 
http://r.789695.n4.nabble.com/Count-of-elements-in-coulmns-of-a-matrix-tp4635979.html
Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] multiple comparisons with generalised least squares

2012-07-10 Thread Ariel

racmar wrote
> 
> I have also been searching various forums and books to see if there are
> any methods I could use and have only found people, such as yourself,
> asking the same question. 
> 

I was looking into this recently, as well, and found that the problem has to
do with building the model.matrix/terms/model.frame for gls objects when
using the glht function.  I ended up creating three gls-specific functions
and was able to get estimates/confidence intervals for the toy example
below.   You may find these functions useful (under the caveat that I only
checked that I got estimates and not that the estimates were correct ;) ).

Ariel

Example:
library(nlme)

Orthodont$fage <- factor(Orthodont$age)

#toy example with Orthodont data using age as a factor
fitgls <- gls( distance ~ fage, data=Orthodont, 
weights = varIdent(form =~1|fage))



library(multcomp)

#notice the error about the model.matrix for gls objects when using glht
confint( glht (fitgls, mcp(fage="Tukey") ))

#create model.frame, terms, and model.matrix functions specifically for gls
objects
model.matrix.gls <- function(object, ...) 
model.matrix(terms(object), data = getData(object), ...)


model.frame.gls <- function(object, ...) 
model.frame(formula(object), data = getData(object), ...)


terms.gls <- function(object, ...) 
terms(model.frame(object),...)


#now run glht again
confint( glht(  fitgls, mcp(fage="Tukey") ))




--
View this message in context: 
http://r.789695.n4.nabble.com/multiple-comparisons-with-generalised-least-squares-tp3441513p4636009.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Help with vectors and rollapply

2012-07-10 Thread Raghuraman Ramachandran
Hello

I have a vector a =(-2,0,0,0,1,0,0,3,0,0,-4)

I want to replace all zeros into previous non-zero state. So for instance the 
above vector should be converted into:

a= (-2,-2,-2,-2,1,1,1,3,3,3,-4)

I tried many things and finally concluded that probably(?) rollapply may be the 
best way?

I tried
f= function(x){
ifelse(x==0,Lag(x),x)
}

And then, rollappy(a,1,f) and that didn't work. Can someone help please?

Thx
R


Jefferies archives and monitors outgoing and incoming e-mail. The contents of 
this email, including any attachments, are confidential to the ordinary user of 
the email address to which it was addressed. If you are not the addressee of 
this email you may not copy, forward, disclose or otherwise use it or any part 
of it in any form whatsoever. Since the confidentiality of Internet e-mail 
cannot be guaranteed, please do not include private or confidential information 
(such as account numbers) or instructions requiring your authorization (such as 
orders or funds transfers) in your e-mail communication to us. This email may 
be produced at the request of regulators or in connection with civil 
litigation. Jefferies accepts no liability for any errors or omissions arising 
as a result of transmission. Although this transmission and any attachments are 
believed to be free of any virus or other defect that might affect any computer 
system into which it is received and opened, it is the!
  responsibility of the recipient to ensure that it is virus free and no 
responsibility is accepted by Jefferies, its subsidiaries and affiliates, as 
applicable, for any loss or damage arising in any way from its use. In the 
United Kingdom, Jefferies operates as Jefferies International Limited; 
registered in England: no. 1978621; and Jefferies Bache Limited; registered in 
England: no. 114226; registered office for both: Vintners Place, 68 Upper 
Thames Street, London EC4V 3BJ. Jefferies International Limited and Jefferies 
Bache Limited are authorised and regulated by the Financial Services Authority. 
If you received this transmission in error, please immediately contact the 
sender and destroy the material in its entirety, whether in electronic or hard 
copy format. Thank you.

[[alternative HTML version deleted]]

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


Re: [R] fill 0-row data.frame with 1 line of NAs

2012-07-10 Thread Brian Diggs

On 7/10/2012 7:53 AM, Peter Ehlers wrote:

On 2012-07-10 06:57, Rui Barradas wrote:

Hello,

If you write a function, it becomes less convoluted...


empty <- function(x){
if(NROW(x) == 0){
y <- rep(NA, NCOL(x))
names(y) <- names(x)
y
}else x
}

(.xb <- iris[ iris$Species=='zz', ])
empty(.xb)


Both this and Liviu's original solution destroy the
factor nature of 'Species' (which may not matter, of
course). How about

   (.xb <- iris[ iris$Species=='zz', ])
   .xb <- .xb[1, ]   # this probably shouldn't work, but it does.


Using NA subscripting seems even better

empty <- function(x) {
  if(NROW(x) == 0) {
x[NA,]
  } else {
x
  }
}

It even preserves the factor nature of things:

> empty(iris[iris$Specis=='zz',])
   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
NA   NA  NA   NA  NA
> str(empty(iris[iris$Specis=='zz',]))
'data.frame':   1 obs. of  5 variables:
 $ Sepal.Length: num NA
 $ Sepal.Width : num NA
 $ Petal.Length: num NA
 $ Petal.Width : num NA
 $ Species : Factor w/ 3 levels "setosa","versicolor",..: NA



?

Peter Ehlers




Hope this helps,

Rui Barradas

Em 10-07-2012 14:15, Liviu Andronic escreveu:

Dear all
Is there a simpler method to achieve the following: When I obtain an
empty data.frame after subsetting, I need for it to contain one line
of NAs. Here's a dummy example:

(.xb <- iris[ iris$Species=='zz', ])

[1] Sepal.Length Sepal.Width  Petal.Length Petal.Width  Species
<0 rows> (or 0-length row.names)

dim(.xb)

[1] 0 5

(.xa <- data.frame(matrix(rep(NA, ncol(.xb)), 1)))

X1 X2 X3 X4 X5
1 NA NA NA NA NA

names(.xa) <- names(.xb)
(.xb <- .xa)

Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1   NA  NA   NA  NA  NA


The solution I came up with is way too convoluted. Anything simpler?
Regards
Liviu




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






--
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health & Science University

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


Re: [R] define stuff to be only usable in the same file

2012-07-10 Thread Jessica Streicher

On 10.07.2012, at 16:45, Jessica Streicher wrote:

> 
> On 10.07.2012, at 15:24, Duncan Murdoch wrote:
> 
>> On 12-07-10 9:13 AM, Jessica Streicher wrote:
>>> Hello R-Help!
>>> 
>>> I've looked around and have not found:
>>> 
>>> A simple(short) way to hide functions and variables from the global 
>>> environment. What i want is for a few of them to only be accessable from 
>>> the scriptfile they're in. I probably could do fun things with environments 
>>> , but that seems quite a hassle.
>> 
>> The simplest and best way to do this is to write a package.  
> 
> After an hour i can say it is neither simple nor short nor will it work at 
> all at the moment
> 
> ERROR
> cannot change to directory 'testpack'
> 
> -> tried to use the build command from pretty much everywhere

Forget about that, i'm stupid and can't use the tools available...

> 
>> You can also use local() around the code in a script, but it gets messy when 
>> you want to export more than one thing.
> 
> I think local isn't quite what i imagined.
> 
>> 
>> Duncan Murdoch
>> 
>>> As example: I have a file that gets me stuff from the database and creates 
>>> an R object from the results, plus some functions on that object. Now i 
>>> want the objectrelated stuff to be global, while the functions and 
>>> variables i use for accessing the database shall be hidden.
>> 
>> 
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] fill 0-row data.frame with 1 line of NAs

2012-07-10 Thread Peter Ehlers

On 2012-07-10 06:57, Rui Barradas wrote:

Hello,

If you write a function, it becomes less convoluted...


empty <- function(x){
if(NROW(x) == 0){
y <- rep(NA, NCOL(x))
names(y) <- names(x)
y
}else x
}

(.xb <- iris[ iris$Species=='zz', ])
empty(.xb)


Both this and Liviu's original solution destroy the
factor nature of 'Species' (which may not matter, of
course). How about

  (.xb <- iris[ iris$Species=='zz', ])
  .xb <- .xb[1, ]   # this probably shouldn't work, but it does.

?

Peter Ehlers




Hope this helps,

Rui Barradas

Em 10-07-2012 14:15, Liviu Andronic escreveu:

Dear all
Is there a simpler method to achieve the following: When I obtain an
empty data.frame after subsetting, I need for it to contain one line
of NAs. Here's a dummy example:

(.xb <- iris[ iris$Species=='zz', ])

[1] Sepal.Length Sepal.Width  Petal.Length Petal.Width  Species
<0 rows> (or 0-length row.names)

dim(.xb)

[1] 0 5

(.xa <- data.frame(matrix(rep(NA, ncol(.xb)), 1)))

X1 X2 X3 X4 X5
1 NA NA NA NA NA

names(.xa) <- names(.xb)
(.xb <- .xa)

Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1   NA  NA   NA  NA  NA


The solution I came up with is way too convoluted. Anything simpler? Regards
Liviu




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



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


Re: [R] Mac OS X R uninstallation question

2012-07-10 Thread Prof Brian Ripley

Please ask Mac-specific questions on R-sig-mac.

In particular, it is a little odd that these are not getting deleted 
when you install a new version.


But *if all your packages are up to date* you do not need earlier 
versions of R.framework, so run


update.packages(checkBuilt=TRUE)

first.

On 10/07/2012 11:55, Alastair wrote:

Hi,

I've been using R for a number of years and have always installed the newest
version when released. However I've just noticed that old versions of R are
taking up quite a lot of disk space.

lap-alastair:/ alastair$ du -h -d 1
/Library/Frameworks/R.framework/Versions/
266M/Library/Frameworks/R.framework/Versions/2.10
204M/Library/Frameworks/R.framework/Versions/2.11
459M/Library/Frameworks/R.framework/Versions/2.12
511M/Library/Frameworks/R.framework/Versions/2.13
478M/Library/Frameworks/R.framework/Versions/2.14
217M/Library/Frameworks/R.framework/Versions/2.15
32K /Library/Frameworks/R.framework/Versions/2.5
5.5M/Library/Frameworks/R.framework/Versions/2.6
84M /Library/Frameworks/R.framework/Versions/2.8
2.2G/Library/Frameworks/R.framework/Versions/

Do I need to keep any of the versions before the current (2.15). If I delete
all the previous versions will that have any impact on the current
installation, or is each version entirely self-contained?

Thanks.



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] define stuff to be only usable in the same file

2012-07-10 Thread Jessica Streicher

On 10.07.2012, at 15:24, Duncan Murdoch wrote:

> On 12-07-10 9:13 AM, Jessica Streicher wrote:
>> Hello R-Help!
>> 
>> I've looked around and have not found:
>> 
>> A simple(short) way to hide functions and variables from the global 
>> environment. What i want is for a few of them to only be accessable from the 
>> scriptfile they're in. I probably could do fun things with environments , 
>> but that seems quite a hassle.
> 
> The simplest and best way to do this is to write a package.  

After an hour i can say it is neither simple nor short nor will it work at all 
at the moment

 ERROR
cannot change to directory 'testpack'

-> tried to use the build command from pretty much everywhere

> You can also use local() around the code in a script, but it gets messy when 
> you want to export more than one thing.

I think local isn't quite what i imagined.

> 
> Duncan Murdoch
> 
>> As example: I have a file that gets me stuff from the database and creates 
>> an R object from the results, plus some functions on that object. Now i want 
>> the objectrelated stuff to be global, while the functions and variables i 
>> use for accessing the database shall be hidden.
> 
> 


[[alternative HTML version deleted]]

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


Re: [R] Count of elements in coulmns of a matrix

2012-07-10 Thread Sarah Goslee
It depends: what's in those "empty" space?

Some combination of apply() and something else, depending on what your
matrix *actually* looks like, and here dput() would be vastly
preferable to copy and paste of something that didn't even come from
an R session.

The something else might involve length() or is.na() or, well, other
possibilities but my telepathy is on the fritz today.

Sarah

On Tue, Jul 10, 2012 at 8:31 AM, Rantony  wrote:
> Could you please tell me what is the function or method to get count of
> elements in all the columns in a matrix ?
>
> for eg :-
>
> ABC  XYZPQR
> --  - --
> 234
>4   5
> 54   3
>   2
>
> Result will be like
> ABC  XYZPQR
> --  - --
> 2 43
>
> Could you please help me ?
>

-- 
Sarah Goslee
http://www.functionaldiversity.org

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


[R] gdata: Problem reading excel document containing non-US characters

2012-07-10 Thread Rolf Marvin Bøe Lindgren
I am using the gdata package to read in an Excel document. read.xls chokes on a 
“foreign” character.  Here's the original code:

   require(gdata)
   dendro <- read.xls("/tmp/avitot.xlsv3WiXg",fileEncoding="Latin1")

Now, the fileEncoding="Latin1" ought to work, because if i copy the code for 
read.xls, and edit

   retval <- read.csv(con, na.strings = na.strings, ...)

appropriately, to include fileEncoding="Latin1" and include the definition to 
override read.xls (to those who wish to test this: you need to include findPerl 
as well), then it works.

but from the code, seems plain that read.xls should pass the 
‘fileEncoding="Latin1"’ all the way to when read.csv is called.

So I don't know if this is a bug, or if I have misuderstood something. 

Is there a better way to achieve this than to edit and override read.xls?  

Any and all suggestions are welcome. 

Thank you,


-- 
Rolf Marvin Bøe Lindgren
r...@grendel.no
http:/www.grendel.no/

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


[R] Count of elements in coulmns of a matrix

2012-07-10 Thread Rantony
Could you please tell me what is the function or method to get count of
elements in all the columns in a matrix ?

for eg :-

ABC  XYZPQR
--  - --
234
   4   5
54   3
  2

Result will be like
ABC  XYZPQR
--  - --
2 43

Could you please help me ?

--
View this message in context: 
http://r.789695.n4.nabble.com/Count-of-elements-in-coulmns-of-a-matrix-tp4635979.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Questions about doing analysis based on time

2012-07-10 Thread APOCooter
Thanks to everyone for their help so far.  It's been greatly appreciated.  I
have a new, but similar problem:

I have data that I have broken down by hour (median/mean for each hour).  I
would like to break it down further, by each half hour (0:00-0:29,
0:30-0:59, 1:00-1:29, 1:30-1:59, etc).  I thought cut.dates() from the chron
package would be able to do it, but I can't find anything in the chron
package documention.  I'm fairly certain that if I can figure out how to
break down the data by half hour that I can do all the other analysis just
fine (median/mean for each half hour, etc)


Here is a small sample of the data:

> dput(head(SundayData, 100))
structure(list(SunDate = structure(c(1273377600, 1307851200, 
1213502640, 1217736420, 1311480420, 1211688540, 1337487060, 1255839120, 
1268543520, 1293945120, 1280635980, 1309061640, 1322975640, 1297574280, 
1221970740, 1253420340, 1218946800, 1329024060, 1290316920, 1224994980, 
1218342420, 1269750420, 1257658080, 1322371680, 1214108940, 1312086540, 
1260077400, 1228023060, 1315110660, 1281241920, 1272774960, 1224995820, 
1275194220, 1246768860, 1302410460, 1234071780, 1305434580, 1232257500, 
1243140300, 1284871500, 1247373960, 1265521560, 1273985160, 1310273160, 
1226209620, 1270356420, 1330235280, 1222577400, 1310878200, 1324187400, 
1242535860, 1336279860, 1283057520, 1291528320, 1324187580, 1330840380, 
1298786100, 1307854500, 1236491880, 1298786280, 1233468180, 1280034240, 
1230444300, 1213506360, 1251608760, 1215320820, 1304226420, 1320556080, 
1299391740, 1286687580, 1296972780, 1296972780, 1321164780, 1260684960, 
1315113420, 1287292680, 1292134800, 1303017600, 1307251200, 1278825720, 
1238304180, 1212902640, 1231655100, 1254029100, 1311485100, 1295159160, 
1220160420, 1297578540, 1300599000, 1241933640, 1225604100, 1269149880, 
1283665140, 1244958120, 1245562980, 1289716980, 1235890020, 1282456080, 
1279432140, 1279432140), class = c("POSIXct", "POSIXt"), tzone = ""), 
SunTime = structure(c(1L, 1L, 2L, 3L, 3L, 4L, 5L, 6L, 6L, 
6L, 7L, 8L, 8L, 9L, 10L, 10L, 11L, 12L, 13L, 14L, 15L, 15L, 
16L, 16L, 17L, 17L, 18L, 19L, 19L, 20L, 21L, 22L, 22L, 23L, 
23L, 24L, 24L, 25L, 25L, 25L, 26L, 26L, 26L, 26L, 27L, 27L, 
28L, 29L, 29L, 29L, 30L, 30L, 31L, 31L, 32L, 32L, 33L, 33L, 
34L, 34L, 35L, 36L, 37L, 38L, 38L, 39L, 39L, 40L, 41L, 42L, 
42L, 42L, 42L, 43L, 44L, 45L, 46L, 46L, 46L, 47L, 48L, 49L, 
50L, 50L, 50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 
60L, 60L, 61L, 62L, 63L, 63L), .Label = c("0:00", "0:04", 
"0:07", "0:09", "0:11", "0:12", "0:13", "0:14", "0:18", "0:19", 
"0:20", "0:21", "0:22", "0:23", "0:27", "0:28", "0:29", "0:30", 
"0:31", "0:32", "0:36", "0:37", "0:41", "0:43", "0:45", "0:46", 
"0:47", "0:48", "0:50", "0:51", "0:52", "0:53", "0:55", "0:58", 
"1:03", "1:04", "1:05", "1:06", "1:07", "1:08", "1:09", "1:13", 
"1:16", "1:17", "1:18", "1:20", "1:22", "1:23", "1:24", "1:25", 
"1:26", "1:27", "1:29", "1:30", "1:34", "1:35", "1:38", "1:39", 
"1:42", "1:43", "1:47", "1:48", "1:49", "1:52", "1:54", "1:55", 
"1:56", "1:57", "1:59", "10:00", "10:04", "10:07", "10:08", 
"10:09", "10:10", "10:11", "10:12", "10:14", "10:15", "10:16", 
"10:18", "10:20", "10:22", "10:23", "10:24", "10:25", "10:26", 
"10:27", "10:28", "10:30", "10:31", "10:32", "10:33", "10:34", 
"10:35", "10:36", "10:37", "10:38", "10:39", "10:40", "10:41", 
"10:43", "10:44", "10:45", "10:47", "10:48", "10:49", "10:50", 
"10:51", "10:53", "10:54", "10:55", "10:56", "10:58", "10:59", 
"11:01", "11:02", "11:05", "11:06", "11:07", "11:09", "11:10", 
"11:12", "11:14", "11:15", "11:16", "11:20", "11:21", "11:22", 
"11:23", "11:24", "11:26", "11:27", "11:29", "11:30", "11:31", 
"11:33", "11:34", "11:35", "11:36", "11:37", "11:38", "11:39", 
"11:40", "11:43", "11:44", "11:46", "11:47", "11:49", "11:52", 
"11:56", "11:58", "11:59", "12:00", "12:01", "12:02", "12:03", 
"12:04", "12:05", "12:06", "12:07", "12:08", "12:09", "12:10", 
"12:11", "12:13", "12:14", "12:15", "12:17", "12:19", "12:21", 
"12:22", "12:24", "12:25", "12:26", "12:27", "12:28", "12:30", 
"12:31", "12:32", "12:34", "12:36", "12:37", "12:38", "12:39", 
"12:41", "12:45", "12:46", "12:47", "12:48", "12:49", "12:50", 
"12:51", "12:53", "12:54", "12:55", "12:56", "12:57", "12:58", 
"12:59", "13:00", "13:01", "13:02", "13:03", "13:04", "13:05", 
"13:06", "13:07", "13:08", "13:09", "13:10", "13:12", "13:13", 
"13:14", "13:15", "13:17", "13:18", "13:19", "13:20", "13:21", 
"13:23", "13:25", "13:26", "13:27", "13:30", "13:31", "13:32", 
"13:34", "13:35", "13:36", "13:38", "13:39", "13:40", "13:44", 
"13:45", "13:46", "13:47", "13:48", "13:49", "13:50", "13:51", 
"13:52", "13:53", "13:54", "13:55", "13:57", "13:58", "13:59", 
"14:00", "14:01", "14:02", "14:04", "14:05", "14:06", "14:07", 
"14:08", "14:11", "14:12", "14:13", "14:14", "14:15", "14:16", 
  

[R] Mac OS X R uninstallation question

2012-07-10 Thread Alastair
Hi,

I've been using R for a number of years and have always installed the newest
version when released. However I've just noticed that old versions of R are
taking up quite a lot of disk space.

lap-alastair:/ alastair$ du -h -d 1
/Library/Frameworks/R.framework/Versions/
266M/Library/Frameworks/R.framework/Versions/2.10
204M/Library/Frameworks/R.framework/Versions/2.11
459M/Library/Frameworks/R.framework/Versions/2.12
511M/Library/Frameworks/R.framework/Versions/2.13
478M/Library/Frameworks/R.framework/Versions/2.14
217M/Library/Frameworks/R.framework/Versions/2.15
32K /Library/Frameworks/R.framework/Versions/2.5
5.5M/Library/Frameworks/R.framework/Versions/2.6
84M /Library/Frameworks/R.framework/Versions/2.8
2.2G/Library/Frameworks/R.framework/Versions/

Do I need to keep any of the versions before the current (2.15). If I delete
all the previous versions will that have any impact on the current
installation, or is each version entirely self-contained? 

Thanks.


--
View this message in context: 
http://r.789695.n4.nabble.com/Mac-OS-X-R-uninstallation-question-tp4635971.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] fitting power growth

2012-07-10 Thread Thomas Hoffmann

Dear all

I am using the x and y vectors as defined below and want do to a power 
law regression:


y = a x^b

using
> lm(log(y)~log(x))

gives reasonable values (b=1.23) but is not very popular due to biases 
of back-transformation from log to non-log values.  Using


> nls(y~a*x^b,start=list(a=100,b=1.23))

is statistically more correct but gives a too large "a" value and a too 
small "b" value.



Doe anybody have a better way to solve the above power-law regression 
(using for instance maximum likely hood or anything else).


Kind regards for your help
Thomas



> x
 [1]   744.90   806.40   838.00   910.70  1818.60  2870.10  4070.00 
4476.80  4857.60  4858.10
[11]  5916.40 13970.80 27306.60 28226.60  2532.10  2658.40 18863.10   
758.0054.0079.00
[21]   139.0046.70  1003.0024.00   106.00   186.00 1503.00   
228.0010.24   162.00

[31]   381.70   312.60   209.00   246.00   221.20  1151.55
> y
 [1] 1.500e+08 2.850e+08 1.800e+08 1.800e+08 6.300e+08 7.200e+08 
1.170e+09 1.095e+09 1.620e+09
[10] 4.650e+09 1.575e+09 4.200e+09 7.755e+09 8.745e+09 9.900e+08 
6.600e+08 1.077e+10 3.450e+08
[19] 1.350e+07 2.550e+07 6.600e+07 6.000e+06 3.300e+07 1.500e+06 
4.500e+06 7.500e+06 2.415e+08
[28] 6.900e+07 9.000e+05 9.450e+06 3.510e+07 4.880e+07 3.100e+06 
1.930e+07 2.270e+07 5.270e+07


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


[R] Use of Sappy and Tappy for Mathematical Calculation

2012-07-10 Thread Rantony
Hi,

i have a matrix like this,

ABCXYZ...   .
- --
1220  ...   .
2435  ...   .
3040  ...   .

Here, i need to get 
   Sum of each columns,
   Mean of each columns, 
   median of each columns,
   mode of each columns, 
   Standard deviation  of each columns, 
   variance of each columns, 
   range of each columns,
   count of each columns,
   max of each columns, 
   min of each columns

Can i get output using sappy or tappy functions ? because there have alots
of records.

Could you please help me fast its kind of urgent !

- Thanks 
Antony 

--
View this message in context: 
http://r.789695.n4.nabble.com/Use-of-Sappy-and-Tappy-for-Mathematical-Calculation-tp4635969.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] identify.hclust() doesn't cut tree at the vertical position of the mouse pointer

2012-07-10 Thread WATSON Mick
Dear All

According to the identify.hclust documentation the function "cuts the tree at 
the vertical position of the pointer and highlights the cluster containing the 
horizontal position of the pointer".

When I carry out this, the tree isn't cut where I click - in fact, there seems 
to be a limit below which I cannot go.

Consider the following code:

mat <- matrix(rnorm(5000), ncol=5)
hc <- hclust(dist(mat))
plot(hc)
identify(hc)

No matter where I click on the tree, I cannot cut below around about 5.   I can 
cut above that value, but not below.

Any help is much appreciated.

> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United 
Kingdom.1252LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
   
[5] LC_TIME=English_United Kingdom.1252

attached base packages:
[1] grid  stats graphics  grDevices utils datasets  methods   base  
   

other attached packages:
 [1] geneplotter_1.34.0   lattice_0.20-6   annotate_1.34.1  
AnnotationDbi_1.18.1 Biobase_2.16.0   BiocGenerics_0.2.0   
BiocInstaller_1.4.7  gplots_2.11.0MASS_7.3-18 
[10] KernSmooth_2.23-7caTools_1.13 bitops_1.0-4.1   
gdata_2.11.0 gtools_2.7.0

loaded via a namespace (and not attached):
[1] DBI_0.2-5  IRanges_1.14.4 RColorBrewer_1.0-5 RSQLite_0.11.1 
stats4_2.15.1  tools_2.15.1   XML_3.9-4.1xtable_1.7-0  

Thanks
Mick

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

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


[R] customize packages' help index ( 00index.html file )

2012-07-10 Thread Damien Georges

Hi all,

I'm writing my packages helps files and I'm not really satisfied by the 
visual results.


I'm would like to make subsections in a package "function help index" file.

I would like for example to put all S4 object documentation link 
together, then all the getters function.. and so on..


Does someone know if it's possible to do it?
Is it possible to define by myself the html/00index.html file that will 
be use in my package?


If it's not possible, how could I add the alphabetic subsections that 
exist in most of packages index help files?


Best,

Damien

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


Re: [R] image.plot transparent?

2012-07-10 Thread Prof Brian Ripley

On 10/07/2012 13:41, Sarah Goslee wrote:

This may be device and OS dependent, so please provide the information
requested in the posting guide, at a minimum the output of sessionInfo(). A
small reproducible example is also necessary.


I think not.  My guess is it is part of a package which we were not told 
('fields'), and this is the programmed behaviour in its two subcases.


But we'd need reproducible code (including which package) to be sure.

If this is fields, read ?poly.image.



Sarah

On Tuesday, July 10, 2012, Chris82 wrote:


Hi R users,

I have a maybe strange problem.

Normaly I do image.plot() with x,y coordinates and add=T and if I have some
NA values in my data matrix z, the color will be transparent of these
pixels.

But now I have a disorted coordinate system and x,y are a matrix. It works
also fine, but now NA values are white colored and not transparent anymore.

It is problematic if I have a secondary information underlying.

Is there any solution for this stuff?

Thanks!



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] Plotting rpart trees with long list of class members

2012-07-10 Thread Jean V Adams
Thanks.  Very helpful.

You can use the information from the splits in the first tree, to define a 
new grouping variable, which will simplify the plot:
suvar <- sort(unique(test_set$list_var))
test_set$var_grp <- as.factor(testtree$csplit[match(test_set$list_var, 
suvar)])
testtree2 <- rpart ( list_val ~ var_grp, data = test_set ) 
rpart.plot(testtree2, type=3) 

Not to other readers, you will need to load these packages, before running 
the code:
library(rpart)
library(rpart.plot)

Jean


MarkBeauchene  wrote on 07/09/2012 03:42:32 PM:
> Here is some sample code.  It generates a class (list_var) that is used 
in
> rpart.  list_val is the dependant variable.
> 
> The plot shows all the values of the class, which is a mess and makes 
the
> plot unuseable.  I'd like to either suppress the list entirely or 
replace it
> with something like "Group 1", "Group 2", etc.
> 
> list_var <- rep(NA,2000)
> list_val <- rep(NA,2000)
> for (i in 1:1000) {
> list_var[i] <- paste("A",i%/%25,sep='')
> list_val[i] <- runif(1,0,1) }
> test_set <- data.frame(list_var, list_val )
> 
> 
> 
> 
> testtree <- rpart ( list_val ~ list_var, data = test_set )
> rpart.plot(testtree, type=3)

[[alternative HTML version deleted]]

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


Re: [R] fill 0-row data.frame with 1 line of NAs

2012-07-10 Thread Rui Barradas

Hello,

If you write a function, it becomes less convoluted...


empty <- function(x){
if(NROW(x) == 0){
y <- rep(NA, NCOL(x))
names(y) <- names(x)
y
}else x
}

(.xb <- iris[ iris$Species=='zz', ])
empty(.xb)


Hope this helps,

Rui Barradas

Em 10-07-2012 14:15, Liviu Andronic escreveu:

Dear all
Is there a simpler method to achieve the following: When I obtain an
empty data.frame after subsetting, I need for it to contain one line
of NAs. Here's a dummy example:

(.xb <- iris[ iris$Species=='zz', ])

[1] Sepal.Length Sepal.Width  Petal.Length Petal.Width  Species
<0 rows> (or 0-length row.names)

dim(.xb)

[1] 0 5

(.xa <- data.frame(matrix(rep(NA, ncol(.xb)), 1)))

   X1 X2 X3 X4 X5
1 NA NA NA NA NA

names(.xa) <- names(.xb)
(.xb <- .xa)

   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1   NA  NA   NA  NA  NA


The solution I came up with is way too convoluted. Anything simpler? Regards
Liviu




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


Re: [R] Predicted values for zero-inflated Poisson

2012-07-10 Thread Achim Zeileis

On Tue, 10 Jul 2012, Laura Lee wrote:


Alain-

Thanks again for the response. I guess my question is more related to R, 
which I'm learning as I go along. Could you provide guidance as to how I 
would code this in R?


That depends on what exactly you want to predict.

As Alain said: The type="count" predictions are probably not interesting 
to you. In the JSS paper accompanying zeroinfl, these correspond to 
exp(x'b) in Equation 8.


More interesting is probably the mean (1 - pi) * exp(x'b) which is the 
expected mean mu_i in Equation 8. This can be obtained as type="response".


Additionally, you might be interested in the individual probabilities for 
counts of 0, 1, 2, ... etc. This corresponds to evaluating Equation 7 
for y = 0, 1, 2, ... which can be obtained via type="prob". And from this 
you could also get the mode or median rather than the mean of the 
distribution.


hth,
Z



Thanks,
Laura

From: Alain Zuur [via R] [mailto:ml-node+s789695n4635920...@n4.nabble.com]
Sent: Monday, July 09, 2012 5:20 PM
To: Lee, Laura
Subject: Re: Predicted values for zero-inflated Poisson

Laura Lee laura.lee at ncdenr.gov
Mon Jul 9 22:51:40 CEST 2012

Previous message: [R] Predicted values for zero-inflated Poisson
Next message: [R] Lavaan Package - How to Extract Residuals in Data Values
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

Thanks for your reply. I do have a copy of "Zero Inflated Models and
Generalized Linear Mixed Models with R" and have been using that as a guide.
I applied the predict function (type="count") to the dataset for which I
built the model to compare the predicted bycatch numbers to the observed to
ensure I was doing things correctly. When I summed over the new predicted
variable, the value is over 500 whereas there were less than 10 observed.
I'd appreciate any advice regarding what I'm doing wrong.

--
View this message in context: 
http://r.789695.n4.nabble.com/Predicted-values-for-zero-inflated-Poisson-tp4635861p4635916.html
Sent from the R help mailing list archive at Nabble.com.




AFZ:
Laurano...you don't want to compare the count part of the model with raw 
datayou need to compare
the Exp(Y) = (1-pi) * mu with the raw data. Have a look at the Epilogue 
chapterit shows the difference
between mu and (1-pi) * mu.



Alain







--

Dr. Alain F. Zuur
First author of:

1. Analysing Ecological Data (2007).
Zuur, AF, Ieno, EN and Smith, GM. Springer. 680 p.
URL: www.springer.com/0-387-45967-7


2. Mixed effects models and extensions in ecology with R. (2009).
Zuur, AF, Ieno, EN, Walker, N, Saveliev, AA, and Smith, GM. Springer.
http://www.springer.com/life+sci/ecology/book/978-0-387-87457-9


3. A Beginner's Guide to R (2009).
Zuur, AF, Ieno, EN, Meesters, EHWG. Springer
http://www.springer.com/statistics/computational/book/978-0-387-93836-3


4. Zero Inflated Models and Generalized Linear Mixed Models with R. (2012) 
Zuur, Saveliev, Ieno.
http://www.highstat.com/book4.htm

Other books: http://www.highstat.com/books.htm


Statistical consultancy, courses, data analysis and software
Highland Statistics Ltd.
6 Laverock road
UK - AB41 6FN Newburgh
Tel: 0044 1358 788177
Email: [hidden email]
URL: www.highstat.com
URL: www.brodgar.com


   [[alternative HTML version deleted]]

__
[hidden email] 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.
Dr. Alain F. Zuur
First author of:

1. Analysing Ecological Data (2007).
Zuur, AF, Ieno, EN and Smith, GM. Springer. 680 p.
URL: www.springer.com/0-387-45967-7


2. Mixed effects models and extensions in ecology with R. (2009).
Zuur, AF, Ieno, EN, Walker, N, Saveliev, AA, and Smith, GM. Springer.
http://www.springer.com/life+sci/ecology/book/978-0-387-87457-9


3. A Beginner's Guide to R (2009).
Zuur, AF, Ieno, EN, Meesters, EHWG. Springer
http://www.springer.com/statistics/computational/book/978-0-387-93836-3


Other books: http://www.highstat.com/books.htm


Statistical consultancy, courses, data analysis and software
Highland Statistics Ltd.
6 Laverock road
UK - AB41 6FN Newburgh
Tel: 0044 1358 788177
Email: highs...@highstat.com
URL: www.highstat.com
URL: www.brodgar.com


If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/Predicted-values-for-zero-inflated-Poisson-tp4635861p4635920.html
To unsubscribe from Predicted values for zero-inflated Poisson, click 
here.
NA

Re: [R] RGB components of plot() colours

2012-07-10 Thread Sarah Goslee
R uses the sandard X11 colors, I believe, and if you're using linux there's
a rgb.txt file on your computer that contains them.

It's also available here
http://cvsweb.xfree86.org/cvsweb/*checkout*/xc/programs/rgb/rgb.txt?rev=1.1

and a less-authoritative but prettier version:
http://en.wikipedia.org/wiki/X11_color_names

Within R, colors() is what you need. See here for an exhaustive discussion:
http://research.stowers-institute.org/efg/R/Color/Chart/

Sarah

On Tuesday, July 10, 2012, Ted Harding wrote:

> A quick question:
>
> Is there anywhere a listing of the RGB components of the
> named colours listed by colors()?
>
> For example, where would I find the RGB for "orange1"
> or "salmon"?
>
> When I look at an EPS file from R where I have used
> these colours, it seems that for:
>
> "salmon":
> 0.9804 0.5020 0.4471 rgb
>
> "orange1":
> 1 0.6471 0 rgb
>
> However, this is a tedious way of finding out!
>
> With thanks,
> Ted.
>
> -
> E-Mail: (Ted Harding) >
> Date: 10-Jul-2012  Time: 14:05:15
> This message was sent by XFMail
>
> __
> R-help@r-project.org  mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


-- 
Sarah Goslee
http://www.stringpage.com
http://www.sarahgoslee.com
http://www.functionaldiversity.org

[[alternative HTML version deleted]]

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


Re: [R] define stuff to be only usable in the same file

2012-07-10 Thread Duncan Murdoch

On 12-07-10 9:13 AM, Jessica Streicher wrote:

Hello R-Help!

I've looked around and have not found:

A simple(short) way to hide functions and variables from the global 
environment. What i want is for a few of them to only be accessable from the 
scriptfile they're in. I probably could do fun things with environments , but 
that seems quite a hassle.


The simplest and best way to do this is to write a package.  You can 
also use local() around the code in a script, but it gets messy when you 
want to export more than one thing.


Duncan Murdoch


As example: I have a file that gets me stuff from the database and creates an R 
object from the results, plus some functions on that object. Now i want the 
objectrelated stuff to be global, while the functions and variables i use for 
accessing the database shall be hidden.


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


  1   2   >