Re: [R] Evaluated expression in lattice key

2015-01-22 Thread Naresh Gurbuxani
Chee Hee,
This is indeed what I was looking for.  
Thank you for introducing me to panel.text,
Naresh

> Date: Mon, 19 Jan 2015 21:17:18 -0600
> From: chl...@mail.usask.ca
> Subject: Re: [R] Evaluated expression in lattice key
> To: naresh_gurbux...@hotmail.com; r-help@r-project.org
> 
> I guess that you may need 'panel.text()' to customize panel function. 
> Please run the following code and see the output.  You will see 
> different value of R-squared in each panel.
> 
> xyplot(
>y~x|name, data=df,
>panel = function(x, y, ...) {
>  panel.xyplot(x, y, ...)
>  panel.abline(lm(y~x), col="red")
>  panel.text(1, -1, bquote(R^2 == .(summary(lm(y~x))$r.squared)))
>},
>grid = TRUE
> )
> 
> Is this what you are looking for?  I hope this helps.
> 
> Chel Hee Lee
> 
> 
> On 01/17/2015 07:08 AM, Naresh Gurbuxani wrote:
> > In a conditional xyplot, I would like to add some numerical results in 
> > every panel.  Consider below example.
> > df <- data.frame(x = rnorm(100), name = "A")
> > df <- within(df, {y <- x + 0.2 * rnorm(100)})
> > df2 <- data.frame(x = rnorm(100), y = rnorm(100), name = "B")
> > df <- rbind(df, df2)
> > rm(df2)
> >
> >
> > with(df, xyplot(y ~ x | name, data = df,
> >panel = function(x, y, ...){
> > panel.xyplot(x, y)
> > panel.lmline(x, y, col = "grey")
> >},
> >auto.key = list(corner = c(1,0), x = 0.9, y = 0.1,
> >text = substitute(expression(R^{2} == myval),
> >list(myval = summary(lm(y ~ x))$r.squared)
> > There are two problems with this plot.  First, there is only one key.  I 
> > want two different keys for the two panels.
> > Second, R^2 is for all data.  For each panel, I want R^2 calculated using 
> > only the data plotted in that panel.
> > Please help.
> > Thanks,Naresh   
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
  
[[alternative HTML version deleted]]

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


Re: [R] need help with renaming a variable

2015-01-22 Thread JSHuang3181
Hi,

  Here is my suggestion:

To change variable 2 name:
>names(temp.data)[2] <- "transsactionnumber"

To show all variable names to verify:
>names(temp.data)




--
View this message in context: 
http://r.789695.n4.nabble.com/need-help-with-renaming-a-variable-tp4702154p4702179.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] need help with renaming a variable

2015-01-22 Thread Jim Lemon
Hi Pavel,
The problem may be with the name "2013fixed.data". I don't know where
that came from, but try naming it "fixed2013.data".

Jim


On Fri, Jan 23, 2015 at 4:53 AM, Pavel Yakovlev  wrote:
> Hello.
>
> I am new to R, so my question/problem might be very basic, but I cannot
> figure out how to solve it.
> So, I would really appreciate your help.
>
> I would like to rename a variable in a very large file (181GB) called
> "2013.xdf" that is saved on my external hard drive.
>
> I tried running the following code to rename variable # 2 in the file and
> save this change, which produced some errors that I cannot resolve:
>
>> temp.data <- rxGetVarInfo("E:/2013.xdf")
>> temp.data[2] <- "transsactionnumber"
>> rxSetVarInfo(2013fixed.data, outfile)
> Error: unexpected symbol in "rxSetVarInfo(2013fixed.data"
>> rxSetVarInfo(temp.data, outfile)
> Error in is.data.frame(file) : object 'outfile' not found
>> rxSetVarInfo(outfile)
> Error in rxSetVarInfoXdf(varInfo, file = data) :
>   object 'outfile' not found
>
>
> Please help me figure out how to do it right.
>
> Gratefully,
> --
>
> Pavel A. Yakovlev, Ph.D.
> Associate Professor
> 819 Rockwell Hall
> Department of Economics and Finance
> Duquesne University
> 600 Forbes Avenue
> Pittsburgh, PA 15282
> Work Phone: 412-396-1908
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


[R] Error in data.frame

2015-01-22 Thread Jim Lemon
John Wasige wrote:
>
> Hi Jim,
>
> I still get the same error. This is to kindly request for your help. Attached 
> herewith is the
> test dataset. Thanks for your help.
...

Hi John,
The file you sent is in some proprietary format that I cannot read.
Fortunately there is a text header and this includes a description of
a variable named "time" coded as the number of days since 1/1/1900.
This is probably the variable you want to use instead of "dates". I
don't know how "dates" was constructed, but it is probably the cause
of the error.

Jim

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


Re: [R] abline?

2015-01-22 Thread Olivier Crouzet
> >
> > plot(r2,d)
> > res = lm(r2~d)
> >
> Mixing up your x and y coordinate.  Do:
> 
> plot(d,r2)

... or use:

plot(r2 ~ d)

so that

res <- lm(r2 ~ d)

uses exactly the same pattern...

Olivier.

-- 
  Olivier Crouzet, PhD
  Laboratoire de Linguistique -- EA3827
  Université de Nantes
  Chemin de la Censive du Tertre - BP 81227
  44312 Nantes cedex 3
  France

 phone:(+33) 02 40 14 14 05 (lab.)
   (+33) 02 40 14 14 36 (office)
 fax:  (+33) 02 40 14 13 27
 e-mail:   olivier.crou...@univ-nantes.fr

  http://www.lling.univ-nantes.fr/

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

Re: [R] abline?

2015-01-22 Thread Rolf Turner

On 23/01/15 08:39, Dennis P. Weygand wrote:

I am a very new user of R, trying to do a linear fit to data,

plot(r2,d)

plots my data correctly, I do a linear fit:

res = lm(r2~d)

gives a fit to the data, but

abline(res,col=“red”)

displays nothing. Again, I am a novice, but what am I doing wrong?


Mixing up your x and y coordinate.  Do:

plot(d,r2)
abline(res,col="red")

and all will be in harmony in the Universe.

cheers,

Rolf Turner


--
Rolf Turner
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
Home phone: +64-9-480-4619

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


[R] abline?

2015-01-22 Thread Dennis P. Weygand
I am a very new user of R, trying to do a linear fit to data,

plot(r2,d)

plots my data correctly, I do a linear fit:

res = lm(r2~d)

gives a fit to the data, but

abline(res,col=“red”)

displays nothing. Again, I am a novice, but what am I doing wrong?

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


Re: [R] Counting Words

2015-01-22 Thread bgnumis bgnum
That' s perfect. Many thanks forma your appreciated help.
El 22/01/2015 19:50, "Chel Hee Lee"  escribió:

> > x <- c("hola mundo mundo");
> > table(unlist(strsplit(x, " ")))
>
>  hola mundo
> 1 2
> >
>
> Is this what you are looking for?  I hope this helps.
>
> Chel Hee Lee
>
> On 1/22/2015 8:25 AM, bgnumis bgnum wrote:
>
>> Hi all,
>>
>> I want to cout the different words in a text.
>>
>> You see if the text is: "hola mundo mundo" the program will count:
>>
>> hola 1
>> mundo 2
>>
>> Is posible that Cran r have a similar function?
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/
>> posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>

[[alternative HTML version deleted]]

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

Re: [R] Counting Words

2015-01-22 Thread MacQueen, Don
In addition to the other suggestions, which are fine for your simple
example, I would take a trip to the CRAN Task View "Natural Language
Processing", and see if there's anything there.

-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 1/22/15, 6:25 AM, "bgnumis bgnum"  wrote:

>Hi all,
>
>I want to cout the different words in a text.
>
>You see if the text is: "hola mundo mundo" the program will count:
>
>hola 1
>mundo 2
>
>Is posible that Cran r have a similar function?
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Counting Words

2015-01-22 Thread Ista Zahn
table(strsplit("hola mundo mundo", " ")[[1]])

On Thu, Jan 22, 2015 at 9:25 AM, bgnumis bgnum  wrote:
> Hi all,
>
> I want to cout the different words in a text.
>
> You see if the text is: "hola mundo mundo" the program will count:
>
> hola 1
> mundo 2
>
> Is posible that Cran r have a similar function?
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Counting Words

2015-01-22 Thread Chel Hee Lee

> x <- c("hola mundo mundo");
> table(unlist(strsplit(x, " ")))

 hola mundo
1 2
>

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

Chel Hee Lee

On 1/22/2015 8:25 AM, bgnumis bgnum wrote:

Hi all,

I want to cout the different words in a text.

You see if the text is: "hola mundo mundo" the program will count:

hola 1
mundo 2

Is posible that Cran r have a similar function?

[[alternative HTML version deleted]]

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



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


[R] Advanced R: manipulating lists, asking a help with programming

2015-01-22 Thread Kaja
Hello!

my question is about a specific problem concerning programming R for that I
have not found a solution since 2 weeks (I have seen forums, searched on
google, all).

The main goal is to remove overlaping events. I have two equal lists of 10
dataframes each (number of rows of these 10 dataframes is varying): in one
are values (list.n) and in another corresponding Dates (list.perc), each
column represents one station (the same stations are in all 10 dataframes
of a list, identically ranked, number of rows is about 20.000); NA values
if any are in the end of columns.

I would like to create a program, a loop such as:
telling the program find me a maximum value for a station (for a given
column) iSta over the list.n. This value N has to be conserved. Create a
variable D==dataframes position in list.n (i.e. list.n[[D]]). Search the
same position over the list.perc (for column iSta), the corresponding
date==X (new variable that has also to be stocked). Make all dates(in
list.perc) and corresponding values (in list.n) "NA" (or remove them
directly) that are inside (or equal) the following interval (with exeption
of N and X that have to be conserved):
{X-D'+1,X+D-1+D'-1} for D' from 1 to 10  corresponding to the searching
dataframes position (e.g., if searching in list.perc[[3]], D'==3)
Then search the second maximum over list.n for the given station iSta etc.
until the last remaining value of iSta over list.n and list.perc
respectively. Do this for all iSta stations.
The result may be a simplified list from that I will extract only not NA
values.

Can someone help me?

May be there is a package that can do this. I have at least found this
logic of proceeding and then try all like lapply and sapply function for
searching maximum and its index for iSta across list, but I am not able to
find suitable commands to do this task across lists and in the best not
much time consuming way.

May be I have to try with 3D matrix?

Thanks a lot for any idea!
I send you a short example of my Data with only 2 (instead of 10)
dataframes in a list that has to be arrandes as follows:

> list.n<-vector("list",2)
> list.perc<-vector("list",2)
 >
n1<-read.table("C:/.../list_N1.txt",sep="\t",header=TRUE,na.strings="NA",dec=".",
as.is=TRUE)
>
n2<-read.table("C:/.../list_N2.txt",sep="\t",header=TRUE,na.strings="NA",dec=".",
as.is=TRUE)
>
perc1<-read.table("C:/.../list_Perc1.txt",sep="\t",header=TRUE,na.strings="NA",dec=".",
as.is=TRUE)
>
perc2<-read.table("C:/.../list_Perc2.txt",sep="\t",header=TRUE,na.strings="NA",dec=".",
as.is=TRUE)
> list.n[[1]]<-n1
> list.n[[2]]<-n2
> list.perc[[1]]<-perc1
> list.perc[[2]]<-perc2
> list.perc
> list.n

Best regards,
Jana


list_N2.txt (1K) 

list_Perc1.txt (1K) 

list_Perc2.txt (1K) 

list_N1.txt (1K) 





--
View this message in context: 
http://r.789695.n4.nabble.com/Advanced-R-manipulating-lists-asking-a-help-with-programming-tp4702132.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


[R] need help with renaming a variable

2015-01-22 Thread Pavel Yakovlev
Hello.

I am new to R, so my question/problem might be very basic, but I cannot
figure out how to solve it.
So, I would really appreciate your help.

I would like to rename a variable in a very large file (181GB) called
"2013.xdf" that is saved on my external hard drive.

I tried running the following code to rename variable # 2 in the file and
save this change, which produced some errors that I cannot resolve:

> temp.data <- rxGetVarInfo("E:/2013.xdf")
> temp.data[2] <- "transsactionnumber"
> rxSetVarInfo(2013fixed.data, outfile)
Error: unexpected symbol in "rxSetVarInfo(2013fixed.data"
> rxSetVarInfo(temp.data, outfile)
Error in is.data.frame(file) : object 'outfile' not found
> rxSetVarInfo(outfile)
Error in rxSetVarInfoXdf(varInfo, file = data) :
  object 'outfile' not found


Please help me figure out how to do it right.

Gratefully,
-- 

Pavel A. Yakovlev, Ph.D.
Associate Professor
819 Rockwell Hall
Department of Economics and Finance
Duquesne University
600 Forbes Avenue
Pittsburgh, PA 15282
Work Phone: 412-396-1908

[[alternative HTML version deleted]]

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


Re: [R] Re-order levels of a categorical (factor) variable

2015-01-22 Thread Ravi Varadhan
Dear Bert, Martin, Bill,

Thank you very much for the help.  Bert & Martin's solutions solved my problem. 
 Would it be useful to add an example like this to the help page on ?factor or 
?levels?

Thanks again,
Ravi

From: Martin Maechler 
Sent: Thursday, January 22, 2015 10:29 AM
To: Bert Gunter
Cc: William Dunlap; r-help@r-project.org; Ravi Varadhan
Subject: Re: [R] Re-order levels of a categorical (factor) variable

> Bert Gunter 
> on Wed, 21 Jan 2015 18:52:12 -0800 writes:

> Bill/Ravi:
> I believe the problem is that the factor is automatically created when
> a data frame is created by read.table(). By default, the levels are
> lexicographically ordered. The following reproduces the problem and
> gives a solution.

>> library(lattice)

>> z <- data.frame(y = 1:9, x = rep(c("pre", "day2","day10")))
>> xyplot(y~x,data=z) ## x axis order is day 10, day2, pre

>> levels(z$x)
> [1] "day10" "day2"  "pre"

>> z$x <- factor(as.character(z$x),levels=c(levels(z$x)[3:1])) ## 
explicitly defines level order
>> xyplot(y~x,data=z) ##  desired plot

Indeed, thank you, Bert,
and using  levels(.) <- *   does *not* work... (as I first thought).

However, slightly shorter and easier and maybe even easier to remember than

 z$x <- factor(as.character(z$x), levels = c(levels(z$x)[3:1])) ## def. level 
order

is

 z$x <- factor(z$x, levels = levels(z$x)[3:1])   ## def. level order


Martin Maechler, ETH Zurich


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


Re: [R] cat() and \r et al. escape sequences - are there more?

2015-01-22 Thread Rainer M Krug


Envoyé de mon iPhone

> Le 22 janv. 2015 à 15:29, Prof Brian Ripley  a écrit :
> 
>> On 22/01/2015 14:22, Rainer M Krug wrote:
>> 
>> 
>> Envoyé de mon iPhone
>> 
>>> Le 22 janv. 2015 à 15:11, Prof Brian Ripley  a écrit 
>>> :
>>> 
>>> See ?Quotes.
>> 
>> Perfect - thanks.
>> 
>>> 
 On 22/01/2015 13:32, Rainer M Krug wrote:
 Hi
 
 I just discovered \r and \t
 
 --8<---cut here---start->8---
> cat(LETTERS, "\n")
 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
> 
 --8<---cut here---end--->8---
 
 --8<---cut here---start->8---
> cat(LETTERS, "\r", letters, "\n")
  a b c d e f g h i j k l m n o p q r s t u v w x y z
> 
> --8<---cut here---end--->8---
 
 and
 \a as alert
 \b as backspace
 \f as form-feed
 \n as newline
 \r as carriage-return
 \t as tab
 \v as vertical-tab
 
 are there more of these escape sequences?
 
 Especially, Can I position the cursor at a specific column? I would like
 to do this to show progress in an analysis done with mclapply() on
 multiple cores and, preferably, display each core (7) at a fixed
 position in a line.
>>> 
>>> How these are interpreted is a matter for the terminal/console. Some 
>>> terminals have escape sequences to do that, but most consoles do not.
>> 
>> You don't know by any chance if terminal on Yosemite has these?
> 
> Depends what terminal you set it to emulate, but likely yes.  See e.g. 
> http://www.termsys.demon.co.uk/vtansi.htm 

Thanks - exactly the information I was looking for. 

I'll give feedback if I get it to work. 

Thanks,

Rainer

> 
>> 
>> Thanks,
>> 
>> Rainer
>> 
>>> 
 
 Thanks,
 
 Rainer
 
 
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
>>> 
>>> 
>>> --
>>> Brian D. Ripley,  rip...@stats.ox.ac.uk
>>> Emeritus Professor of Applied Statistics, University of Oxford
>>> 1 South Parks Road, Oxford OX1 3TG, UK
> 
> 
> -- 
> Brian D. Ripley,  rip...@stats.ox.ac.uk
> Emeritus Professor of Applied Statistics, University of Oxford
> 1 South Parks Road, Oxford OX1 3TG, UK

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

[R] How to show the color bar legend in R?

2015-01-22 Thread Ferra Xu
 Based on the dataset, I computed a 3D kernel (longitude, latitude, depth) and 
displayed the magnitude with the sphere radius and time with color as follows. 
I am wondering how I can show the color bar legend. Also I have problem with 
the scale of the graph. I need to see if the balls touch or overlap each other 
from the graph but since the scales are not real I cannot recognize it. How can 
I correct it? library(ks)
x <- read.csv("HK1.csv")
y <- x[,1:3]
fhat1 <- kde(x=y)
n <- nrow(x)
col <- grey((n:1)/n)
plot(fhat1, xlim=c(0,500), ylim=c(0,250), zlim=c(0, 4.4))
spheres3d(y, radius=15*(x$magnitude), alpha=1, col= col)I tried this code 
(which didn't work):legend_image <- as.raster(matrix(grey((n:1)/n), ncol=1))
plot(c(0,2),c(0,200),type = 'n', axes = F, xlab = '', ylab = '', main =  'time 
scale')
text(x=1.5, y = seq(0,200,l=5), labels = seq(0,200,l=5))
rasterImage(legend_image, 0, 0, 1, 1)And this one in "plotrix" 
package:testcol<- col
col.labels<- seq(0,200, l=5)
color.legend(600, 0, 601,200,col.labels,testcol,gradient="y")But it gives me 
this error:Error in rect(xleft, ybottoms, xright, ytops, col = col, lty = 0) : 
plot.new has not been called yetHere is my data: longitude   latitudedepth  
 time  magnitude

422.697323  164.19886   2.4574198.083796636  0.83367586
423.008236  163.32434   0.5551326   37.58477455  0.893893903
204.733908  218.36365   1.9397874   37.88324312  0.912809449
203.963056  218.48080.3723791   43.21775903  0.926406005
100.727581  46.608761.4022341   49.41510519  0.782807523
453.335182  244.25521   1.6292517   51.73779175  0.903910803
134.909462  210.96333   2.2389119   53.13433521  0.896529401
135.300562  212.02055   0.6739541   67.55073745  0.748783521
258.237117  134.29735   2.1205291   76.34032587  0.735699304
341.305271  149.26953   3.71895894.33975483  0.849509216
307.138925  59.605710.6311074   106.9636715  0.987923188
307.76875   58.914532.6496741   113.8515307  0.802115718
415.025535  217.17398   1.7155688   115.7464603  0.875580325
414.977687  216.73327   1.7107369   115.9776948  0.767143582
311.006135  173.24378   2.7819572   120.8079566  0.925380118
310.116929  174.28122   4.3318722   129.2648401  0.776528535
347.260911  37.349463.5155427   136.7851291  0.851787115
351.317624  33.657030.5806926   138.7349284  0.909723017
4.47189259.420681.4062959   139.0543783  0.967270976
5.48022359.728572.7326106   139.2114277  0.987787428
199.513023  21.533022.5163259   143.5895625  0.864164659
198.718031  23.501630.4801849   147.2280466  0.741587333
26.650517   35.2019 0.8246514   150.4876506  0.744788202
25.089379   90.478250.8700944   152.1944046  0.777252476
26.307439   88.415522.4422487   155.9090026  0.952215177
234.282901  236.11422   1.8115261   155.9658144  0.776284654
235.052948  236.77437   1.9644963   156.6900297  0.944285448
23.048202   98.6261 3.4573048   159.7700912  0.773057491
21.516695   98.054312.5029284   160.8202997  0.978779087
213.936324  151.87013   3.1042192   161.0612489  0.80499513
277.887935  197.25753   1.3659279   163.673142   0.758978575
277.239746  197.54001   2.2109361   166.2629868  0.775325157

[[alternative HTML version deleted]]

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


[R] Counting Words

2015-01-22 Thread bgnumis bgnum
Hi all,

I want to cout the different words in a text.

You see if the text is: "hola mundo mundo" the program will count:

hola 1
mundo 2

Is posible that Cran r have a similar function?

[[alternative HTML version deleted]]

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


Re: [R] ggplot courses?

2015-01-22 Thread Charles Determan Jr
I don't know about any courses but I recommend the cookbook for R website:

http://www.cookbook-r.com/Graphs/

There are many examples implementing ggplot2 for different types of plots.

Hope this helps,

On Thu, Jan 22, 2015 at 12:14 PM, Erin Hodgess 
wrote:

> Hello!
>
> Are there any ggplot courses, please?  This would be for a beginner in
> ggplot; I know the base plot, but nothing from there.
>
> Thanks,
> Erin
>
>
> --
> Erin Hodgess
> Associate Professor
> Department of Mathematical and Statistics
> University of Houston - Downtown
> mailto: erinm.hodg...@gmail.com
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Dr. Charles Determan, PhD
Integrated Biosciences

[[alternative HTML version deleted]]

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


Re: [R] ggplot courses?

2015-01-22 Thread Erin Hodgess
thank you!


On Thu, Jan 22, 2015 at 1:18 PM, Bert Gunter  wrote:

> Check:
>
> http://www.rstudio.com/
>
> (where Hadley works)
>
> -- Bert
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
> (650) 467-7374
>
> "Data is not information. Information is not knowledge. And knowledge
> is certainly not wisdom."
> Clifford Stoll
>
>
>
>
> On Thu, Jan 22, 2015 at 10:14 AM, Erin Hodgess 
> wrote:
> > Hello!
> >
> > Are there any ggplot courses, please?  This would be for a beginner in
> > ggplot; I know the base plot, but nothing from there.
> >
> > Thanks,
> > Erin
> >
> >
> > --
> > Erin Hodgess
> > Associate Professor
> > Department of Mathematical and Statistics
> > University of Houston - Downtown
> > mailto: erinm.hodg...@gmail.com
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>



-- 
Erin Hodgess
Associate Professor
Department of Mathematical and Statistics
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

[[alternative HTML version deleted]]

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


Re: [R] ggplot courses?

2015-01-22 Thread Bert Gunter
Check:

http://www.rstudio.com/

(where Hadley works)

-- Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

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




On Thu, Jan 22, 2015 at 10:14 AM, Erin Hodgess  wrote:
> Hello!
>
> Are there any ggplot courses, please?  This would be for a beginner in
> ggplot; I know the base plot, but nothing from there.
>
> Thanks,
> Erin
>
>
> --
> Erin Hodgess
> Associate Professor
> Department of Mathematical and Statistics
> University of Houston - Downtown
> mailto: erinm.hodg...@gmail.com
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] How to split a data table into multiple tables based on column (unique value) and save them separately

2015-01-22 Thread Bert Gunter
Kristi:

You post here frequently.

1. Have you gone through any R tutorials (e.g. "An Intro to R", which
ships with R) where you would find out about how to handle such basic
operations? If not, why not??

2. Why do you persist in posting in HTML, even though you have been
asked not to? Not an issue here, particularly, but ...

2.5 But kudos on posting a small reproducible example that can be cut
and pasted.

3. To answer your question, either the base R idiom
lapply(split(...),FUN=..) or ?tapply handles this. ?by, ?aggregate,
and ?ave are wrappers that might be more convenient, so you might
start there. Hadley Wickham's widely used plyr package provides what
many consider to be much more usable interfaces and flexibility for
this sort of thing, so you may wish to learn and use this instead.

Cheers,
Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

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




On Thu, Jan 22, 2015 at 9:52 AM, Kristi Glover
 wrote:
> How to split a data table into multiple tables based on column (unique value) 
> and save them separately ?
>
>  For example:
> dat<-structure(list(name = structure(c(1L, 1L, 1L, 2L, 2L, 3L, 3L,
> 4L), .Label = c("A", "B", "C", "D"), class = "factor"), date = structure(c(6L,
> 7L, 8L, 1L, 2L, 3L, 4L, 5L), .Label = c("5/10/2011", "5/11/2011",
> "5/12/2011", "5/13/2011", "5/14/2011", "5/7/2011", "5/8/2011",
> "5/9/2011"), class = "factor"), index = c(0.880538463, 0.256183209,
> 0.447239913, 0.942572251, 0.756441284, 0.098201146, 0.730044176,
> 0.177744529)), .Names = c("name", "date", "index"), class = "data.frame", 
> row.names = c(NA,
> -8L))
> to make seperate table based on unique value, I did following way
> siteA<-subset(dat, dat$name=="A")
> write.csv(siteA, "siteA.csv")
> Similarly for site B,
> siteB<-subset(dat, dat$name=="B")
> write.csv(siteB, "siteB.csv")
> and so on
>
> But I have more than 800 unique numbers in the column "name". Therefore, I 
> have to repeat it more than 800 times,
> I am wondering there is a quickest way to split the data and save 
> automatically in csv format.
> Thanks for your help.
> KG
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


[R] ggplot courses?

2015-01-22 Thread Erin Hodgess
Hello!

Are there any ggplot courses, please?  This would be for a beginner in
ggplot; I know the base plot, but nothing from there.

Thanks,
Erin


-- 
Erin Hodgess
Associate Professor
Department of Mathematical and Statistics
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

[[alternative HTML version deleted]]

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


Re: [R] How to split a data table into multiple tables based on column (unique value) and save them separately

2015-01-22 Thread Ista Zahn
The answer is right there in your question: see ?split

Best,
Ista
On Jan 22, 2015 12:55 PM, "Kristi Glover"  wrote:

> How to split a data table into multiple tables based on column (unique
> value) and save them separately ?
>
>  For example:
> dat<-structure(list(name = structure(c(1L, 1L, 1L, 2L, 2L, 3L, 3L,
> 4L), .Label = c("A", "B", "C", "D"), class = "factor"), date =
> structure(c(6L,
> 7L, 8L, 1L, 2L, 3L, 4L, 5L), .Label = c("5/10/2011", "5/11/2011",
> "5/12/2011", "5/13/2011", "5/14/2011", "5/7/2011", "5/8/2011",
> "5/9/2011"), class = "factor"), index = c(0.880538463, 0.256183209,
> 0.447239913, 0.942572251, 0.756441284, 0.098201146, 0.730044176,
> 0.177744529)), .Names = c("name", "date", "index"), class = "data.frame",
> row.names = c(NA,
> -8L))
> to make seperate table based on unique value, I did following way
> siteA<-subset(dat, dat$name=="A")
> write.csv(siteA, "siteA.csv")
> Similarly for site B,
> siteB<-subset(dat, dat$name=="B")
> write.csv(siteB, "siteB.csv")
> and so on
>
> But I have more than 800 unique numbers in the column "name". Therefore, I
> have to repeat it more than 800 times,
> I am wondering there is a quickest way to split the data and save
> automatically in csv format.
> Thanks for your help.
> KG
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] How to split a data table into multiple tables based on column (unique value) and save them separately

2015-01-22 Thread Kristi Glover
How to split a data table into multiple tables based on column (unique value) 
and save them separately ?

 For example: 
dat<-structure(list(name = structure(c(1L, 1L, 1L, 2L, 2L, 3L, 3L, 
4L), .Label = c("A", "B", "C", "D"), class = "factor"), date = structure(c(6L, 
7L, 8L, 1L, 2L, 3L, 4L, 5L), .Label = c("5/10/2011", "5/11/2011", 
"5/12/2011", "5/13/2011", "5/14/2011", "5/7/2011", "5/8/2011", 
"5/9/2011"), class = "factor"), index = c(0.880538463, 0.256183209, 
0.447239913, 0.942572251, 0.756441284, 0.098201146, 0.730044176, 
0.177744529)), .Names = c("name", "date", "index"), class = "data.frame", 
row.names = c(NA, 
-8L))
to make seperate table based on unique value, I did following way
siteA<-subset(dat, dat$name=="A")
write.csv(siteA, "siteA.csv")
Similarly for site B, 
siteB<-subset(dat, dat$name=="B")
write.csv(siteB, "siteB.csv")
and so on 

But I have more than 800 unique numbers in the column "name". Therefore, I have 
to repeat it more than 800 times, 
I am wondering there is a quickest way to split the data and save automatically 
in csv format. 
Thanks for your help. 
KG

  
[[alternative HTML version deleted]]

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


Re: [R] 'which' statement for recode?

2015-01-22 Thread Jeff Newmiller
?factor

You might find the description in the Introduction to R that comes with the R 
software helpful if the help page seems terse.

Please read the Posting Guide and particular post using plain text format, a 
strong in your email program.
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

On January 22, 2015 8:01:25 AM PST, Charles Stangor  wrote:
>Hi,
>
>Is there a way to easily convert the list of course terms into
>sequential
>integers in the dataframe (see code below)?
>
>eg. "199801" = 1; "199808"=2
>
>I know I can use recode but shouldn't "which" work?
>
>Thanks in advance!
>
>
>sc = data.frame(c("200208", "200701", "201201"))
>names(sc) = c("TERM")
>
>TermList = c(NA, "199801", "199808", "199901", "199908", "21",
>"28", "200101", "200108",
>"200201", "200208", "200301", "200308", "200401", "200408",
>"200501", "200508",
>"200601", "200608", "200701", "200708", "200801", "200808",
>"200901", "200908",
>"201001", "201008", "201101", "201108", "201201", "201308",
>"201401", "201408")
>
>which(TermList==sc$TERM)
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] 'which' statement for recode?

2015-01-22 Thread John Fox
Dear Charles,

When you put TERM in a data frame, by default it was converted to a factor,
which is already stored as integers. Thus, if I understand correctly what
you want, the following will work:

> sc$TERM
[1] 200208 200701 201201
Levels: 200208 200701 201201

> unclass(sc$TERM)
[1] 1 2 3
attr(,"levels")
[1] "200208" "200701" "201201"

> class(unclass(sc$TERM))
[1] "integer"

Note that the original class designations are presented in the "levels"
attribute.

This assumes that all of the class designations that you want to use appear
in sc$TERM. You already received some suggestions for the way that you
originally posed the problem (where there were classes in TermList not
appearing in sc$TERM).

I hope this helps,
 John

---
John Fox, Professor
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/



> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Charles
> Stangor
> Sent: January-22-15 11:01 AM
> To: r-help@r-project.org
> Subject: [R] 'which' statement for recode?
> 
> Hi,
> 
> Is there a way to easily convert the list of course terms into sequential
> integers in the dataframe (see code below)?
> 
> eg. "199801" = 1; "199808"=2
> 
> I know I can use recode but shouldn't "which" work?
> 
> Thanks in advance!
> 
> 
> sc = data.frame(c("200208", "200701", "201201"))
> names(sc) = c("TERM")
> 
> TermList = c(NA, "199801", "199808", "199901", "199908", "21",
"28",
> "200101", "200108",
>  "200201", "200208", "200301", "200308", "200401", "200408",
"200501",
> "200508",
>  "200601", "200608", "200701", "200708", "200801", "200808",
"200901",
> "200908",
>  "201001", "201008", "201101", "201108", "201201", "201308",
"201401",
> "201408")
> 
> which(TermList==sc$TERM)
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.


---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com

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


Re: [R] 'which' statement for recode?

2015-01-22 Thread William Dunlap
You did not show what answer you expected, but does the following do what
you want?

  > match(sc$TERM, TermList)
  [1] 11 20 30

Making a factor whose levels are TermList may also be useful.  (The
exclude=NULL
is to factor doesn't drop NA from the levels).
  > sc$fTERM <- factor(sc$fTERM, levels=TermList, exclude=NULL)
  > str(sc)
  'data.frame':   3 obs. of  2 variables:
   $ TERM : Factor w/ 3 levels "200208","200701",..: 1 2 3
   $ fTERM: Factor w/ 33 levels NA,"199801","199808",..: 11 20 30



Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Thu, Jan 22, 2015 at 8:01 AM, Charles Stangor  wrote:

> Hi,
>
> Is there a way to easily convert the list of course terms into sequential
> integers in the dataframe (see code below)?
>
> eg. "199801" = 1; "199808"=2
>
> I know I can use recode but shouldn't "which" work?
>
> Thanks in advance!
>
>
> sc = data.frame(c("200208", "200701", "201201"))
> names(sc) = c("TERM")
>
> TermList = c(NA, "199801", "199808", "199901", "199908", "21",
> "28", "200101", "200108",
>  "200201", "200208", "200301", "200308", "200401", "200408",
> "200501", "200508",
>  "200601", "200608", "200701", "200708", "200801", "200808",
> "200901", "200908",
>  "201001", "201008", "201101", "201108", "201201", "201308",
> "201401", "201408")
>
> which(TermList==sc$TERM)
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] 'which' statement for recode?

2015-01-22 Thread Sarah Goslee
I'm not quite sure, but I think you might want:
> which(TermList %in% sc$TERM)
[1] 11 20 30

instead. Using == ends up with automatic recycling and other things you
probably weren't expecting.

Sarah

On Thu, Jan 22, 2015 at 11:01 AM, Charles Stangor 
wrote:
> Hi,
>
> Is there a way to easily convert the list of course terms into sequential
> integers in the dataframe (see code below)?
>
> eg. "199801" = 1; "199808"=2
>
> I know I can use recode but shouldn't "which" work?
>
> Thanks in advance!
>
>
> sc = data.frame(c("200208", "200701", "201201"))
> names(sc) = c("TERM")
>
> TermList = c(NA, "199801", "199808", "199901", "199908", "21",
> "28", "200101", "200108",
>  "200201", "200208", "200301", "200308", "200401", "200408",
> "200501", "200508",
>  "200601", "200608", "200701", "200708", "200801", "200808",
> "200901", "200908",
>  "201001", "201008", "201101", "201108", "201201", "201308",
> "201401", "201408")
>
> which(TermList==sc$TERM)
>


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

[[alternative HTML version deleted]]

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


[R] 'which' statement for recode?

2015-01-22 Thread Charles Stangor
Hi,

Is there a way to easily convert the list of course terms into sequential
integers in the dataframe (see code below)?

eg. "199801" = 1; "199808"=2

I know I can use recode but shouldn't "which" work?

Thanks in advance!


sc = data.frame(c("200208", "200701", "201201"))
names(sc) = c("TERM")

TermList = c(NA, "199801", "199808", "199901", "199908", "21",
"28", "200101", "200108",
 "200201", "200208", "200301", "200308", "200401", "200408",
"200501", "200508",
 "200601", "200608", "200701", "200708", "200801", "200808",
"200901", "200908",
 "201001", "201008", "201101", "201108", "201201", "201308",
"201401", "201408")

which(TermList==sc$TERM)

[[alternative HTML version deleted]]

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


Re: [R] Re-order levels of a categorical (factor) variable

2015-01-22 Thread Martin Maechler
> Bert Gunter 
> on Wed, 21 Jan 2015 18:52:12 -0800 writes:

> Bill/Ravi:
> I believe the problem is that the factor is automatically created when
> a data frame is created by read.table(). By default, the levels are
> lexicographically ordered. The following reproduces the problem and
> gives a solution.

>> library(lattice)

>> z <- data.frame(y = 1:9, x = rep(c("pre", "day2","day10")))
>> xyplot(y~x,data=z) ## x axis order is day 10, day2, pre

>> levels(z$x)
> [1] "day10" "day2"  "pre"

>> z$x <- factor(as.character(z$x),levels=c(levels(z$x)[3:1])) ## 
explicitly defines level order
>> xyplot(y~x,data=z) ##  desired plot

Indeed, thank you, Bert,
and using  levels(.) <- *   does *not* work... (as I first thought).

However, slightly shorter and easier and maybe even easier to remember than

 z$x <- factor(as.character(z$x), levels = c(levels(z$x)[3:1])) ## def. level 
order

is

 z$x <- factor(z$x, levels = levels(z$x)[3:1])   ## def. level order


Martin Maechler, ETH Zurich

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


Re: [R] cat() and \r et al. escape sequences - are there more?

2015-01-22 Thread Prof Brian Ripley

On 22/01/2015 14:22, Rainer M Krug wrote:



Envoyé de mon iPhone


Le 22 janv. 2015 à 15:11, Prof Brian Ripley  a écrit :

See ?Quotes.


Perfect - thanks.




On 22/01/2015 13:32, Rainer M Krug wrote:
Hi

I just discovered \r and \t

--8<---cut here---start->8---

cat(LETTERS, "\n")

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z



--8<---cut here---end--->8---

--8<---cut here---start->8---

cat(LETTERS, "\r", letters, "\n")

  a b c d e f g h i j k l m n o p q r s t u v w x y z


--8<---cut here---end--->8---


and
\a as alert
\b as backspace
\f as form-feed
\n as newline
\r as carriage-return
\t as tab
\v as vertical-tab

are there more of these escape sequences?

Especially, Can I position the cursor at a specific column? I would like
to do this to show progress in an analysis done with mclapply() on
multiple cores and, preferably, display each core (7) at a fixed
position in a line.


How these are interpreted is a matter for the terminal/console. Some terminals 
have escape sequences to do that, but most consoles do not.


You don't know by any chance if terminal on Yosemite has these?


Depends what terminal you set it to emulate, but likely yes.  See e.g. 
http://www.termsys.demon.co.uk/vtansi.htm .




Thanks,

Rainer





Thanks,

Rainer



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




--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK

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

Re: [R] cat() and \r et al. escape sequences - are there more?

2015-01-22 Thread Prof Brian Ripley

See ?Quotes.

On 22/01/2015 13:32, Rainer M Krug wrote:

Hi

I just discovered \r and \t

--8<---cut here---start->8---

cat(LETTERS, "\n")

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z



--8<---cut here---end--->8---

--8<---cut here---start->8---

cat(LETTERS, "\r", letters, "\n")

  a b c d e f g h i j k l m n o p q r s t u v w x y z


--8<---cut here---end--->8---


and
\a as alert
\b as backspace
\f as form-feed
\n as newline
\r as carriage-return
\t as tab
\v as vertical-tab

are there more of these escape sequences?

Especially, Can I position the cursor at a specific column? I would like
to do this to show progress in an analysis done with mclapply() on
multiple cores and, preferably, display each core (7) at a fixed
position in a line.


How these are interpreted is a matter for the terminal/console. Some 
terminals have escape sequences to do that, but most consoles do not.




Thanks,

Rainer



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




--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK

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


[R] cat() and \r et al. escape sequences - are there more?

2015-01-22 Thread Rainer M Krug
Hi

I just discovered \r and \t

--8<---cut here---start->8---
> cat(LETTERS, "\n")
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
>
--8<---cut here---end--->8---

--8<---cut here---start->8---
> cat(LETTERS, "\r", letters, "\n")
 a b c d e f g h i j k l m n o p q r s t u v w x y z
>
>--8<---cut here---end--->8---

and
\a as alert
\b as backspace
\f as form-feed
\n as newline
\r as carriage-return
\t as tab
\v as vertical-tab

are there more of these escape sequences?

Especially, Can I position the cursor at a specific column? I would like
to do this to show progress in an analysis done with mclapply() on
multiple cores and, preferably, display each core (7) at a fixed
position in a line.

Thanks,

Rainer

-- 
Rainer M. Krug
email: Rainerkrugsde
PGP: 0x0F52F982


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

Re: [R] Neural Network

2015-01-22 Thread Charles Determan Jr
Javad,

First, please make sure to hit 'reply all' so that these messages go to the
R help list so others (many far more skilled than I) may possibly chime in.

The problem here is that you appear to have no dependent variable (i.e. no
eutrophication variable).  Without it, there is no way to a typical
'supervised' analysis.  Given that this is likely a regression type problem
(I assume eutrophication would be continous) I'm not quite sure
'supervised' is the correct description but it furthers my point that you
need a dependent variable for any neuralnet algorithm I am aware of.  As
such, if you don't have a dependent variable then you will need to look at
unsupervised methods such as PCA.  Other users may have other suggestions.

Regards,
Charles

On Wed, Jan 21, 2015 at 11:36 PM, javad bayat  wrote:

> Dear Charles;
> Many thanks for your attention. what I want to know is: How can I predict
> the Eutrophication by these parameters in the future?
> These variables are the most important variables that control the Eutro.
> in lakes.
> Let me break it to two parts.
> 1) How can I predict these variables by NN?
> 2) Is it possible to predict the Eutro. by these variables?
>
>
> Many thanks for your help.
>  Regards,
>
>
>
>
>
>
>
> 
> On Wed, 1/21/15, Charles Determan Jr  wrote:
>
>  Subject: Re: [R] Neural Network
>  To: "javad bayat" 
>  Cc: "r-help@r-project.org" 
>  Date: Wednesday, January 21, 2015, 9:10 PM
>
>  Javad,
>  You
>  question is a little too broad to be answered
>  definitively.  Also, this is not a code writing service.
>  You should make a meaningful attempt and we are here to help
>  when you get stuck.
>  1.
>  If you want to know if you can do neural nets, the answer is
>  yes.  The three packages most commonly used (that I know
>  of) are 'neuralnet', 'nnet' and
>  'RSNNS'.  You should look in to these package
>  documentation for how to use them.  There are also many
>  examples online if you simply google them.
>  2. You question is unclear, are you
>  wanting to predict all the variables (e.g. phosphorus, Total
>  N, etc.) or do you have some metric for eutrophication?
>  What exactly is the model supposed to predict?
>  3. If you want to know if a
>  neuralnet is appropriate, that is more of a statistical
>  question.  It depends more on the question you want to
>  answer.  Given your temporal data, you may want to look in
>  to mixed effects models (e.g nlme, lme4) as another
>  potential approach.
>  Regards,
>  On Tue, Jan 20, 2015 at
>  11:35 PM, javad bayat via R-help 
>  wrote:
>  Dear
>  all;
>
>  I am the new user of R. I want to simulation or prediction
>  the Eutrophication of a lake. I have weekly data(almost for
>  two years) for Total phosphorus, Total N, pH, Chlorophyll a,
>  Alkalinity, Silica.
>
>  Can I predict the Eutrophication by Neural Network in R?
>
>  How can I simulation the Eutrophication by these
>  parameter?
>
>  please help me to write the codes.
>
>  many thanks.
>
>
>
>  __
>
>  R-help@r-project.org
>  mailing list -- To UNSUBSCRIBE and more, see
>
>  https://stat.ethz.ch/mailman/listinfo/r-help
>
>  PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
>
>  and provide commented, minimal, self-contained, reproducible
>  code.
>
>
>
>
>  --
>  Dr. Charles Determan, PhD
>  Integrated Biosciences
>
>
>


-- 
Dr. Charles Determan, PhD
Integrated Biosciences

[[alternative HTML version deleted]]

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


Re: [R] need help with excel data

2015-01-22 Thread William Dunlap
The following is one way to parse your file using R (using R-3.1.2 on
Windows
in a US English locale).  I downloaded it from Google Docs in tab-separated
format.
I could not get read.table() to do the job, but I don't completely
understand
the encoding/fileEncoding business there.

> file <- "exampX.xlsx - examp.tsv" # the name Google Docs suggested
> lines <- readLines(file, encoding="UTF-8")
Warning message:
In readLines(file, encoding = "UTF-8") :
  incomplete final line found on 'exampX.xlsx - examp.tsv'
> fields <- strsplit(lines, "\t")
> txt <- vapply(fields, function(x)x[2], "") # 2nd field of each line
> nmbrs <- regmatches(txt, gregexpr("[[:digit:]]+(\\*[[:digit:]]+)*", txt))
> lines[16:20]
[1] "1.97\tл.а. 11 35*46 27*46" "1.61\tсамбо 9 31*36 29*45"
[3] "1.17\tс.п. 4  37*29 39*30" "1.54\tушу 9 31*39 30*38"
[5] "1.73\tсамбо 6 32*39 29*39"
> nmbrs[16:20]
[[1]]
[1] "11""35*46" "27*46"

[[2]]
[1] "9" "31*36" "29*45"

[[3]]
[1] "4" "37*29" "39*30"

[[4]]
[1] "9" "31*39" "30*38"

[[5]]
[1] "6" "32*39" "29*39"

If you want to split those "x*y" into "x" and "y" you can use
the pattern "[[:digit:]]+" instead of the one I used.


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Wed, Jan 21, 2015 at 12:31 PM, Dr Polanski 
wrote:

> Hi all!
>
> Sorry to bother you, I am trying to learn some R via coursera courses and
> other internet sources yet haven’t managed to go far
>
> And now I need to do some, I hope, not too difficult things, which I think
> R can do, yet have no idea how to make it do so
>
> I have a big set of data (empirical) which was obtained by my colleagues
> and store at not convenient  way - all of the data in two cells of an excel
> table
> an example of the data is in the attached file (the link)
>
>
> https://drive.google.com/file/d/0B64YMbf_hh5BS2tzVE9WVmV3bFU/view?usp=sharing
>
> so the first column has a number and the second has a whole vector (I
> guess it is) which looks like
> «some words in Cyrillic(the length varies)» and then the set of numbers
> «12*23 34*45» (another problem that some times it is «12*23, 34*56»
>
> And the number of raws is about 3000 so it is impossible to do manually
>
> what I need to have at the end is to have it separately in different excel
> cells
> - what is written in words - |  12  | 23 | 34 | 45 |
>
> Do you think it is possible to do so using R (or something else?)
>
> Thank you very much in advance and sorry for asking for help and so stupid
> question, the problem is - I am trying and yet haven’t even managed to
> install openSUSE onto my laptop - only Ubuntu! :)
>
>
> Thank you very much!
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

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