Re: [R] cube root

2011-04-17 Thread Berend Hasselman

Branimir K. Hackenberger wrote:
 
 This is some interesting:
 
 -8^(1/3)
 
 [1] -2
 
 x=(-8:8)
 
 y=x^(1/3)
 
 y
 
  [1]  NaN  NaN  NaN  NaN  NaN  NaN  NaN 
 NaN
 0.00 1.00
 
 [11] 1.259921 1.442250 1.587401 1.709976 1.817121 1.912931 2.00
 So, can anybody explain this?! (Why is x[1]^(1/3)=y[1]=NaN, but
 -8^(1/3)=-2?)
 

Operator precedence.

See R FAQ 7.33 Why are powers of negative numbers wrong?


Berend


--
View this message in context: 
http://r.789695.n4.nabble.com/cube-root-tp3455020p3455027.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] kpss

2011-04-17 Thread Stat Consult
Dear All
I will be glade if you help me to understand what difference is between
trend Stationary and level Stationary at kpss.test in tseries package.
best regards
stat consult

--

[[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] Counting elements in columns

2011-04-17 Thread helin_susam
Hi,
try this;

sum(sapply(a, function(x) (x==b)))

--
View this message in context: 
http://r.789695.n4.nabble.com/Re-Counting-elements-in-columns-tp3454930p3454936.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] sweave options with variable

2011-04-17 Thread Kai Ying
hello:
   Do any one know how to set sweave option by variable, for example I want
set some of my selected code chunk with:
eval=needRun= rather than eval=TRUE=, so  I can change the action
only in the head by change the variable needRun one times.
I have tried use \Def and \newcommand, both do not work, so I suppose it
is related with R/Sweave its self.
thanks for any good suggestion.

[[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] cube root

2011-04-17 Thread Tsjerk Wassenaar
Hey :)

In addition, although (-2)^3 = -8, (-8)^(1/3) != -2, mathematically. A
fractional power of a negative number is complex. And this can be
obtained properly in R:

 (-8+0i)^(1/3)
[1] 1+1.732051i

Cheers,

Tsjerk

 This is some interesting:

 -8^(1/3)

 [1] -2

 x=(-8:8)

 y=x^(1/3)

 y

  [1]      NaN      NaN      NaN      NaN      NaN      NaN      NaN
 NaN
 0.00 1.00

 [11] 1.259921 1.442250 1.587401 1.709976 1.817121 1.912931 2.00
 So, can anybody explain this?! (Why is x[1]^(1/3)=y[1]=NaN, but
 -8^(1/3)=-2?)


 Operator precedence.

 See R FAQ 7.33 Why are powers of negative numbers wrong?


 Berend


 --
 View this message in context: 
 http://r.789695.n4.nabble.com/cube-root-tp3455020p3455027.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.




-- 
Tsjerk A. Wassenaar, Ph.D.

post-doctoral researcher
Molecular Dynamics Group
* Groningen Institute for Biomolecular Research and Biotechnology
* Zernike Institute for Advanced Materials
University of Groningen
The Netherlands

__
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] if else statements in data frame

2011-04-17 Thread ozgrerg
Thanks  alot B77S. That was a critical post. 

--
View this message in context: 
http://r.789695.n4.nabble.com/if-else-statements-in-data-frame-tp3454646p3455077.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] prb with data.table

2011-04-17 Thread yoda55
I upgraded to R.2.13.0 and the problem disappeared.

Thx

--
View this message in context: 
http://r.789695.n4.nabble.com/prb-with-data-table-tp3454478p3455103.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] cube root

2011-04-17 Thread David Winsemius

Hey :)

In addition, although (-2)^3 = -8, (-8)^(1/3) != -2, mathematically. A
fractional power of a negative number is complex. 

_Not_ in addition. The citation of FAQ 7.33 did not address the correct
issue since the sequence was enclosed in parens. Yours is the only correct
answer. For further discussion about various approaches to fractional powers
of negative numbers one can get further approaches by searching the
archives.

-- 
David.

And this can be
obtained properly in R:

 (-8+0i)^(1/3)
[1] 1+1.732051i

Cheers,

Tsjerk

 This is some interesting:

 -8^(1/3)

 [1] -2

 x=(-8:8)

 y=x^(1/3)

 y

  [1]      NaN      NaN      NaN      NaN      NaN      NaN      NaN
 NaN
 0.00 1.00

 [11] 1.259921 1.442250 1.587401 1.709976 1.817121 1.912931 2.00
 So, can anybody explain this?! (Why is x[1]^(1/3)=y[1]=NaN, but
 -8^(1/3)=-2?)


 Operator precedence.

 See R FAQ 7.33 Why are powers of negative numbers wrong?


 Berend


Tsjerk Wassenaar wrote:
 
 Hey :)
 
 In addition, although (-2)^3 = -8, (-8)^(1/3) != -2, mathematically. A
 fractional power of a negative number is complex. And this can be
 obtained properly in R:
 
 (-8+0i)^(1/3)
 [1] 1+1.732051i
 
 Cheers,
 
 Tsjerk
 
 This is some interesting:

 -8^(1/3)

 [1] -2

 x=(-8:8)

 y=x^(1/3)

 y

  [1]      NaN      NaN      NaN      NaN      NaN      NaN      NaN
 NaN
 0.00 1.00

 [11] 1.259921 1.442250 1.587401 1.709976 1.817121 1.912931 2.00
 So, can anybody explain this?! (Why is x[1]^(1/3)=y[1]=NaN, but
 -8^(1/3)=-2?)


 Operator precedence.

 See R FAQ 7.33 Why are powers of negative numbers wrong?


 Berend


 --
 View this message in context:
 http://r.789695.n4.nabble.com/cube-root-tp3455020p3455027.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.

 
 
 
 -- 
 Tsjerk A. Wassenaar, Ph.D.
 
 post-doctoral researcher
 Molecular Dynamics Group
 * Groningen Institute for Biomolecular Research and Biotechnology
 * Zernike Institute for Advanced Materials
 University of Groningen
 The Netherlands
 
 __
 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.
 

Tsjerk Wassenaar wrote:
 
 Hey :)
 
 In addition, although (-2)^3 = -8, (-8)^(1/3) != -2, mathematically. A
 fractional power of a negative number is complex. And this can be
 obtained properly in R:
 
 (-8+0i)^(1/3)
 [1] 1+1.732051i
 
 Cheers,
 
 Tsjerk
 
 This is some interesting:

 -8^(1/3)

 [1] -2

 x=(-8:8)

 y=x^(1/3)

 y

  [1]      NaN      NaN      NaN      NaN      NaN      NaN      NaN
 NaN
 0.00 1.00

 [11] 1.259921 1.442250 1.587401 1.709976 1.817121 1.912931 2.00
 So, can anybody explain this?! (Why is x[1]^(1/3)=y[1]=NaN, but
 -8^(1/3)=-2?)


 Operator precedence.

 See R FAQ 7.33 Why are powers of negative numbers wrong?


 Berend


 --
 View this message in context:
 http://r.789695.n4.nabble.com/cube-root-tp3455020p3455027.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.

 
 
 
 -- 
 Tsjerk A. Wassenaar, Ph.D.
 
 post-doctoral researcher
 Molecular Dynamics Group
 * Groningen Institute for Biomolecular Research and Biotechnology
 * Zernike Institute for Advanced Materials
 University of Groningen
 The Netherlands
 
 __
 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.
 


--
View this message in context: 
http://r.789695.n4.nabble.com/cube-root-tp3455020p3455118.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] cube root

2011-04-17 Thread Sascha Vieweg

On 11-04-17 07:51, Branimir K. Hackenberger wrote:


This is some interesting:


-8^(1/3)


[1] -2


x=(-8:8)



y=x^(1/3)



y


[1]  NaN  NaN  NaN  NaN  NaN  NaN  NaN  NaN
0.00 1.00

[11] 1.259921 1.442250 1.587401 1.709976 1.817121 1.912931 2.00

So, can anybody explain this?! (Why is x[1]^(1/3)=y[1]=NaN, but
-8^(1/3)=-2?)


-8^(1/3) == (-8)^(1/3) # NA
-8^(1/3) == -(8^(1/3)) # TRUE


Thx!!!


You're welcome.

--
Sascha Vieweg, saschav...@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] how to get the plot like this by R?

2011-04-17 Thread wangxipei
Thank you, John, for the blog website and the kind reminding.
Thank Jinsong and Jinyan for your kindness.

Xipei Wang, Ph.D. student
Beijing, China
 
At 2011-04-16 21:21:33£¬John Kane jrkrid...@yahoo.ca wrote:

I posted my response to you to the mailing list.  You replied only to me so 
other R-help readers will not see your response.  You need to use Reply All  to 
get your message to both the person and the list.  This is something I forget 
regularly.

I hope that Jim Lemon's code at 
http://www.r-statistics.com/2011/03/beeswarm-boxplot-and-plotting-it-with-r/ 
does what you want.  If not, hopefully some of the other code or links will 
help.

--- OnSat, 4/16/11, wangxipeiwangxi...@gmail.com wrote:

From: wangxipei wangxi...@gmail.com
Subject: Re:Re: [R] how to get the plot like this by R?
To: John Kane jrkrid...@yahoo.ca
Received: Saturday, April 16, 2011, 8:36 AM


I am sorry for the fault. The figure is posted 
athttp://www.mediafire.com/i/?08b9f4um43vxvw8 (hope this works!).
Thank John for the website.
 
Xipei Wang, Ph.D. student
--

Xipei Wang, Ph.D. student
Department of Pharmaceutics, School of Pharmaceutical Sciences,
Peking University Health Science Center, Beijing,
China
Tel: +86-0-152 1089 2231
Email:wangxi...@gmail.com



ÌåÑéÍøÒ×ÓÊÏä2G³¬´ó¸½¼þ£¬ÇáËÉ·¢ÓÅÖÊ´óµçÓ°¡¢´óÕÕƬ£¬ÌáËÙ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] sweave options with variable

2011-04-17 Thread Duncan Murdoch

On 11-04-17 2:41 AM, Kai Ying wrote:

hello:
Do any one know how to set sweave option by variable, for example I want
set some of my selected code chunk with:
eval=needRun= rather thaneval=TRUE=, so  I can change the action
only in the head by change the variable needRun one times.
I have tried use \Def and \newcommand, both do not work, so I suppose it
is related with R/Sweave its self.
thanks for any good suggestion.



You can't do that, but you can get a similar effect this way:

echo=FALSE=
needRun - TRUE
@

...

thecode,eval=FALSE=
someSlowFunction()
@

echo=FALSE=
if (needRun) {
thecode
}
@

Or you could use cacheSweave or weaver for caching, which may do what 
you want, or write your own Sweave driver to do exactly what you want.


Duncan Murdoch

__
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] Rsquared for anova

2011-04-17 Thread Mike Marchywka



( did this msg make it through the lists as rich text? hotmail
didn't seem to think it was plain text?)

Anyway, having come in in the middle of this it isn't clear
if your issues are with R or stats or both. Usually the hard
core stats people punt the stats questions to other places but
both can be addressed somewhat.
In any case, exploratory work is a good way to learn both and I 
always like looking at new data. If you have one or
a few dependent variable and many independent variable,
it would probably help if you could visualize a
surface with the response as a function of the input
variables and then, maybe with the input of prior information or
anecdotes, you have some idea what tests or
analyses would make sense. 

just some thoughts for illustration only

df-read.table(results_processedCP.txt,header=T)


first it helps to make sure everything went ok and do quick
checks, for example, 

str(df)
unique(df$nh1)
unique(df$nh2)
unique(df$nh3)
unique(df$randsize)
unique(df$aweoghts)
unique(df$aweights)


now personally lots of binary variable confuse me and
I can munge them all together since I expect I can
later identify issues in following plots. So, with
this data you can create a composite variable like this,
( now I have not checked any of this for accuracy
and typos and other problems may render the results useless)

x=df$nh1+2*df$nh2+4*df$nh3+2*df$randsize+32*df$aweights
df2-cbind(df,x)
str(df2)

not sure if time was an input or output but you could
see if there is any obvious trend or periodicity of
time with your new made up variable,

plot(df2$time,df2$x)

Apparently x is a num rather than int, it can be changed for illustration
but probably of no consequence,

xi=as.integer(x)
str(xi)

and then you can add color based on this varaiable, 

min(xi)
c=rainbow(56)
cx=c[xi+1]
str(cx)

and make color coded scatter plots. Now, if you 
got lucky and guessed right you may see some patterns
that you want to test, 

plot(df2$tos,df2$tws,col=cx)

in this case, I get a cool red-yellow-green line along bottom ( very
compelling linear fit question ) and scattered magenta( pink red? LOL ) and 
blue points
everywhere with cluster near origin and nothing in top right quadrant. 
Also note a few blues lines above the red-green-yellow line but much shorter.

And in fact, presumably you already knew this as it looks like it was designed
in, if you just plot the red and green points the fit looks perfect for linear,


 good=which(df2$x20)
 plot(df2$tos[good],df2$tws[good],col=cx[good])

now if you look at results of fit of Good points vs all points,
it isn't clear that anything like this would emerge from just
looking at summaries of a linear fit, 


td=df2$tos[good]
ti=df2$tws[good]
lm(td~ti)
lm(df2$tos~ df2$tws)
summary(lm(td~ti))
summary(lm(df2$tos~ df2$tws))





Now of course tests need to be considered ahead of time or else
it is easy to go shopping for the answer you want. Anything post hoc
needs to be very complete and you should at least try to rationalize
test results you don't happen to like ( assuming you are trying to understand
the system from which the data was measured rather than justify some
particular outcome). 




Date: Sun, 17 Apr 2011 11:34:14 +0200
From: dorien.herrem...@ua.ac.be
To: dieter.me...@menne-biomed.de
CC: r-help@r-project.org
Subject: Re: [R] Rsquared for anova

Thanks for your remarks. I've been reading about R for the last two days,
but I don't really get when I should use lm or aov.
 
I have attached the dataset, feel free to take a look at it.
 
So far, running it with alle the combinations did not take too long and
there seem to be some effects between the parameters. However, 2x2
combinations might suffice.
 
Thanks for any help, or a pointer to some good documentation,
 
Dorien
 
 
On 16 April 2011 10:13, Dieter Menne dieter.me...@menne-biomed.de wrote:
 

 dorien wrote:
 
  fit - lm((tos~nh1*nh2*nh3*randsize*aweights*tt1*tt2*tt3*iters*length,
  data=expdata))
  Error: unexpected ',' in fit -
  lm((tos~nh1*nh2*nh3*randsize*aweights*tt1*tt2*tt3*iters*length,
 
 

 Peter's point is the important one: too many interactions, and even with +
 instead of * you might be running into problems.

 But anyway: if you don't let us access


 /home/dorien/UA/meta-music/optimuse/optimuse1-build-desktop/results/results_processedCP

 you cannot expect a better answer which will depend on the structure of the
 data set.

 Dieter



 --
 View this message in context:
 http://r.789695.n4.nabble.com/Rsquared-for-anova-tp3452399p3453719.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.

 
 
 
-- 
Dorien Herremans
 
*Department of Environment, Technology and Technology Management*
Faculty of Applied 

Re: [R] adding two colmns of a data frame

2011-04-17 Thread John Kane
You mean like this?
mydata - data.frame(aa=1:5, bb=1:5)
mydata[,3] - mydata[,1] + mydata[,2]
mydata

--- On Sat, 4/16/11, ozgrerg ozgr...@gmail.com wrote:

 From: ozgrerg ozgr...@gmail.com
 Subject: [R] adding two colmns of a data frame
 To: r-help@r-project.org
 Received: Saturday, April 16, 2011, 4:22 PM
 It seems very simple but I could not
 find the way. I just want to add two
 columns of a data frame. I am doing the below operation: 
 
 data$C=transform(data, data$A+data$B)
 
 However that return as a data frame. I will be glad if ypu
 help. Thanks a
 lot
 
 
 
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/adding-two-colmns-of-a-data-frame-tp3454556p3454556.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] sweave options with variable

2011-04-17 Thread Kai Ying
thanks,
   It can work but not as elegant as I expect because it add extra code to
every chunk of code.
I have tried the cache for this purpose it works in most case but have a lot
of other problems so I decided to control it by myself.
I guess that sweave running R code before tex, so tex variable do not work
and need find something run before sweave and set the variable,
but it seems currently no way do that. Write my own Sweave driver is too
hard for me hope in the future someone can refine the sweave driver.
   best wishes

On Sun, Apr 17, 2011 at 7:30 AM, Duncan Murdoch murdoch.dun...@gmail.comwrote:

 On 11-04-17 2:41 AM, Kai Ying wrote:

 hello:
Do any one know how to set sweave option by variable, for example I
 want
 set some of my selected code chunk with:
 eval=needRun= rather thaneval=TRUE=, so  I can change the action
 only in the head by change the variable needRun one times.
 I have tried use \Def and \newcommand, both do not work, so I suppose
 it
 is related with R/Sweave its self.
 thanks for any good suggestion.


 You can't do that, but you can get a similar effect this way:

 echo=FALSE=
 needRun - TRUE
 @

 ...

 thecode,eval=FALSE=
 someSlowFunction()
 @

 echo=FALSE=
 if (needRun) {
 thecode
 }
 @

 Or you could use cacheSweave or weaver for caching, which may do what you
 want, or write your own Sweave driver to do exactly what you want.

 Duncan Murdoch


[[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] sweave options with variable

2011-04-17 Thread Gabor Grothendieck
On Sun, Apr 17, 2011 at 11:04 AM, Kai Ying yi...@iastate.edu wrote:
 thanks,
   It can work but not as elegant as I expect because it add extra code to
 every chunk of code.
 I have tried the cache for this purpose it works in most case but have a lot
 of other problems so I decided to control it by myself.
 I guess that sweave running R code before tex, so tex variable do not work
 and need find something run before sweave and set the variable,
 but it seems currently no way do that. Write my own Sweave driver is too
 hard for me hope in the future someone can refine the sweave driver.
   best wishes


You may be better off just directly emit the latex from R (not using
Sweave at all).  Another alternative is the brew package.

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

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


Re: [R] sweave options with variable

2011-04-17 Thread Henrik Bengtsson
[Forgot to cc: the list]

Hi.

On Sun, Apr 17, 2011 at 8:04 AM, Kai Ying yi...@iastate.edu wrote:
 thanks,
   It can work but not as elegant as I expect because it add extra code to
 every chunk of code.
 I have tried the cache for this purpose it works in most case but have a lot
 of other problems so I decided to control it by myself.
 I guess that sweave running R code before tex, so tex variable do not work
 and need find something run before sweave and set the variable,
 but it seems currently no way do that.

You can do exactly this by embedding your Sweave document with RSP markup, e.g.

% needRun - TRUE %

eval=%=needRun%=
someSlowFunction()
@

To compile this into a valid Sweave document/file, you have to append
filename extension *.rsp, e.g. report.Rnw.rsp.  Then compile it as:

library(R.rsp);
rsp(report.Rnw.rsp, postprocess=FALSE);

which outputs a file report.Rnw containing:

eval=TRUE=
someSlowFunction()
@

If you also want to run Sweave on this and generate a PDF you can do
everything in one go (using the default postprocess=TRUE):

library(R.rsp);
rsp(report.Rnw.rsp);

RSP is a context-independent markup, i.e. it does not care what format
the underlying document has, as long as it is text based.

Hope this helps

/Henrik

 Write my own Sweave driver is too
 hard for me hope in the future someone can refine the sweave driver.
   best wishes

 On Sun, Apr 17, 2011 at 7:30 AM, Duncan Murdoch 
 murdoch.dun...@gmail.comwrote:

 On 11-04-17 2:41 AM, Kai Ying wrote:

 hello:
    Do any one know how to set sweave option by variable, for example I
 want
 set some of my selected code chunk with:
 eval=needRun= rather thaneval=TRUE=, so  I can change the action
 only in the head by change the variable needRun one times.
 I have tried use \Def and \newcommand, both do not work, so I suppose
 it
 is related with R/Sweave its self.
 thanks for any good suggestion.


 You can't do that, but you can get a similar effect this way:

 echo=FALSE=
 needRun - TRUE
 @

 ...

 thecode,eval=FALSE=
 someSlowFunction()
 @

 echo=FALSE=
 if (needRun) {
 thecode
 }
 @

 Or you could use cacheSweave or weaver for caching, which may do what you
 want, or write your own Sweave driver to do exactly what you want.

 Duncan Murdoch


        [[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] startup script with library call to ggplot2 in R-2.13.0; was: (no subject)

2011-04-17 Thread Uwe Ligges

1. Please do read the posting guide and perovide a sensible subject line.
2. Have you updated ggplot for R-2.13.0 before  reporting the error? 
E.g. please try update.packages(checkBuilt=TRUE) and afterwards report 
again.


Uwe Ligges


On 16.04.2011 22:25, Steve Lianoglou wrote:

Out of curiosity, do you have a problem calling `library(ggplot2)`
from the R prompt (after R is finished spinning up)?

I vaguely recall (~ 2 years ago) that I was trying to load some
packages in my ~/.Rprofile since I thought I always wanted them in R
anyway and had problems ... I've given up trying to do that, though
:-)

So -- doesn't answer your question, but if you have number of
libraries you want to load up, but it's a pain to call individual
`library()` calls, maybe you can define a .setup() function in your
~/.Rprofile that does all these library calls for you when you come to
a point in your (interactive) work that you think you need them.

-steve

On Sat, Apr 16, 2011 at 2:47 PM, stephen sefickssef...@gmail.com  wrote:

I have just upgraded to R 2.13 and have library(ggplot2) in my
.Rprofile (among other things).  when i start R I get an error
message.  Has something in the start up scripts changed?  Is there a
better way to specify the library calls in .Rprofile?  Thanks for all
of the help in advance.

Error:

Loading required package: grid
Loading required package: proto
Error in rename(x, .base_to_ggplot) : could not find function setNames
Error : unable to load R code in package 'ggplot2'
Error: package/namespace load failed for 'ggplot2'
[Previously saved workspace restored]


Computer 1:

R version 2.13.0 (2011-04-13)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
  [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8
  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
  [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] proto_0.3-9.1 reshape_0.8.4 plyr_1.5.1

Computer 2

R version 2.13.0 (2011-04-13)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
  [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8
  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
  [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] proto_0.3-9.1 reshape_0.8.4 plyr_1.5.1

--
Stephen Sefick

| Auburn University |
| Biological Sciences  |
| 331 Funchess Hall   |
| Auburn, Alabama |
| 36849   |
|___|
| sas0...@auburn.edu  |
| http://www.auburn.edu/~sas0025 |
|___|

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

 -K. Mullis

A big computer, a complex algorithm and a long time does not equal science.

   -Robert Gentleman

__
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] boxplot with 2 treatments and 2 variables (with 2 corresponding y-axes)

2011-04-17 Thread Uwe Ligges



On 15.04.2011 16:20, Ellis, David wrote:

Hi,

I am a complete newcomer to R and although I can plot standard box-plots I am 
struggling with this...

I have two treatments - A  B, and 2 variables 1  2. I want to compare 
boxplots of variable 1 with variable 2 for each treatment. I would also like them to 
all be on the same graphic.

I would like treatment to be on the x axis (A and B) and above A and B have 
their corresponding boxplots for both variables.I would also like 2 seperate 
y-axes, one for each variable - Variable 1 has a continuous y axis, and 
variable 2 is a percentage (of variable 1 in-fact, not that this should make a 
difference).

It would also be helpful if the boxplots were a different colour for each 
variable and that this corresponded somehow to the relevant axis. Or if someone 
can think of another way to show which treatment each boxplot is that would be 
gratefully recieved

Hope this makes sense and isn't too much of a pain to answer!


Not sure if it makes sense:
If you have two boxplots beside each other, you tend to compare them 
directly. If they are unrelated (different variables with different 
scaling as in this case), I'd be careful not to confuse the reader of 
the plot 


Best,
Uwe Ligges




Thanks in advance
Dave


[[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] Boxplot with two or more Y vectors

2011-04-17 Thread Uwe Ligges



On 13.04.2011 15:58, Håvard Wahl Kongsgård wrote:

Hi, for a simple boxplot in R, in the formula is it possible to include two
or more Y vectors directly. Or is that only possibility by aggregating the
data first?



Do you think about something like

boxplot(cbind(y1, y2))

?

Uwe Ligges

__
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] Rsquared for anova

2011-04-17 Thread Peter Ehlers

On 2011-04-17 02:34, Dorien Herremans wrote:

Thanks for your remarks. I've been reading about R for the last two days,
but I don't really get when I should use lm or aov.


I don't think that reading about R is the answer at this stage.
It appears to me that you need to learn more about regression.
There are many good introductory books. If you want to learn
the R way at the same time, you could look at the books section
on CRAN. Perhaps Peter Dalgaard's Intro to Stats with R or
An R Companion to Applied Regression by J. Fox and S. Weisberg,
or the books by Verzani or Heiberger/Holland.

After that, you'll find that the R documentation is actually
quite good. Most complaints about R's documentation seem to
amount to complaints that it doesn't teach statistics. That's
a good thing.

About your data: I'm fairly sure that several, if not most, of
your predictors should be factors.

Peter Ehlers



I have attached the dataset, feel free to take a look at it.

So far, running it with alle the combinations did not take too long and
there seem to be some effects between the parameters. However, 2x2
combinations might suffice.

Thanks for any help, or a pointer to some good documentation,

Dorien


On 16 April 2011 10:13, Dieter Mennedieter.me...@menne-biomed.de  wrote:



dorien wrote:



fit- lm((tos~nh1*nh2*nh3*randsize*aweights*tt1*tt2*tt3*iters*length,

data=expdata))
Error: unexpected ',' in fit-
lm((tos~nh1*nh2*nh3*randsize*aweights*tt1*tt2*tt3*iters*length,




Peter's point is the important one: too many interactions, and even with +
instead of * you might be running into problems.

But anyway: if you don't let us access


/home/dorien/UA/meta-music/optimuse/optimuse1-build-desktop/results/results_processedCP

you cannot expect a better answer which will depend on the structure of the
data set.

Dieter



--
View this message in context:
http://r.789695.n4.nabble.com/Rsquared-for-anova-tp3452399p3453719.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] Rsquared for anova

2011-04-17 Thread Dorien Herremans
Thanks everyone.

Yes Peter, I already added nh1=factor(nh1) to the 'routine'. Mostly,
my collegues are helping me work out the results and they know more
about regression, it has been a while for me...  They just asked if I
could also provide an R2, to see how good the model fits... therefore
the question. I already have the P values for each factor. I tought it
might be a simple command that I overlooked, such as summary(fit) :-)

Mike, I will study what you propose first thing tomorrow morning when
I am back at the office!

Thanks a lot,

Dorien

On 17 April 2011 19:43, Peter Ehlers ehl...@ucalgary.ca wrote:
 On 2011-04-17 02:34, Dorien Herremans wrote:

 Thanks for your remarks. I've been reading about R for the last two days,
 but I don't really get when I should use lm or aov.

 I don't think that reading about R is the answer at this stage.
 It appears to me that you need to learn more about regression.
 There are many good introductory books. If you want to learn
 the R way at the same time, you could look at the books section
 on CRAN. Perhaps Peter Dalgaard's Intro to Stats with R or
 An R Companion to Applied Regression by J. Fox and S. Weisberg,
 or the books by Verzani or Heiberger/Holland.

 After that, you'll find that the R documentation is actually
 quite good. Most complaints about R's documentation seem to
 amount to complaints that it doesn't teach statistics. That's
 a good thing.

 About your data: I'm fairly sure that several, if not most, of
 your predictors should be factors.

 Peter Ehlers


 I have attached the dataset, feel free to take a look at it.

 So far, running it with alle the combinations did not take too long and
 there seem to be some effects between the parameters. However, 2x2
 combinations might suffice.

 Thanks for any help, or a pointer to some good documentation,

 Dorien


 On 16 April 2011 10:13, Dieter Mennedieter.me...@menne-biomed.de  wrote:


 dorien wrote:

 fit- lm((tos~nh1*nh2*nh3*randsize*aweights*tt1*tt2*tt3*iters*length,

 data=expdata))
 Error: unexpected ',' in fit-
 lm((tos~nh1*nh2*nh3*randsize*aweights*tt1*tt2*tt3*iters*length,



 Peter's point is the important one: too many interactions, and even with
 +
 instead of * you might be running into problems.

 But anyway: if you don't let us access



 /home/dorien/UA/meta-music/optimuse/optimuse1-build-desktop/results/results_processedCP

 you cannot expect a better answer which will depend on the structure of
 the
 data set.

 Dieter



 --
 View this message in context:
 http://r.789695.n4.nabble.com/Rsquared-for-anova-tp3452399p3453719.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.




-- 
Dorien Herremans

Department of Environment, Technology and Technology Management
Faculty of Applied Economics
University of Antwerp

B.513
Prinsstraat 13
2000 Antwerp
Belgium
+32 3 265 41 25

__
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] multiple instance learning

2011-04-17 Thread zem
Hi all,

know somebody a package for R where are implemented multiple instance
learning algos? 
I've just checked the forum, but couldnt find anythink... 

thanks in advance

--
View this message in context: 
http://r.789695.n4.nabble.com/multiple-instance-learning-tp3455505p3455505.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] as.Date function error

2011-04-17 Thread Wonjae Lee
Hi,

I have some problems with as.Date function.
After I applied as.Date for my data, 2010 changed to 2020 as below
Where am I wrong?

Thanks

Wonjae

 x=c(11/16/2010,11/17/2010,11/18/2010,11/19/2010)
 x=as.Date(x,%m/%d/%y)
 x
[1] 2020-11-16 2020-11-17 2020-11-18 2020-11-19

my R veision is 2.12.2.

--
View this message in context: 
http://r.789695.n4.nabble.com/as-Date-function-error-tp3455466p3455466.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] Multinomial Logit Model with lots of Dummy Variables

2011-04-17 Thread ghpow1
Hi 

Thanks to Jeremy for his response...

I have been able to generate the factors and generate mlogit data using his
code:

mldata-mlogit.data(mydata, varying=NULL, choice=pitch_type_1,
shape=wide)

my mlogit data looks like:

dependent_var,A variable,B Var,chid,alt
FALSE,110,19,1,0
FALSE,110,19,1,1
FALSE,110,19,1,2
FALSE,110,19,1,3
FALSE,110,19,1,4
TRUE,110,19,1,5
FALSE,110,19,1,6
FALSE,110,19,1,7
FALSE,110,19,1,8
FALSE,110,19,2,0
FALSE,110,19,2,1
FALSE,110,19,2,2
FALSE,110,19,2,3
FALSE,110,19,2,4
FALSE,110,19,2,5
TRUE,110,19,2,6
FALSE,110,19,2,7
FALSE,110,19,2,8
TRUE,110,561,3,0
FALSE,110,561,3,1
FALSE,110,561,3,2
FALSE,110,561,3,3
FALSE,110,561,3,4
FALSE,110,561,3,5
FALSE,110,561,3,6
FALSE,110,561,3,7
FALSE,110,561,3,8
FALSE,110,149,4,0
FALSE,110,149,4,1
TRUE,110,149,4,2

...

The mldata contains 651431 rows.  

If I try to run this full data set I get the following error:  


 mlogit.model- mlogit(dependent_var~0|A+B, data = mldata, reflevel=0)
Error in model.matrix.default(formula, data) :
  allocMatrix: too many elements specified
Calls: mlogit ... model.matrix.mFormula - model.matrix -
model.matrix.default
Execution halted

Smaller datasets (595 mldata rows) and mlogit works fine and generates
regression output.  

Is there a problem with mlogit and huge datasets?  

I suppose this is perhaps not the best way to assess this kind of data, but
I am trying to replicate a previous analysis that was completed on a similar
amount of similar data.




--
View this message in context: 
http://r.789695.n4.nabble.com/Multinomial-Logit-Model-with-lots-of-Dummy-Variables-tp3439492p3455345.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] cajolst

2011-04-17 Thread egle
Well, it was a simple phrase problem. Maybe it is going to be useful for
someone:

summary(ca.jo(sjd,ecdet=const,type=eigen,K=2,spec=longrun,season=4))
summary(cajolst(sjd,season=4))
cajolst(sjd,season=4)@bp

--
View this message in context: 
http://r.789695.n4.nabble.com/cajolst-tp3454306p3455628.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] reporting lme results

2011-04-17 Thread Pennell, Tanya
Hi,

I have used lme4 and I have found a significant result when using anova to 
compare model 1 and model 2 (where I took out an interaction).

The result looks like this:
model.3: DIFFERENCE ~ (1 | MALE.ID)
model.2: DIFFERENCE ~ MALE.SPECIES + (1 | MALE.ID)
DfAICBIC  logLik  Chisq Chi Df Pr(Chisq)
model.3  3 1379.7 1387.1 -686.86
model.2  4 1374.1 1384.0 -683.05 7.6235  1   0.005761 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Just wondering how I would report this in a scientific paper?

Thanks in advance,
Tanya

[[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] How to retrieve a vector of a data.frame's variable attributes?

2011-04-17 Thread Bacou, Melanie
Hi,

I have a data.frame with 100 variables and I have assigned a label,
units and category attribute to each variable. I would like to reorder
the variables in the data.frame by the category attributes but can't find
a way.

For example, the first variable is:

 attributes(hh$aez)
$levels
[1] coastal  forest   savannah

$class
[1] labelled factor  

$label
[1] ecological zone
93 Levels: 10 quantiles of welfare  ... year of the interview

$units
[1] class
24 Levels: '05 PPP USD / year cedis / year cedis /year class geo-1 ... years

$category
[1] geography
7 Levels: agriculture demography design expenditure geography ... welfare

I have tried:

hh - hh[, order(attr(hh, category))]
hh - hh[, order(attr(hh[, 1:100], category))]
hh - hh[, order(attr(dimnames(hh), category))]

but all the right-hand side assignments above return NULL.

Thanks very much for your help with this simple task!

--Mel.



___
 Melanie Bacou
 3110 Wisconsin Ave, NW 
 Washington DC, 20016 
 +1 (202) 492-7978
 m...@mbacou.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] side by side histogram after splitting data by year

2011-04-17 Thread Stratford, Jeffrey
Hi everyone,

 

I'm looking to produce a side-by-side histogram of the number of trips
taken by jays with a particular number of acorns after accounting for
year (year one and year two). I know this involves indexing first
then creating a histogram but I'm not sure how I'd do this. I want to
explore the possibilities that jays are altering their strategies in
different years.  Data are below.

 

This is a common need for myself so any help would be greatly
appreciated!  

 

Thanks,

 

Jeff

 

 

 

structure(list(year = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,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, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 

[R] Box plot with 5th and 95th percentiles instead of 1.5 * IQR: problems implementing an existing solution...

2011-04-17 Thread Paul Raftery
Hi all,

I'm just getting started with R and I would appreciate some help. I'm having
trouble creating a boxplot with whiskers at the 95th and 5th percentiles
instead of at 1.5 * IQR. I have read the relevant documentation, and checked
existing mails on this topic. I found a small modification that should work
: https://stat.ethz.ch/pipermail/r-help/2001-November/016817.html and tried
to implement it.

Basically, it says to replace boxplot.stats with:

myboxplot.stats -  function (x, coef = NULL, do.conf = TRUE, do.out =
TRUE)
{
  nna - !is.na(x)
  n - sum(nna)
  stats - quantile(x, c(.05,.25,.5,.75,.95), na.rm = TRUE)
  iqr - diff(stats[c(2, 4)])
  out - x  stats[1] | x  stats[5]
  conf - if (do.conf)
stats[3] + c(-1.58, 1.58) * diff(stats[c(2, 4)])/sqrt(n)
  list(stats = stats, n = n, conf = conf, out = x[out  nna])
}

I entered the new function, and used fix(boxplot.default) to modify
boxplot.default so that it references myboxplot.stats instead of the
original boxplot.stats function.

If I now type boxplot.default, I can see that the code has been modified as
expected. However, I get the exact same result as before when I create a
boxplot - it shows the whiskers at 1.5 * IQR. You can test this out by
creating a boxplot from the iris dataset supplied with R using
boxplot(iris$Sepal.Length ~ iris$Species). You see that the boxplot is the
same before and after the fix.  Does anybody know why this occurs, and how I
can get around this issue?

Thanks,
-- 
Regards,
Paul


=
Contact Details
=
Paul Raftery, BEng(Hons) (Mech), Fulbright Fellow, PhD
http://www.paulraftery.com/
 http://www.paulraftery.com/
Postdoctoral Research Engineer
Informatics Research Unit for Sustainable Engineering (IRUSE)
http://www.iruse.ie/

Department of Civil Engineering,
National University of Ireland, Galway,
University Road,
Galway,
Ireland.

Landline: +353 91 49 3086
Mobile: +353 85 124 7947
Skype: praftery

[[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] converting data.frame into a numeric ( integer) form

2011-04-17 Thread Haillie
Hi Everyone,

I am relatively new to R and would appreciate your help on this problem that
I encontered this morning.
When running an ordinal IRT model using Ratings package on R, I keep getting
this error message.

ord.out-ordrating(UNORD, burnin = 1000, mcmc = 40,000, thin = 400, tune =
1, verbose = 1000, seed = NA)

Error in as.vector(as.integer(Y)) : 
  (list) object cannot be coerced to type 'integer'

UNORD is my data.frame and it is in the form of delimited CSV file without
either row or column name.
According to the help page on Ordinal ratings, Y should be a Matrix of data
to be analyzed. Entries must be integers from 1; : : : ;C or NA where C is
the number of ordinal categories. Items are on the rows and subjects are on
the columns. I am confused because my data.frame only contains numerica
values of 1,2,3, and NA. I checked and my NAs were all numeric. 

Any help or advice you could provide on this issue would be greatly
appreciated. Thank you very much.
I would like to thank all the R experts navigating this forum in advance. 

Sincerely,
Haillie 

--
View this message in context: 
http://r.789695.n4.nabble.com/converting-data-frame-into-a-numeric-integer-form-tp3455811p3455811.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] as.Date function error

2011-04-17 Thread Dennis Murphy
as.Date(x,%m/%d/%Y)
[1] 2010-11-16 2010-11-17 2010-11-18 2010-11-19

Notice the Y (four digit date).

Dennis

On Sun, Apr 17, 2011 at 6:34 AM, Wonjae Lee wjlee2...@naver.com wrote:
 Hi,

 I have some problems with as.Date function.
 After I applied as.Date for my data, 2010 changed to 2020 as below
 Where am I wrong?

 Thanks

 Wonjae

 x=c(11/16/2010,11/17/2010,11/18/2010,11/19/2010)
 x=as.Date(x,%m/%d/%y)
 x
 [1] 2020-11-16 2020-11-17 2020-11-18 2020-11-19

 my R veision is 2.12.2.

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/as-Date-function-error-tp3455466p3455466.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] Color Key in RColorBrewer

2011-04-17 Thread chakri_amateur
Hello,

I am using RcolorBrewer for plotting similarity scores, starting with
pair-wise similarity matrix as input. similarity scores range is 0 to1,
with 1 meaning 100% similar (see two maps below)
http://r.789695.n4.nabble.com/file/n3455953/lingosimilarity.jpg 
http://r.789695.n4.nabble.com/file/n3455953/bingosimilarity.jpg 
I would like to have same color key in both the plots. My objective here is
to compare two plots visually. By same color key, I mean, same range -
like white for 0 - 0.2, grey for 0.2 - 0.4 and black for 0.8 - 1. Is it
possible to make color scale constant in RColorBrewer? If so, please provide
me pointers to command !

Thanks in Advance
Chakri

--
View this message in context: 
http://r.789695.n4.nabble.com/Color-Key-in-RColorBrewer-tp3455953p3455953.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] URL Scan

2011-04-17 Thread jmsc
I am wondering why when I try to input data from the first site listed below
into R using the scan() function, a different page is read in instead (the
second site listed):

http://data.visionappraisal.com/CanterburyCT/parcel.asp?pid=1242

http://www.visionappraisal.com/databases/

I am wondering if this is an issue with R or something in the source code of
the web page that I am not familiar with. Since I can access the first site
directly, I assume it is not within the source code. Any help would be
appreciated.

--
View this message in context: 
http://r.789695.n4.nabble.com/URL-Scan-tp3456084p3456084.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] (no subject)

2011-04-17 Thread Bryan Hanson
Is there any news on this issue?  I have the same problem but on a Mac.  I
have upgraded R and updated the built packages.  The console output and
sessionInfo are below.  The problem is triggered by library(ggplot2) my
.Rprofile  If I do library(ggplot2) after the aborted start up ggplot2 is
loaded properly, and I can manually do everything in my .Rprofile and my
configuration is as originally intended.  Thanks, Bryan

Console Output:

Loading required package: reshape
Loading required package: plyr

Attaching package: 'reshape'

The following object(s) are masked from 'package:plyr':

rename, round_any

Loading required package: grid
Loading required package: proto
Error in rename(x, .base_to_ggplot) : could not find function setNames
Error : unable to load R code in package 'ggplot2'
Error: package/namespace load failed for 'ggplot2'
[R.app GUI 1.40 (5751) x86_64-apple-darwin9.8.0]

[History restored from /Users/bryanhanson/.Rhistory]

and here is my session info after the aborted start up:

R version 2.13.0 (2011-04-13)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] proto_0.3-9.1   reshape_0.8.4   plyr_1.5.1  lattice_0.19-23

* Original Post from Stephen Sefick


I have just upgraded to R 2.13 and have library(ggplot2) in my
.Rprofile (among other things).  when i start R I get an error
message.  Has something in the start up scripts changed?  Is there a
better way to specify the library calls in .Rprofile?  Thanks for all
of the help in advance.

Error:

Loading required package: grid
Loading required package: proto
Error in rename(x, .base_to_ggplot) : could not find function setNames
Error : unable to load R code in package 'ggplot2'
Error: package/namespace load failed for 'ggplot2'
[Previously saved workspace restored]


Computer 1:

R version 2.13.0 (2011-04-13)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] proto_0.3-9.1 reshape_0.8.4 plyr_1.5.1

Computer 2

R version 2.13.0 (2011-04-13)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] proto_0.3-9.1 reshape_0.8.4 plyr_1.5.1

-- 
Stephen Sefick

| Auburn University                                         |
| Biological Sciences                                      |
| 331 Funchess Hall                                       |
| Auburn, Alabama                                         |
| 36849                                                           |
|___|
| sas0...@auburn.edu                                  |
| http://www.auburn.edu/~sas0025                 |
|___|


--
View this message in context: 
http://r.789695.n4.nabble.com/no-subject-tp3454416p3456100.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] 600 people's time series

2011-04-17 Thread Jannis
Your questions are as basic that it smells like home/classwork. Try to 
formulate precise questions and not questions like how do I solve this 
general problem and you are much mor likely to get answers.


To get you started:

For questions on how to plot values from dataframes please have a look 
either at an introduction to R (pdf), some basic textbooks or just 
google: r-project plotting tutorial (the second link should get you 
started)


For the regression I would loop through all ids and calculate the 
regression for a subset of the dataframe like:


for (i:1:...)
{
invest = DF$invest[DF$id==i]
payout=
invest.norm=invest/mean(...)
l.model=lm(...)
}


You will have to find out the details yourself. We will happily help if 
you post some precise (!) questions in case you get stuck!



Jannis

On 04/16/2011 07:15 PM, 苏江东Su Jiangdong wrote:

Hi there,

I have a data frame DF of over 600 people's short term trade data in time
order. Below is the super simplified structure of the data.

  id invest payout
[1]  1  10   -1
[2]  1  33   33
[3]  1  20   -5
[4]  2  200  33
[5]  2  33-20
[6]  3   5  -5
[7]  3  5-5

id is each person's id. Each person have invested many times in the sampling
period, in temporal order.

What I want to check is the correlation between invest and payout.

1. How do I run the regression for each person, with the invest being
devided by the mean or medium of the person's invest?
2. How do I plot a graph with y axis being invest/mean(invest) and x axis
being payout, all 600 people's dots superimposed on one graph?

I tried to use

for (i in 1:(dim (DF)[1]-1))
  {
if (DF[i,1]=DF[i+1,1])   id.lm- lm(invest ~ payput, data=DF)
}

But I don't know how to superimpose graphs onto each other.

Thanks a lot!

Su

[[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] R Reference Card for Data Mining

2011-04-17 Thread Yanchang Zhao
An R Reference Card for Data Mining is available for free download at
http://www.rdatamining.com. It can be a quick reference card for you
to use R for data mining applications.

Regards
-- 
Yanchang Zhao
PhD
Data Miner
Email: yanchangz...@gmail.com
RDataMining: http://www.rdatamining.com

Twitter: http://www.twitter.com/RDataMining

__
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] as.Date function error

2011-04-17 Thread Achim Zeileis

On Sun, 17 Apr 2011, Wonjae Lee wrote:


Hi,

I have some problems with as.Date function.
After I applied as.Date for my data, 2010 changed to 2020 as below
Where am I wrong?


You used %y (two-digit year, here: 20 and then expanded to 2020) 
instead of %Y (four-digit year, here 2010).


Using as.Date(x,%m/%d/%Y) yields the desired result.
Z




Thanks

Wonjae


x=c(11/16/2010,11/17/2010,11/18/2010,11/19/2010)
x=as.Date(x,%m/%d/%y)
x

[1] 2020-11-16 2020-11-17 2020-11-18 2020-11-19

my R veision is 2.12.2.

--
View this message in context: 
http://r.789695.n4.nabble.com/as-Date-function-error-tp3455466p3455466.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] Box plot with 5th and 95th percentiles instead of 1.5 * IQR: problems implementing an existing solution...

2011-04-17 Thread Frank Harrell
Try
require(Hmisc)
?panel.bpplot

This implements extended box plots that can show a variety of quantiles.
Frank


Paul Raftery wrote:
 
 Hi all,
 
 I'm just getting started with R and I would appreciate some help. I'm
 having
 trouble creating a boxplot with whiskers at the 95th and 5th percentiles
 instead of at 1.5 * IQR. I have read the relevant documentation, and
 checked
 existing mails on this topic. I found a small modification that should
 work
 : https://stat.ethz.ch/pipermail/r-help/2001-November/016817.html and
 tried
 to implement it.
 
 Basically, it says to replace boxplot.stats with:
 
 myboxplot.stats -  function (x, coef = NULL, do.conf = TRUE, do.out =
 TRUE)
 {
   nna - !is.na(x)
   n - sum(nna)
   stats - quantile(x, c(.05,.25,.5,.75,.95), na.rm = TRUE)
   iqr - diff(stats[c(2, 4)])
   out - x  stats[1] | x  stats[5]
   conf - if (do.conf)
 stats[3] + c(-1.58, 1.58) * diff(stats[c(2, 4)])/sqrt(n)
   list(stats = stats, n = n, conf = conf, out = x[out  nna])
 }
 
 I entered the new function, and used fix(boxplot.default) to modify
 boxplot.default so that it references myboxplot.stats instead of the
 original boxplot.stats function.
 
 If I now type boxplot.default, I can see that the code has been modified
 as
 expected. However, I get the exact same result as before when I create a
 boxplot - it shows the whiskers at 1.5 * IQR. You can test this out by
 creating a boxplot from the iris dataset supplied with R using
 boxplot(iris$Sepal.Length ~ iris$Species). You see that the boxplot is the
 same before and after the fix.  Does anybody know why this occurs, and how
 I
 can get around this issue?
 
 Thanks,
 -- 
 Regards,
 Paul
 
 
 =
 Contact Details
 =
 Paul Raftery, BEng(Hons) (Mech), Fulbright Fellow, PhD
 http://www.paulraftery.com/
  lt;http://www.paulraftery.com/gt;
 Postdoctoral Research Engineer
 Informatics Research Unit for Sustainable Engineering (IRUSE)
 http://www.iruse.ie/
 
 Department of Civil Engineering,
 National University of Ireland, Galway,
 University Road,
 Galway,
 Ireland.
 
 Landline: +353 91 49 3086
 Mobile: +353 85 124 7947
 Skype: praftery
 
   [[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.
 


-
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: 
http://r.789695.n4.nabble.com/Box-plot-with-5th-and-95th-percentiles-instead-of-1-5-IQR-problems-implementing-an-existing-solution-tp3456123p3456187.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 retrieve a vector of a data.frame's variable attributes?

2011-04-17 Thread David Winsemius


On Apr 17, 2011, at 4:21 PM, Bacou, Melanie wrote:


Hi,

I have a data.frame with 100 variables and I have assigned a label,
units and category attribute to each variable. I would like to  
reorder
the variables in the data.frame by the category attributes but  
can't find

a way.



Something like lapply(hh, attr, which=category) might return  
something potentially useful. You obviously have a test case, but have  
failed to offer it up. Possibly using order() around that might get  
all the like category variables together.




For example, the first variable is:


attributes(hh$aez)

$levels
[1] coastal  forest   savannah

$class
[1] labelled factor

$label
[1] ecological zone
93 Levels: 10 quantiles of welfare  ... year of the interview

$units
[1] class
24 Levels: '05 PPP USD / year cedis / year cedis /year class  
geo-1 ... years


$category
[1] geography
7 Levels: agriculture demography design expenditure geography ...  
welfare


I have tried:

hh - hh[, order(attr(hh, category)) ]


Did you look at what order(attr(hh, category)) returns. Since you  
assigned the attribute to individual columns (which are arranged as a  
list, you cannot expect the whole object to return anything useable  
when queried with attr().



hh - hh[, order(attr(hh[, 1:100], category))]


(It would be the same since hh == hh[,1:100] )



hh - hh[, order(attr(dimnames(hh), category))]


dimnames would _not_ have any attributes. And attr can only work on  
one object at a a time anyway,




but all the right-hand side assignments above return NULL.

Thanks very much for your help with this simple task!

--Mel.



___
Melanie Bacou



David Winsemius, MD
West Hartford, CT

__
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] URL Scan

2011-04-17 Thread Barry Rowlingson
On Sun, Apr 17, 2011 at 9:40 PM, jmsc michaelfp...@gmail.com wrote:
 I am wondering why when I try to input data from the first site listed below
 into R using the scan() function, a different page is read in instead (the
 second site listed):

 http://data.visionappraisal.com/CanterburyCT/parcel.asp?pid=1242

 http://www.visionappraisal.com/databases/

 I am wondering if this is an issue with R or something in the source code of
 the web page that I am not familiar with. Since I can access the first site
 directly, I assume it is not within the source code. Any help would be
 appreciated.

 I can't access the first URL directly - even from my web browser
without R being involved at all. Is that pid a parcel ID that you
need to be logged in to see? Or not a valid parcel id anymore?

 If you want to access a web site from R that needs a login/password
then you need to send the appropriate login form info from R and keep
the cookie session info that gets returned. Web sessions from R and
from a web browser are independent.

Barry

__
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] different colors in a segplot centers (package latticeExtra)

2011-04-17 Thread barbara costa
Hi,
how can I change colors in the centers of my segplot?
I'm not interested in coloring the lines (Standard error limits) but the
centers (means)?
 here's my code:


segplot(reorder(factor(Species), MeanBiom)  ~ MinSEBiom + MaxSEBiom ,
data=dfRatioAftBefBiom, draw.bands = FALSE, centers = MeanBiom,
col=as.numeric (Commercial.Value))


thanks a lot,
barbara

[[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] side by side histogram after splitting data by year

2011-04-17 Thread jim holtman
Will one of these do it for you:

 str(x)
'data.frame':   550 obs. of  5 variables:
 $ year: Factor w/ 2 levels one,two: 1 1 1 1 1 1 1 1 1 1 ...
 $ size: Factor w/ 2 levels large,small: 2 2 2 2 2 2 2 2 2 2 ...
 $ distance: num  30.9 121.5 46.1 46.1 46.1 ...
 $ taken   : int  10 2 12 1 4 1 10 3 5 5 ...
 $ mass: num  13.88 2.78 16.65 1.39 5.55 ...
 require(lattice)
 histogram(~taken|year, x)
 histogram(~taken|year*size, x)



On Sun, Apr 17, 2011 at 10:51 AM, Stratford, Jeffrey
jeffrey.stratf...@wilkes.edu wrote:
 Hi everyone,



 I'm looking to produce a side-by-side histogram of the number of trips
 taken by jays with a particular number of acorns after accounting for
 year (year one and year two). I know this involves indexing first
 then creating a histogram but I'm not sure how I'd do this. I want to
 explore the possibilities that jays are altering their strategies in
 different years.  Data are below.



 This is a common need for myself so any help would be greatly
 appreciated!



 Thanks,



 Jeff







 structure(list(year = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
 1L, 1L, 1L,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2L, 2L, 2L,
 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L,
 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
 1L, 1L, 1L, 1L, 1L, 

Re: [R] Dump the source code of data frame

2011-04-17 Thread jim holtman
If you want to save it so that you can read it back later, then look
at 'save' and 'load'.

On Wed, Apr 13, 2011 at 3:09 AM, C.H. chainsawti...@gmail.com wrote:
 Dear R experts,

 I remember a similar function existed and have been mentioned in
 R-help before. I tried my best to search but I really can't find it
 out.

 suppose I have an data frame like this:

 somedata - data.frame(age.min = 1, age.max = 1.5, male = TRUE, l = -1.013, 
 m=16.133, s=0.07656)

 In order to back up the data and I don't want to use write.table(), I
 would like to back up the source code of the data frame. When I
 apply that function (let's call it dumpdf() ), the function will
 reproduce the source code that creates the data.frame. For example:

 dumpdf(somedata)
 somedata - data.frame(age.min = 1, age.max = 1.5, male = TRUE, l =
 -1.013, m=16.133, s=0.07656)

 Is there any function similar to the dumpdf() above?

 Thank you so much!

 Regards,

 CH

 --
 CH Chan

 __
 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?

__
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] URL Scan

2011-04-17 Thread jmsc
The site does not require a login/password. Another way to access the first
site would be to go to the second site, click Connecticut, click Canterbury,
CT, enter the online database, click search under Query by Location with
nothing in the search fields, and click the first property. Viewing the
frame source on this page redirects to the second site.

Also, could you direct me to or give me some instructions on scanning from
sites that do require a login/password? Thanks.

On Sun, Apr 17, 2011 at 6:33 PM, Barry Rowlingson [via R] 
ml-node+3456231-1127256797-230...@n4.nabble.com wrote:

 On Sun, Apr 17, 2011 at 9:40 PM, jmsc [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=3456231i=0by-user=t
 wrote:

  I am wondering why when I try to input data from the first site listed
 below
  into R using the scan() function, a different page is read in instead
 (the
  second site listed):
 
  http://data.visionappraisal.com/CanterburyCT/parcel.asp?pid=1242
 
  http://www.visionappraisal.com/databases/
 
  I am wondering if this is an issue with R or something in the source code
 of
  the web page that I am not familiar with. Since I can access the first
 site
  directly, I assume it is not within the source code. Any help would be
  appreciated.

  I can't access the first URL directly - even from my web browser
 without R being involved at all. Is that pid a parcel ID that you
 need to be logged in to see? Or not a valid parcel id anymore?

  If you want to access a web site from R that needs a login/password
 then you need to send the appropriate login form info from R and keep
 the cookie session info that gets returned. Web sessions from R and
 from a web browser are independent.

 Barry

 __
 [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=3456231i=1by-user=tmailing 
 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.


 --
  If you reply to this email, your message will be added to the discussion
 below:
 http://r.789695.n4.nabble.com/URL-Scan-tp3456084p3456231.html
  To unsubscribe from URL Scan, click 
 herehttp://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=3456084code=bWljaGFlbGZwYWdlQGdtYWlsLmNvbXwzNDU2MDg0fC04NTEyNDQyOTE=.




--
View this message in context: 
http://r.789695.n4.nabble.com/URL-Scan-tp3456084p3456257.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] NEW ONLINE R COURSE: Fundamentals of Using R

2011-04-17 Thread Geoffrey Hubona
EARLY REGISTRATION ENDS APRIL 22



The non-profit organization *Information Institute* (
http://www.information-institute.org) and faculty from Virginia Commonwealth
University (VCU) are offering a live, interactive, synchronous online course
entitled Fundamentals of Using R. The early registration cost (through April
22) for the 14-hour, 5 week course is $195 (student); $250 (faculty); and
$295 (practitioner). All of the live class sessions that
registered participants attend are recorded and provided to those
participants so they can repeatedly review the live sessions at their
convenience.



This course is designed for people who are curious about R, new to R, and
who would like to obtain a basic knowledge of R capabilities that apply to
any ultimate intended use of R. This course instructs about the R
environment: using workspaces; importing and exporting data; R data types,
data structures, and objects; writing simple and complex scripts; essential
R functions and packages; writing your own R functions and packages;
programming with R; publication-style 2-D and 3-D graphics capabilities
using special R packages, and many other essential topics. The course is
designed to serve as a useful knowledge foundation regardless of one’s
ultimate use of R (for example, statistical and data analyses, programming,
writing scripts or creating packages, using graphics, etc.). There is more
information at the URLs below.



The informational (and registration) site for the AM version (AM by US
Eastern Time) is here: https://www.regonline.com/R-fund-may-AM This course
runs on five consecutive Fridays from May 27 to June 24, from 11AM until 2PM
ET (GMT-4).



The informational (and registration) site for the PM version (PM by US
Eastern Time) is here: https://www.regonline.com/R-fund-may-PM  This course
runs on the same five consecutive Fridays (May 27-June 24), but in the
evenings from 6PM until 9PM ET (GMT-4).



Please email ghub...@vcu.edu with any questions or for more information.



Geoff Hubona

Information Systems Department

Virginia Commonwealth University

[[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] as.Date error

2011-04-17 Thread Wonjae Lee

Thank you for replying the as.Date error question.

I have one more question as below.
I used cbind command, and data x changed, 2010-11-16 to 14929, 2010-11-17 to
14930.
What happened to them?
What should I do to see -mm-dd format data?

 x=c(11/16/2010,11/17/2010,11/18/2010,11/19/2010)
 x=as.Date(x,%m/%d/%Y)
 x
[1] 2010-11-16 2010-11-17 2010-11-18 2010-11-19
 y=c(1753.75,15077,1759.35,15078)
 cbind(x,y)
 xy
[1,] 14929  1753.75
[2,] 14930 15077.00
[3,] 14931  1759.35
[4,] 14932 15078.00


Thanks
Wonjae

--
View this message in context: 
http://r.789695.n4.nabble.com/as-Date-error-tp3456279p3456279.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] Incremental ReadLines

2011-04-17 Thread Frederik Lang
Hi again,

Changing my code by defining vectors outside the loop and combining them
afterwards helped a lot so now the code does not slow down anymore and I was
able to parse the file in less than 2 hours. Not fantastic but it works.

I will William's the last suggestion of how to parse it without looping
through for next time I have to parse a large file.

Many thanks for your help!


Frederik

On Thu, Apr 14, 2011 at 4:58 PM, William Dunlap wdun...@tibco.com wrote:

 [see below]

 From: Frederik Lang [mailto:frederikl...@gmail.com]
 Sent: Thursday, April 14, 2011 12:56 PM
 To: William Dunlap
 Cc: r-help@r-project.org
 Subject: Re: [R] Incremental ReadLines



 Hi Bill,

Thank you so much for your suggestions. I will try and alter my
 code.


Regarding the even shorter solution outside the loop it looks
 good but my problem is that not all observations have the same variables
 so that three different observations might look like this:


Id: 1
Var1: false
Var2: 6
Var3: 8

Id: 2
missing

Id: 3
Var1: true
3 4 5
Var2: 7
Var3: 3


Doing it without looping through I thought my data had to quite
 systematic, which it is not. I might be wrong though.

 Doing the simple preallocation that I describe should speed it up
 a lot with very little effort.  It is more work to manipulate the
 columns one at a time instead of using data.frame subscripting and
 it may not be worth it if you have lots of columns.

 If you have a lot of this sort of file and feel that it will be worth
 the programming time to do something fancier, here is some code that
 reads lines of the form

  cat(lines, sep=\n)
 Id: First
   Var1: false
  Var2: 6
  Var3: 8

 Id: Second
 Id: Last
  Var1: true
  Var3: 8

 and produces a matrix with the Id's along the rows and the Var's
 along the columns:

  f(lines)
   Var1Var2 Var3
 First  false 6  8
 Second NA  NA   NA
 Last   true  NA   8

 The function f is:

 f - function (lines)
 {
# keep only lines with colons
lines - grep(value = TRUE, ^.+:, lines)
lines - gsub(^[[:space:]]+|[[:space:]]+$, , lines)
isIdLine - grepl(^Id:, lines)
group - cumsum(isIdLine)
rownames - sub(^Id:[[:space:]]*, , lines[isIdLine])
lines - lines[!isIdLine]
group - group[!isIdLine]
varname - sub([[:space:]]*:.*$, , lines)
value - sub(.*:[[:space:]]*, , lines)
colnames - unique(varname)
col - match(varname, colnames)
retval - array(NA_character_, c(length(rownames),
 length(colnames)),
dimnames = list(rownames, colnames))
retval[cbind(group, col)] - value
retval
 }

 The main trick is the matrix subscript given to retval on the
 penultimate line.

Thanks again,


Frederik



On Thu, Apr 14, 2011 at 12:56 PM, William Dunlap
 wdun...@tibco.com wrote:


I have two suggestions to speed up your code, if you
must use a loop.

First, don't grow your output dataset at each iteration.
Instead of
cases - 0
output - numeric(cases)
while(length(line - readLines(input, n=1))==1) {
   cases - cases + 1
   output[cases] - as.numeric(line)
}
preallocate the output vector to be about the size of
its eventual length (slightly bigger is better),
 replacing
output - numeric(0)
with the likes of
output - numeric(50)
and when you are done with the loop trim down the length
if it is too big
if (cases  length(output)) length(output) - cases
Growing your dataset in a loop can cause quadratic or
 worse
growth in time with problem size and the above sort of
code should make the time grow linearly with problem
 size.

Second, don't do data.frame subscripting inside your
 loop.
Instead of
data - data.frame(Id=numeric(cases))
while(...) {
data[cases, 1] - newValue
}
do
Id - numeric(cases)
while(...) {
Id[cases] - newValue
}
data - data.frame(Id = Id)
This is just the general principal that you don't want
 to
repeat the same operation over and over in a loop.
dataFrame[i,j] first extracts column j then extracts
 element
i from that column.  Since the column is the same every
 iteration
you may as well extract the column outside of the loop.

Avoiding the loop altogether is the fastest.  E.g., the
 code
you showed does the same 

[R] Repeating a function

2011-04-17 Thread Sclera
Hello all,

I currently have this function:

drift -function(p0=0.4,N=40,ngen=55){
p = p0
for( i in 1:ngen){
p = rbinom(1,2*N,p)/(2*N)
}
return( p )
}

I want to repeat it 1000 times, then do some analysis on the results. I've
tried using the rep() function, but that only gives me repeats of the first
value of p. How can I get 1000 values of p for different iterations of the
function?

Thanks in advance

--
View this message in context: 
http://r.789695.n4.nabble.com/Repeating-a-function-tp3456295p3456295.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] Repeating a function

2011-04-17 Thread helin_susam
Hi,

try this;

output - list()

times - 1000

drift -function(p0=0.4,N=40,ngen=55){
p = p0
for( i in 1:ngen){
p = rbinom(1,2*N,p)/(2*N)
}
return( p )
} 
for(i in 1:times){
result - drift(0.4, 40, 55)

output - c(output, list(result))
}

Then, you can use the output with unlist() to do analysis. For example
mean(unlist(output))

Helin.

--
View this message in context: 
http://r.789695.n4.nabble.com/Repeating-a-function-tp3456295p3456358.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] Deleting the last value of a vector

2011-04-17 Thread empyrean
Hey guys,

I've search a few threads about deleting a value from a vector, but no one
has addressed this question so far.

I want to delete the last value from a string of values

I have:

r = [ 1, 2, 3, 4, 5 ], and i want to make r2 = to [ 1, 2, 3, 4]

So that r2 is just like r, except that it missing the final value. 

Thanks,

--
View this message in context: 
http://r.789695.n4.nabble.com/Deleting-the-last-value-of-a-vector-tp3456363p3456363.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] Deleting the last value of a vector

2011-04-17 Thread baptiste auguie
Hi,

Try this,

snip = function(x, n=1) {

rand = sample(1:3, 1)
print(paste(using algorithm #, rand))

switch(rand,
'1' = head(x, length(x) - n),
'2' = x[ seq(1, length(x) - n) ],
'3' = x[ - seq(length(x), by=-1, length=n) ])
}

snip(1:5)


HTH, but please do read the posting guide.

baptiste

On 18 April 2011 12:51, empyrean ctr...@ucdavis.edu wrote:
 Hey guys,

 I've search a few threads about deleting a value from a vector, but no one
 has addressed this question so far.

 I want to delete the last value from a string of values

 I have:

 r = [ 1, 2, 3, 4, 5 ], and i want to make r2 = to [ 1, 2, 3, 4]

 So that r2 is just like r, except that it missing the final value.

 Thanks,

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Deleting-the-last-value-of-a-vector-tp3456363p3456363.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] Deleting the last value of a vector

2011-04-17 Thread Daisy Englert Duursma
A easier solution:

r - c(1, 2, 3, 4, 5)
r2-r[1:length(r)-1]




On Mon, Apr 18, 2011 at 10:51 AM, empyrean ctr...@ucdavis.edu wrote:
 Hey guys,

 I've search a few threads about deleting a value from a vector, but no one
 has addressed this question so far.

 I want to delete the last value from a string of values

 I have:

 r = [ 1, 2, 3, 4, 5 ], and i want to make r2 = to [ 1, 2, 3, 4]

 So that r2 is just like r, except that it missing the final value.

 Thanks,

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Deleting-the-last-value-of-a-vector-tp3456363p3456363.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.




-- 
Daisy Englert Duursma
Department of Biological Sciences
Room E8C156
Macquarie University, North Ryde, NSW 210
Australia

Tel +61 2 9850 9256

__
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] Deleting the last value of a vector

2011-04-17 Thread Min-Han Tan
Or perhaps even more parsimoniously (by a couple of characters) -

r - c(1, 2, 3, 4, 5)
r2-r[-length(r)]

Min-Han

On Sun, Apr 17, 2011 at 10:23 PM, Daisy Englert Duursma 
daisy.duur...@gmail.com wrote:

 A easier solution:

 r - c(1, 2, 3, 4, 5)
 r2-r[1:length(r)-1]




 On Mon, Apr 18, 2011 at 10:51 AM, empyrean ctr...@ucdavis.edu wrote:
  Hey guys,
 
  I've search a few threads about deleting a value from a vector, but no
 one
  has addressed this question so far.
 
  I want to delete the last value from a string of values
 
  I have:
 
  r = [ 1, 2, 3, 4, 5 ], and i want to make r2 = to [ 1, 2, 3, 4]
 
  So that r2 is just like r, except that it missing the final value.
 
  Thanks,
 
  --
  View this message in context:
 http://r.789695.n4.nabble.com/Deleting-the-last-value-of-a-vector-tp3456363p3456363.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.
 



 --
 Daisy Englert Duursma
 Department of Biological Sciences
 Room E8C156
 Macquarie University, North Ryde, NSW 210
 Australia

 Tel +61 2 9850 9256

 __
 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] Repeating a function

2011-04-17 Thread Dennis Murphy
Hi:

The rdist functions are vectorized, so the loop is unnecessary:

drift - rbinom(55, 80, 0.4)

or within a function,

drift - function(p0 = 0.4, N = 40, ngen = 55) rbinom(ngen, 2 * N, p0)

To repeat it 1000 times, you have at least two options:

(1)   [1000 columns]
simmat - replicate(1000, drift())

(2)  [1000 rows]
simmat - matrix(drift(0.4, 40, 1000 * 55), nrow = 1000)

HTH,
Dennis

On Sun, Apr 17, 2011 at 4:48 PM, Sclera kn0wza...@gmail.com wrote:
 Hello all,

 I currently have this function:

 drift -function(p0=0.4,N=40,ngen=55){
        p = p0
        for( i in 1:ngen){
                p = rbinom(1,2*N,p)/(2*N)
                }
        return( p )
        }

 I want to repeat it 1000 times, then do some analysis on the results. I've
 tried using the rep() function, but that only gives me repeats of the first
 value of p. How can I get 1000 values of p for different iterations of the
 function?

 Thanks in advance

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Repeating-a-function-tp3456295p3456295.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] cairo device and locator on windows

2011-04-17 Thread Richard M. Heiberger
In several tries, I am finding the locator and identify functions on the
cairo device on Windows,
with R-2.13.0, do not seem to work correctly.  Here is my experience with
locator where I click the
four corners of the device window.

First, with the windows() device, the results are consistent with what I see
on screen
 windows()
 plot(1,1)
 locator()
$x
[1] 0.6075000 1.3981252 1.3653126 0.6090625
$y
[1] 0.6117440 0.6239533 1.3931395 1.3983721



Second, with the Cairo device, the results are not consistent with what I
see on screen.
 library(cairoDevice)
 Cairo()
 plot(1,1)
 locator()
$x
[1] 0.6715602 1.7007429 1.7071620 0.6672808
$y
[1] 0.2775717 0.2945700 1.3144688 1.3290388


Any guidance on making Cairo work would be appreciated.

Rich

[[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] Print out data frames into neat images

2011-04-17 Thread Santosh Srinivas
Hi Group,

I often need to print out data frames with results of analysis into a
neat little image to copy and paste into documents. I need apply
formatting like bold, currency signs, number formats, header shading
etc.
I currently output the data into csv and format using good old excel.

Any suggestions if there are packages to help with such activities (to
some level of basic functionality).
I know that formatting can get quite adhoc but just wondering if there
is anyway to output reasonably standard output.

(I'm borrowing this idea from javascript plugins that can do such
activities in the HTML5 world).

Thanks,
Santosh

__
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] covariance matrix: a erro and simple mixed model question, but id not know answer sorry

2011-04-17 Thread Maya Joshi
Dear list

I need your help: Execuse me for my limited R knowledge.

#example data set
set.seed (134)
lm=c(1:4)

block = c(rep(lm,6))

gen - c(rep(1, 4), rep(2, 4), rep(3, 4), rep(4, 4),rep(5, 4),rep(6, 4))

X1 = c( rnorm (4, 10, 4), rnorm (4, 12, 6), rnorm (4, 10, 7),rnorm (4, 5, 2),
rnorm (4, 8, 4), rnorm (4,7, 2))

X2 = X1 + rnorm(length(X1), 0,3)

yvar - c(X1, X2)

X - c(rep( 1, length(X1)), rep( 2, length(X2))) # dummy x variable

dataf - data.frame(as.factor(block), as.factor(gen), as.factor(X), yvar )



My objective to estimate variance-covariance between two variables X1 and
X2. Means that I need to fit something like unstructure (UN) covariance
structure.



Question 1: I got the following error

require(lme4);

fm1Gen - lmer(yvar ~ X + gen +(1|block), data= dataf) # Question 1: should
I consider X fixed or random



Error in model.frame.default(data = dataf, formula = yvar ~ X + gen +  :
  variable lengths differ (found for 'gen')



A tried nlme too.

require(nlme)

fm2Gen - lme(yvar ~ X + gen,  random= ~ 1|block, data= dataf)

Error in model.frame.default(formula = ~yvar + X + gen + block, data = list(
:
  variable lengths differ (found for 'gen') # similar error



Question 2: How can get I covariance matrix between X1 and X2 either using
lme4 or lmer.

   X1X2

X1   Var (X1) Cov(X1,X2)

X2   Cov(X1, X2)  Var(X2)



Should I put gen in the model to do this? Should I specify something in *
correlation* =  

Thank you for your time

Maya

[[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] Using jitter function with differing variable lengths

2011-04-17 Thread Danica Horrell
Hi,

I am trying to make a scatter plot with 4 different categories using the
jitter function.  My code returns a variable length error and will not plot
because my four categories have different numbers of samples.  When I delete
samples from my spreadsheet so that each of the categories has the same
number of variables, it plots just fine.

Is there any way to get around this and plot all of my samples using jitter?

Thanks for the help!

[[alternative HTML version deleted]]

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


Re: [R] How to retrieve a vector of a data.frame's variable attributes?

2011-04-17 Thread Bacou, Melanie
David,

Thanks very much. That was the right method.

--Mel.

-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: Sunday, April 17, 2011 6:00 PM
To: Bacou, Melanie
Cc: r-help@r-project.org
Subject: Re: [R] How to retrieve a vector of a data.frame's variable
attributes?


On Apr 17, 2011, at 4:21 PM, Bacou, Melanie wrote:

 Hi,

 I have a data.frame with 100 variables and I have assigned a label,
 units and category attribute to each variable. I would like to  
 reorder
 the variables in the data.frame by the category attributes but  
 can't find
 a way.


Something like lapply(hh, attr, which=category) might return  
something potentially useful. You obviously have a test case, but have  
failed to offer it up. Possibly using order() around that might get  
all the like category variables together.


 For example, the first variable is:

 attributes(hh$aez)
 $levels
 [1] coastal  forest   savannah

 $class
 [1] labelled factor

 $label
 [1] ecological zone
 93 Levels: 10 quantiles of welfare  ... year of the interview

 $units
 [1] class
 24 Levels: '05 PPP USD / year cedis / year cedis /year class  
 geo-1 ... years

 $category
 [1] geography
 7 Levels: agriculture demography design expenditure geography ...  
 welfare

 I have tried:

 hh - hh[, order(attr(hh, category)) ]

Did you look at what order(attr(hh, category)) returns. Since you  
assigned the attribute to individual columns (which are arranged as a  
list, you cannot expect the whole object to return anything useable  
when queried with attr().

 hh - hh[, order(attr(hh[, 1:100], category))]

(It would be the same since hh == hh[,1:100] )


 hh - hh[, order(attr(dimnames(hh), category))]

dimnames would _not_ have any attributes. And attr can only work on  
one object at a a time anyway,


 but all the right-hand side assignments above return NULL.

 Thanks very much for your help with this simple task!

 --Mel.



 ___
 Melanie Bacou


David Winsemius, MD
West Hartford, CT

__
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] error message while running IRT model

2011-04-17 Thread Haillie
I have been struggling with the same problem for the past few hours and am
desperately in need of some help. The code I am running is as follows:

## opening a data set on the desktop
setwd(C:/Users/haillie/Desktop)
UN2010- read.csv(UN2010.csv,header=TRUE)

##calling libraries
library(reshape)
library(car)

## these are the variables I want to recode
colname - names(UN2010)


## this applies the recode functionto all the variable I want to recode
UN2010[colname] -
   lapply(UN2010[colname],
   function(x) recode(x, recodes = 8=NA,
   as.factor.result = FALSE, as.numeric.result = TRUE))
   

UN2010frame-data.matrix(lapply(UN2010,as.numeric))

ord.out1-ordrating(UN2010, beta.constraint=1, tune=.035,
ma=1, mb=-5, vinva=1, vinvb=0.05,
gamma.start=c(-300, 0, 1.5, 3.0, 4.5, 300),
thin=20, burnin=2, mcmc=10, verbose=1000)


##
However, when i try to run the above ordrating code, an error message comes
up  NA/NaN/Inf in foreign function call (arg 24). Because I interpreted
this as that this model has no ability to perform na.omit, I did na.omit
myself using the code UN2010-na.omit(UN2010). However, I encoutered another
problem then. 

I recieved the below error messages this time..
Error in dimnames(x) - dn : 
  length of 'dimnames' [1] not equal to array extent
In addition: Warning messages:
1: In min(Y, na.rm = TRUE) :
  no non-missing arguments to min; returning Inf
2: In max(Y, na.rm = TRUE) :
  no non-missing arguments to max; returning -Inf
3: In max(Y, na.rm = TRUE) :
  no non-missing arguments to max; returning -Inf
 
##

I have tried everything I could but nothing has worked so far. Any advice or
help would be deeply appreciated. Thank you very much.

Haillie 


--
View this message in context: 
http://r.789695.n4.nabble.com/error-message-while-running-IRT-model-tp3456603p3456603.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.