Re: [R] y axis in a stacked bar plot

2015-03-26 Thread Jim Lemon
Hi Michy,
I agree with Jeff that you probably don't want a stacked bar chart. What
you describe appears to be a display of relative positions of genetic
elements in different strains of mice and the place to ask is most likely
the Bioconductor mailing list.

Jim


On Thu, Mar 26, 2015 at 3:51 PM, Jeff Newmiller jdnew...@dcn.davis.ca.us
wrote:

 I don't understand what you expect. Stacked bar charts add the values
 together. Perhaps that is not really how you want to represent these data?
 ---
 Jeff NewmillerThe .   .  Go Live...
 DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  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 March 25, 2015 9:29:40 PM PDT, Michelle Simon m.si...@har.mrc.ac.uk
 wrote:
 Hello,
 Below is some simple R code I have used to create a stacked bar chart.
 However the y-axis tick marks do not reflect the data.  The minimum and
 maximum data values I have are 3073351 and 25329814 respectively but
 the graph has data from 0 and the maximum is different  The data file
 is too large so there is a small sample below.  What am I doing wrong?
 Please help as I cannot be sure the data is represented correctly in
 the graph (attached).
 
 fn -~/Documents/chr7Data.txt
 x-read.table(fn,check.names = TRUE, header=T)
 d - data.frame(x)
 theChart-ggplot(d, aes(x=factor(Congenic),y=Position, fill=Strain,
 theme_rect=white)) + geom_bar(stat='identity', position = stack ) +
 scale_fill_manual(values=c(deepskyblue1, red2, green3,
 steelblue4, lightblue4, gray70)) + ylab(c(Position))+
 ggtitle(Strain specific SNP distribution in the congenics) +
 
 #coord_cartesian(ylim = c(min(d$Position), max(d$Position))) +
 #scale_y_continuous(breaks=seq(0, 2, 5000)) +
 theme_bw()+
 theme(plot.title = element_text(size=23),
axis.text.x = element_text(size=13, angle=90),#20 before
 axis.text.y = element_text(size=13),
 panel.border = element_rect(colour=BLACK,size=0.5),
 axis.title.x = element_text(size=12),
 axis.title.y = element_text(size=12,angle = 90),
 panel.background = element_rect(fill=transparent),
 legend.text=element_text(size=13),
 legend.title=element_text(size=12)
   #plot.background = element_rect(fill = transparent,colour = NA)
 )
 png(~/Documents/sendToRGrp.png,950,750)
 print(theChart)
 dev.off()
 
 ——— Sample Data —
 Congenic Position Strain
 4201 3073351 hets
 4203 3073351 reference
 4215 3073351 reference
 4333 3073351 cba
 4335 3073351 cba
 4484 3073351 cba
 4485 3073351 reference
 4496 3073351 hets
 4497 3073351 reference
 //lots of data//
 4201 25329814 reference
 4203 25329814 reference
 4215 25329814 cba
 4333 25329814 balbc
 4335 25329814 balbc
 4484 25329814 reference
 4485 25329814 reference
 4496 25329814 balbc
 4497 25329814 hets
 
 Many thanks,
 Michy
 
 
 This email may have a PROTECTIVE MARKING, for an explanation please
 see:
 
 http://www.mrc.ac.uk/About/Informationandstandards/Documentmarking/index.htm
 
 
 
 
 __
 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.

[[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] Having trouble with gdata read in

2015-03-26 Thread jim holtman
My suggestion is to use XLConnect to read the file:


 x -
C:\\Users\\jh52822\\AppData\\Local\\Temp\\Rtmp6nVgFC\\file385c632aba3.xls
 require(XLConnect)
Loading required package: XLConnect
Loading required package: XLConnectJars
XLConnect 0.2-10 by Mirai Solutions GmbH [aut],
  Martin Studer [cre],
  The Apache Software Foundation [ctb, cph] (Apache POI, Apache Commons
Codec),
  Stephen Colebourne [ctb, cph] (Joda-Time Java library)
http://www.mirai-solutions.com ,
http://miraisolutions.wordpress.com
 input - f.readXLSheet(x, 1)

 str(input)
'data.frame':   2266 obs. of  51 variables:
 $ EIA  : num  34 59 87 97 108 118 123 149
150 157 ...
 $ Entity.Name  : chr  City of Abbeville City of
Abbeville City of Ada Adams Electric Cooperative ...
 $ State: chr  SC LA MN IL ...
 $ NERC.Region  : chr  SERC SPP MRO SERC ...
 $ Filing.Order : num  12 11 1237 392 252 ...
 $ Q5.MultRegion: chr  ...
 $ Q6.OwnMeters.: chr  Yes Yes Yes Yes ...
 $ Q7.ResMeters : num  3051 4253 857 8154 33670 ...
 $ Q7.ComMeters : num  531 972 132 155 1719 ...
 $ Q7.IntMeters : num  0 19 32 NA 626 NA 29 0 2 NA
...
 $ Q7.TransMeters   : num  0 NA NA NA NA NA NA 0 0 NA
...
 $ Q7.OtherMeters   : num  0 NA NA 57 NA NA NA 0 0 NA
...
 $ Q7...total.meters: num  3582 5244 1021 8366 36015 ...
 $ Q8.15Min.ResAMI  : num  0 NA NA NA NA NA NA NA NA NA
...
 $ Q8.15Min.ComAMI  : num  0 NA NA 155 NA NA NA NA NA
NA ...
 $ Q8.15Min.IndAMI  : num  0 NA NA NA NA NA NA NA NA NA
...
 $ Q8.15Min.TransAMI: num  0 NA NA NA NA NA NA NA NA NA
...
 $ Q8.15Min.OtherAMI: num  0 NA NA NA NA NA NA NA NA NA
...
 $ Q8.15Min.TotalAMI: num  0 0 0 155 0 0 0 0 0 0 ...
 $ Q8.Hourly.ResAMI : num  0 NA NA NA 16100 NA NA NA NA
NA ...
 $ Q8.Hourly.ComAMI : num  0 NA NA NA 1600 NA NA NA NA
NA ...




Jim Holtman
Data Munger Guru

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

On Wed, Mar 25, 2015 at 5:01 PM, Benjamin Baker bba...@reed.edu wrote:

 Trying to read and clean up the FERC data on Advanced Metering
 infrastructure. Of course it is in XLS for the first two survey years and
 then converts to XLSX for the final two. Bad enough that it is all in
 excel, they had to change the survey design and data format as well. Still,
 I’m sorting through it. However, when I try and read in the 2008 data, I’m
 getting this error:
 ###
 Wide character in print at
 /Library/Frameworks/R.framework/Versions/3.1/Resources/library/gdata/perl/
 xls2csv.pl line 270.
 Warning message:
 In scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  :
   EOF within quoted string
 ###



 Here is the code I’m running to get the data:
 ###
 install.packages(gdata)
 library(gdata)
 fileUrl - 
 http://www.ferc.gov/industries/electric/indus-act/demand-response/2008/survey/ami_survey_responses.xls
 
 download.file(fileUrl, destfile=./ami.data/ami-data2008.xls)
 list.files(ami.data)
 dateDown.2008 - date()
 ami.data2008 - read.xls(./ami.data/ami-data2008.xls, sheet=1,
 header=TRUE)
 ###


 Reviewed the data in the XLS file, and both “” and # are present within
 it. Don’t know how to get the read.xls to ignore them so I can read all the
 data into my data frame. Tried :
 ###
 ami.data2008 - read.xls(./ami.data/ami-data2008.xls, sheet=1, quote=,
 header=TRUE)
 ###


 And it spits out “More columns than column names” output.


 Been searching this, and I can find some “solutions” for read.table, but
 nothing specific to read.xls


 Many thanks,


 Benjamin Baker



 —
 Sent from Mailbox
 [[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] Converting charter string to vector of numbers (Turgidson)

2015-03-26 Thread Manel Amado Martí
Hi,

See that strsplit() retorns a list object. Then, to transform a character 
vector (that is an element into the list), to a numèric vector, you should 
access directly to that element to aply as.numeric. The code is:

aux-0.5 1 2 3 4
vectnum-strsplit(aux, )
class(vectnum)  ## see that is returning a list
numaux-as.numeric(vectnum[[1]])## get the nummerical vector form the 
vector object that stays into the vectnum list


Message: 20
Date: Wed, 25 Mar 2015 10:27:40 -0700 (PDT)
From: Turgidson e...@upenn.edu
To: r-help@r-project.org
Subject: [R] Converting charter string to vector of numbers
Message-ID: 1427304460123-4705097.p...@n4.nabble.com
Content-Type: text/plain; charset=us-ascii

Apologies for bringing up an old topic, but I am not finding working answers. 
I am also an R newbie, so I'm still on the steep part of the learning curve.

I have a character string :  0.5 1 2 3 4

I need to convert it to a vector of numbers.  I get as far as strsplit(),
which gives me 

 0.5 1 2 3 4

this is still treated by R as a single item.  I need to get it to look like
this:  0.5, 1, 2, 3, 4

so that I can use as.numeric() and make it into a vector of numbers...   I
have been going mad because for text operations, commas and quotes are
loaded with meaning, and I keep going around in circles.

Any help would be appreciated

Thanks

Paul





--
View this message in context: 
http://r.789695.n4.nabble.com/Converting-charter-string-to-vector-of-numbers-tp4705097.html
Sent from the R help mailing list archive at Nabble.com.


Manel Amado i Martí
Cap d'Assessoria de Comerç Interior
am...@cambrasabadell.org
Tel. 93 745 12 63 . Fax 93 745 12 64  
Av. Francesc Macià, 35 . 08206 Sabadell
Apt. corr. 119 . www.cambrasabadell.org  

__
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] Why can't I access this type?

2015-03-26 Thread yoursurrogate...@gmail.com




 On Mar 25, 2015, at 10:14, Henric Winell nilsson.hen...@gmail.com wrote:
 
 On 2015-03-25 09:40, Patrick Connolly wrote:
 
 On Sun, 22-Mar-2015 at 08:06AM -0800, John Kane wrote:
 
 | Well, first off, you have no variable called Name.  You have lost
 | the state names as they are rownames in the matrix state.x77 and
 | not a variable.
 |
 | Try this. It's ugly and I have no idea why I had to do a cbind()
 
 You don't have to use cbind
 
 | but it seems to work. Personally I find subset easier to read than
 | the indexing approach.
 
 | state  -  rownames(state.x77)
 | all.states - as.data.frame(state.x77)
 | all.states  -  cbind(state, all.states) ### ?
 
 You don't have to use cbind()
 
 all.states  - within(as.data.frame(state.x77), state - rownames(state.x77))
 
 but I think cbind is simpler to read.
 
 |
 | coldstates  -   subset(all.states, all.states$Frost  50,
 | select = c(state,Frost) )
 
 I find the indexing approach
 
 coldstates - all.states[all.states$Frost  150, c(state,Frost)]
 
 to be the most direct and obvious solution.
 
 Tidier, even more so than subset():
 
 require(dplyr)
 coldstates - all.states %% filter(Frost  150) %% select(state, Frost)
 
 Or, easier to see what's happening:
 
 coldstates - all.states %%
   filter(Frost  150) %%
   select(state, Frost)
 
 Well...  Opinions may perhaps differ, but apart from '%%' being butt-ugly 
 it's also fairly slow:
 
  library(microbenchmark)
  microbenchmark(
 + subset(all.states, all.states$Frost  150, select = c(state,Frost)),
 + all.states[all.states$Frost  150, c(state,Frost)],
 + all.states %% filter(Frost  150) %% select(state, Frost),
 + times = 1000L
 + )
 Unit: microseconds
   expr
 subset(all.states, all.states$Frost  150, select = c(state, Frost))
   all.states[all.states$Frost  150, c(state, Frost)]
   all.states %% filter(Frost  150) %% select(state, Frost)
  min   lq  meanmedianuq  max neval cld
  139.112  148.673  163.3960  159.1760  170.7895 1763.200  1000  b
  104.039  111.973  127.2138  120.4395  128.6640 1381.809  1000 a
 1010.076 1033.519 1133.1469 1107.8480 1175.1800 2932.206  1000   c
 
 Of course, this doesn't matter for interactive one-off use.  But lately I've 
 seen examples of the '%%' operator creeping into functions in packages.  
 However, it would be nice to see a fast pipe operator as part of base R.
 
 
 Henric Winell
 
 
 
 
 
 |
 |
 | John Kane
 | Kingston ON Canada
 |
 |
 |  -Original Message-
 |  From: yoursurrogate...@gmail.com
 |  Sent: Sun, 22 Mar 2015 10:39:03 -0400
 |  To: r-help@r-project.org
 |  Subject: [R] Why can't I access this type?
 | 
 |  Hi, I'm just learning my way around R.  I got a bunch of states and 
 would
 |  like to access to get all of the ones where it's cold.  But when I do 
 the
 |  following, I will get the following error:
 | 
 |  all.states - as.data.frame(state.x77)
 |  cold.states - all.states[all.states$Frost  150, c(Name, Frost)]
 |  Error in `[.data.frame`(all.states, all.states$Frost  150, c(Name,  :
 |undefined columns selected
 | 
 |  I don't get it.  When I look at all.states, this is what I see:
 | 
 |  str(all.states)
 |  'data.frame':   50 obs. of  8 variables:
 |   $ Population: num  3615 365 2212 2110 21198 ...
 |   $ Income: num  3624 6315 4530 3378 5114 ...
 |   $ Illiteracy: num  2.1 1.5 1.8 1.9 1.1 0.7 1.1 0.9 1.3 2 ...
 |   $ Life Exp  : num  69 69.3 70.5 70.7 71.7 ...
 |   $ Murder: num  15.1 11.3 7.8 10.1 10.3 6.8 3.1 6.2 10.7 13.9 ...
 |   $ HS Grad   : num  41.3 66.7 58.1 39.9 62.6 63.9 56 54.6 52.6 40.6 ...
 |   $ Frost : num  20 152 15 65 20 166 139 103 11 60 ...
 |   $ Area  : num  50708 566432 113417 51945 156361 ...
 | 
 |  What am I messing up?
 | 
 | [[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.
 |
 | 
 | FREE ONLINE PHOTOSHARING - Share your photos online with your friends and 
 family!
 | Visit http://www.inbox.com/photosharing to find out more!
 |
 | __
 | 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.


I agree with you on the indexing approach.  But even after using within, I 
still get the same error.
 

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE 

[R] matrix manipulation question

2015-03-26 Thread Jatin Kala

Hi,
I've got a rather large matrix of about 800 rows and 60 columns.
Each column is a time-series 800 long.

Out of these 60 time series, some have missing values (NA).
I want to strip out all columns that have one or more NA values, i.e., 
only want full time series.


This should do the trick:
data_no_NA - data[,!apply(is.na(data), 2, any)]

I now use data_no_NA as input to a function, which returns output as a 
matrix of the same size as data_no_NA


The trick is that i now need to put these columns back into a new 800 by 
60 empty matrix, at their original locations.

Any suggestions on how to do that? hopefully without having to use loops.
I'm using R/3.0.3

Cheers,
Jatin.

__
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] matrix manipulation question

2015-03-26 Thread Richard M. Heiberger
just reverse what you did before.

newdata - data
newdata[] - NA
newdata[,!apply(is.na(data), 2, any)] - myfunction(data_no_NA)

On Fri, Mar 27, 2015 at 1:13 AM, Jatin Kala jatin.kala...@gmail.com wrote:
 Hi,
 I've got a rather large matrix of about 800 rows and 60 columns.
 Each column is a time-series 800 long.

 Out of these 60 time series, some have missing values (NA).
 I want to strip out all columns that have one or more NA values, i.e., only
 want full time series.

 This should do the trick:
 data_no_NA - data[,!apply(is.na(data), 2, any)]

 I now use data_no_NA as input to a function, which returns output as a
 matrix of the same size as data_no_NA

 The trick is that i now need to put these columns back into a new 800 by
 60 empty matrix, at their original locations.
 Any suggestions on how to do that? hopefully without having to use loops.
 I'm using R/3.0.3

 Cheers,
 Jatin.

 __
 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] Vennerable Plots for Publications

2015-03-26 Thread Dario Strbenac
Does anyone make Venn diagrams for publication using Vennerable ? I found that 
the font size is too big when the plot is created at 300 DPI, and there's no 
option to change it, even when the point size argument to the device is changed.

aVenn - Venn(Sets = list(A = 1:5, B = 3:6))
png(forPublication.png, units = in, h = 2.55, w = 2.4, res = 300) # 
Changing pointsize to a smaller number has no effect on size of the text.
plot(aVenn)
dev.off()

--
Dario Strbenac
PhD Student
University of Sydney
Camperdown NSW 2050
Australia

__
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-es] Acceso gratuito durante un mes a la plataforma DataCamp...

2015-03-26 Thread Isidro Hidalgo
Muy interesante. Había visto la oferta de 9$, pero NO GRATIS...
Como siempre, gracias.

Isidro Hidalgo Arellano
Observatorio Regional de Empleo
Consejería de Empleo y Economía
http://www.jccm.es

 -Mensaje original-
 De: R-help-es [mailto:r-help-es-boun...@r-project.org] En nombre de
 Carlos Ortega
 Enviado el: jueves, 26 de marzo de 2015 18:36
 Para: Lista R
 Asunto: [R-es] Acceso gratuito durante un mes a la plataforma
 DataCamp...

 Buenas a todos,

 La gente de DataCamp se han puesto en contacto con el grupo de Madrid
 para ofrecernos una oferta para usar gratuitamente su plataforma con
 diferentes cursos de R durante un mes.

 Les hemos preguntado si sería posible compartir este ofrecimiento con
 toda la lista de R-Help-es y no ven mayor problema, les ha parecido muy
 bien la posibilidad.

 El link de acceso es el siguiente:

 https://www.datacamp.com/enroll-meetup

 ?Cuidado que los cursos son en inglés y para darse de alta, aun siendo
 gratuitio este primer mes, hay que asociar una tarjeta de crédito o una
 cuenta Paypal. Pasado este mes el estar dado de alta en la plataforma
 cuesta ?25$/mes.
 ?Durante este mes gratuito, uno se puede a puntar a cualquier curso
 (necesitan de una dedicación de de 5-8 horas aprox.). Los cursos van
 desde Introducción a R? hasta el uso de la solución RevoScale para
 BigData de Revolution Analytics.

 Saludos,
 Carlos Ortega
 www.qualityexcellence.es

   [[alternative HTML version deleted]]

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

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


[R-es] Acceso gratuito durante un mes a la plataforma DataCamp...

2015-03-26 Thread Carlos Ortega
Buenas a todos,

La gente de DataCamp se han puesto en contacto con el grupo de Madrid para
ofrecernos una oferta para usar gratuitamente su plataforma con diferentes
cursos de R durante un mes.

Les hemos preguntado si sería posible compartir este ofrecimiento con toda
la lista de R-Help-es y no ven mayor problema, les ha parecido muy bien la
posibilidad.

El link de acceso es el siguiente:

https://www.datacamp.com/enroll-meetup

​Cuidado que los cursos son en inglés y para darse de alta, aun siendo
gratuitio este primer mes, hay que asociar una tarjeta de crédito o una
cuenta Paypal. Pasado este mes el estar dado de alta en la plataforma
cuesta ​25$/mes.​

​Durante este mes gratuito, uno se puede a puntar a cualquier curso
(necesitan de una dedicación de de 5-8 horas aprox.). Los cursos van desde
Introducción a R​ hasta el uso de la solución RevoScale para BigData de
Revolution Analytics.

Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

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


Re: [R] list output

2015-03-26 Thread MacQueen, Don
I don't think you are correctly keeping track of the structure of your
objects.
(and my email software may mess up the indentation, but I can't prevent it)


I have not tested, but try replacing

   out[i]$phi_0 - x$phi_0
   out[i]$maxlike - x$maxlike
   out[i]$bigp - x$bigp

with

   out[[i]] - list(phi_0=x$phi_0,
maxlike=x$maxlike,
bigp=x$bigp
   )

(double bracket, as Peter suggested)

Then also replace
  aic[i] - -2*out[i]$maxlike + (2*(i+1))
with
 aic[i] - -2*out[[i]]$maxlike + (2*(i+1))

To begin understanding this, see this little sequence:
 foo - vector('list',3)
 foo[[2]] - list(a=1, b=2)
 foo[2]$a
NULL
 foo[[2]]$a
[1] 1




Also, which() does not return a list object as you are using it, so there
is no reason to unlist() it. Might as well use
  which.min(minaic)
while you're at it.

So replace your last three lines with
  out[which.min(minaic)]
as the last line of your function, before the closing }

No need to use return()

-Don


-- 
Don MacQueen

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





On 3/26/15, 11:22 AM, Erin Hodgess erinm.hodg...@gmail.com wrote:

Hello!

I am having some trouble with some list output.

Here is my code:
geobunch - function(y) {

  out - vector(list,3)
  aic - numeric(length=3)
  print(str(out))
  for(i in 1:3) {

  x - geomin(y,i)
  print(i)
  print(x)
  print(str(x))
  out[i]$phi_0 - x$phi_0
  out[i]$maxlike - x$maxlike
  out[i]$bigp - x$bigp
  aic[i] - -2*out[i]$maxlike + (2*(i+1))
}
  minaic - which(aic==min(aic))
  minout - out[unlist(minaic)]
  return(minout)
}

And here is the output:
 geobunch(ez2a)
List of 3
 $ : NULL
 $ : NULL
 $ : NULL
NULL
[1] 1
$phi_0
[1] 2.856428

$bigp
[1] 0.1584016

$maxlike
[1] -473.0203

List of 3
 $ phi_0  : num 2.86
 $ bigp   : num 0.158
 $ maxlike: num -473
NULL
Error in aic[i] - -2 * out[i]$maxlike + (2 * (i + 1)) :
  replacement has length zero
In addition: Warning messages:
1: In out[i]$phi_0 - x$phi_0 :
  number of items to replace is not a multiple of replacement length
2: In out[i]$maxlike - x$maxlike :
  number of items to replace is not a multiple of replacement length
3: In out[i]$bigp - x$bigp :
  number of items to replace is not a multiple of replacement length


I know that the problem is in how I am setting up the out variable, but
I'm not sure how to correct it.  Also, the bigp variable can take on
different lengths.

This is on R version 3.1.3, on Ubuntu 14.04.

Thank you so much for any help.

Sincerely,
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-es] Conectividad con Excel

2015-03-26 Thread Isidro Hidalgo
Como te indica Miguel Ángel, no necesitas ODBC para conectar con Excel. Yo
también uso el mismo sistema: XLConnect. Tiene una buena vignette:
http://cran.r-project.org/web/packages/XLConnect/vignettes/XLConnect.pdf

Si quieres profundizar en el tema, Hadley Wickham hace unos días estaba
haciendo propaganda por Twitter de haber mejorado mucho un paquete que
también conecta con Excel, pero yo no lo he usado. Es el paquete readxl,
pero tengo pendiente probarlo. No está en cran, pero lo tienes en GitHub:
https://github.com/hadley/readxl

Si no quieres complicarte la vida instalando devtools para instalar paquetes
desde GitHub, usa XLConnect, que va bien.
Suerte.

Isidro Hidalgo Arellano
Observatorio Regional de Empleo
Consejería de Empleo y Economía
http://www.jccm.es


 -Mensaje original-
 De: R-help-es [mailto:r-help-es-boun...@r-project.org] En nombre de
 miguel.angel.rodriguez.mui...@sergas.es
 Enviado el: jueves, 26 de marzo de 2015 15:26
 Para: r-help-es@r-project.org
 Asunto: Re: [R-es] Conectividad con Excel

 Hola Our Utopy.

 Te puedo comentar cómo hago yo con XLConnect para acceder a un fichero
 de Excel (por si es ésto lo que pretendes) Veamos..

   require(XLConnect)
   file.import=/trayecto_del_fichero_Excel/fichero.xlsx
   file.load=loadWorkbook(file.import, create=FALSE)  
 misdatos=readWorksheet(file.load, sheet=1)

 Es esto lo que buscas?

 Un Saludo,
 Miguel Rodríguez
 Consellería de Sanidade
 Xunta de Galicia




 El 26/03/2015 a las 15:04, Our Utopy escribió:
  Hola amigos, buenos días
 
  Esto sigue avanzando. Estoy ahora tratando de establecer la
  conectividad de R con Excel y he seguido dos viídeos en YouTube de
 una
  profesora llamada Bebilda que se explica muy bien.
 
  Con ambos tengo el mismo problema así que planteo uno de ellos, éste
 es:
https://youtu.be/_pSJQO_9I4k?list=PL7DA3FDA21A1A6310
 
  Pero os lo explico brevemente:
 
  Cargo el paquete RODBC   install.packages(RODBC) Instalo la
  librería   library(RODBC)
 
  Todo bien hasta aqui...
 
  Se supone, que en esa librería hay unas funciones que me permiten
  conectar con Excel, esas funciones son:
 
  o-odncConnectExcel2007 o-odncConnectExcel
 
  DE tal manera que ahora podría abrir una canal
 
  canalexcel - odbcConnectExcel2007(lbw.xlsx)
  Pues esas funciones no están. R me da el error
 
  Error: no se pudo encontrar la función odbcConnectExcel2007
 
  lo mismo con la otra función
 
  canalexcel - odbcConnectExcel(lbw.xlsx)
  Y lo curioso es que también me pasa algo similar con la otra
  posibilidad que es el paquete XLConnect
 
  Y es que, además, si miro la documentación de este paquete RODBC no
  figuran esas funciones.
 
  ¿ ?
 
  ¿Me podéis nuevamente ayudar?
 
  Un saludo
 
 
 
 
 
 
 

 

 Nota: A información contida nesta mensaxe e os seus posibles documentos
 adxuntos é privada e confidencial e está dirixida únicamente ó seu
 destinatario/a. Se vostede non é o/a destinatario/a orixinal desta
 mensaxe, por favor elimínea. A distribución ou copia desta mensaxe non
 está autorizada.

 Nota: La información contenida en este mensaje y sus posibles
 documentos adjuntos es privada y confidencial y está dirigida
 únicamente a su destinatario/a. Si usted no es el/la destinatario/a
 original de este mensaje, por favor elimínelo. La distribución o copia
 de este mensaje no está autorizada.

 See more languages: http://www.sergas.es/aviso_confidencialidad.htm

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

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


Re: [R] list output

2015-03-26 Thread peter dalgaard
Erin,

I think you'll have heard people requesting _reproducible_ examples several 
times by now... This one isn't.

Offhand, I'd suspect that the issue has to do with your single-bracket indexing 
of the list out. Try out[[i]].

-Peter

 On 26 Mar 2015, at 19:22 , Erin Hodgess erinm.hodg...@gmail.com wrote:
 
 Hello!
 
 I am having some trouble with some list output.
 
 Here is my code:
 geobunch - function(y) {
 
  out - vector(list,3)
  aic - numeric(length=3)
  print(str(out))
  for(i in 1:3) {
 
  x - geomin(y,i)
  print(i)
  print(x)
  print(str(x))
  out[i]$phi_0 - x$phi_0
  out[i]$maxlike - x$maxlike
  out[i]$bigp - x$bigp
  aic[i] - -2*out[i]$maxlike + (2*(i+1))
 }
  minaic - which(aic==min(aic))
  minout - out[unlist(minaic)]
  return(minout)
 }
 
 And here is the output:
 geobunch(ez2a)
 List of 3
 $ : NULL
 $ : NULL
 $ : NULL
 NULL
 [1] 1
 $phi_0
 [1] 2.856428
 
 $bigp
 [1] 0.1584016
 
 $maxlike
 [1] -473.0203
 
 List of 3
 $ phi_0  : num 2.86
 $ bigp   : num 0.158
 $ maxlike: num -473
 NULL
 Error in aic[i] - -2 * out[i]$maxlike + (2 * (i + 1)) :
  replacement has length zero
 In addition: Warning messages:
 1: In out[i]$phi_0 - x$phi_0 :
  number of items to replace is not a multiple of replacement length
 2: In out[i]$maxlike - x$maxlike :
  number of items to replace is not a multiple of replacement length
 3: In out[i]$bigp - x$bigp :
  number of items to replace is not a multiple of replacement length
 
 
 I know that the problem is in how I am setting up the out variable, but
 I'm not sure how to correct it.  Also, the bigp variable can take on
 different lengths.
 
 This is on R version 3.1.3, on Ubuntu 14.04.
 
 Thank you so much for any help.
 
 Sincerely,
 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.

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

__
R-help@r-project.org mailing list -- 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] list output

2015-03-26 Thread Erin Hodgess
Hello!

I am having some trouble with some list output.

Here is my code:
geobunch - function(y) {

  out - vector(list,3)
  aic - numeric(length=3)
  print(str(out))
  for(i in 1:3) {

  x - geomin(y,i)
  print(i)
  print(x)
  print(str(x))
  out[i]$phi_0 - x$phi_0
  out[i]$maxlike - x$maxlike
  out[i]$bigp - x$bigp
  aic[i] - -2*out[i]$maxlike + (2*(i+1))
}
  minaic - which(aic==min(aic))
  minout - out[unlist(minaic)]
  return(minout)
}

And here is the output:
 geobunch(ez2a)
List of 3
 $ : NULL
 $ : NULL
 $ : NULL
NULL
[1] 1
$phi_0
[1] 2.856428

$bigp
[1] 0.1584016

$maxlike
[1] -473.0203

List of 3
 $ phi_0  : num 2.86
 $ bigp   : num 0.158
 $ maxlike: num -473
NULL
Error in aic[i] - -2 * out[i]$maxlike + (2 * (i + 1)) :
  replacement has length zero
In addition: Warning messages:
1: In out[i]$phi_0 - x$phi_0 :
  number of items to replace is not a multiple of replacement length
2: In out[i]$maxlike - x$maxlike :
  number of items to replace is not a multiple of replacement length
3: In out[i]$bigp - x$bigp :
  number of items to replace is not a multiple of replacement length


I know that the problem is in how I am setting up the out variable, but
I'm not sure how to correct it.  Also, the bigp variable can take on
different lengths.

This is on R version 3.1.3, on Ubuntu 14.04.

Thank you so much for any help.

Sincerely,
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] list output

2015-03-26 Thread Erin Hodgess
It's the double bracket issue.

I replaced that, and all is well.

Thanks to Peter and Don.

Sincerely,
Erin


On Thu, Mar 26, 2015 at 3:21 PM, MacQueen, Don macque...@llnl.gov wrote:

 I don't think you are correctly keeping track of the structure of your
 objects.
 (and my email software may mess up the indentation, but I can't prevent it)


 I have not tested, but try replacing

out[i]$phi_0 - x$phi_0
out[i]$maxlike - x$maxlike
out[i]$bigp - x$bigp

 with

out[[i]] - list(phi_0=x$phi_0,
 maxlike=x$maxlike,
 bigp=x$bigp
)

 (double bracket, as Peter suggested)

 Then also replace
   aic[i] - -2*out[i]$maxlike + (2*(i+1))
 with
  aic[i] - -2*out[[i]]$maxlike + (2*(i+1))

 To begin understanding this, see this little sequence:
  foo - vector('list',3)
  foo[[2]] - list(a=1, b=2)
  foo[2]$a
 NULL
  foo[[2]]$a
 [1] 1




 Also, which() does not return a list object as you are using it, so there
 is no reason to unlist() it. Might as well use
   which.min(minaic)
 while you're at it.

 So replace your last three lines with
   out[which.min(minaic)]
 as the last line of your function, before the closing }

 No need to use return()

 -Don


 --
 Don MacQueen

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





 On 3/26/15, 11:22 AM, Erin Hodgess erinm.hodg...@gmail.com wrote:

 Hello!
 
 I am having some trouble with some list output.
 
 Here is my code:
 geobunch - function(y) {
 
   out - vector(list,3)
   aic - numeric(length=3)
   print(str(out))
   for(i in 1:3) {
 
   x - geomin(y,i)
   print(i)
   print(x)
   print(str(x))
   out[i]$phi_0 - x$phi_0
   out[i]$maxlike - x$maxlike
   out[i]$bigp - x$bigp
   aic[i] - -2*out[i]$maxlike + (2*(i+1))
 }
   minaic - which(aic==min(aic))
   minout - out[unlist(minaic)]
   return(minout)
 }
 
 And here is the output:
  geobunch(ez2a)
 List of 3
  $ : NULL
  $ : NULL
  $ : NULL
 NULL
 [1] 1
 $phi_0
 [1] 2.856428
 
 $bigp
 [1] 0.1584016
 
 $maxlike
 [1] -473.0203
 
 List of 3
  $ phi_0  : num 2.86
  $ bigp   : num 0.158
  $ maxlike: num -473
 NULL
 Error in aic[i] - -2 * out[i]$maxlike + (2 * (i + 1)) :
   replacement has length zero
 In addition: Warning messages:
 1: In out[i]$phi_0 - x$phi_0 :
   number of items to replace is not a multiple of replacement length
 2: In out[i]$maxlike - x$maxlike :
   number of items to replace is not a multiple of replacement length
 3: In out[i]$bigp - x$bigp :
   number of items to replace is not a multiple of replacement length
 
 
 I know that the problem is in how I am setting up the out variable, but
 I'm not sure how to correct it.  Also, the bigp variable can take on
 different lengths.
 
 This is on R version 3.1.3, on Ubuntu 14.04.
 
 Thank you so much for any help.
 
 Sincerely,
 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] basic help with as.Date()

2015-03-26 Thread Jeff Newmiller
That would be because they are not dates... they don't specify the day.

Either add a day of month to the character data before you convert it, or use 
the yearmon class from zoo.

Something like...

as.Date(paste(1,as.character(df$mydate),sep=-), format='%d-%b-%y')

And why in the world are you converting to factor and back? Perhaps because you 
are not preventing conversion to factor when you read in your actual data? Do 
you know about the stringsAsFactors argument to read.table and friends?
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  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 March 26, 2015 2:11:50 PM PDT, Simon Kiss sjk...@gmail.com wrote:
Hi there: normally I’m quite comfortable with as.Date(). But this data
set is causing problems.

The core of the data frame looks like the sample data frame below, but
my attempt to convert df$mydate to a date object returns only NA. Can
anyone provide a suggestion?

Thank you, Simon Kiss

#sample data frame
df-data.frame(mydate=factor(c('Jan-15', 'Feb-13', 'Mar-11',
'Jul-12')), other=rnorm(4, 3))
#Attempt to convert
as.Date(as.character(df$mydate), format='%b-%y')

__
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] new package: canceR

2015-03-26 Thread Karim Mezhoud
Dear All,
I am pleased to announce the release of new package named canceR
http://www.bioconductor.org/packages/devel/bioc/html/canceR.html. The
main goal of this package is to facilitate to NOT R user the access of
complex cancer genomics data hosted by the MSKCC and available through
cgdsr CRAN package. By simple clic, the user can combine Cases (Samples)
and Genetic profiles to get rapidly without programming skills all
available cancer genomics data (CNA, mRNA, Methylation, Mutation, miRNA,
RPPA) in exportable table.
Compared to cBioportal http://www.cbioportal.org/, canceR allows user to
focus on some Studies and get specific data as Amino Acid changes in
Mutation Data for selected gene list.

The second part of canceR focus on modeling. I selected some interesting
fonctions from others packages (see Vignette) and I adapted them to
1-Associate phenotypes (gene / variable ) to disease
2-Classify genes by phenotype or disease
3-Enrichment gene expression data using GSEA-R (Broad Institute)

Other function is in progress to facilitated the visualization of multi
Dimensional Genomics Data  for multiples cancers using Circos styles.

Please fill free for any suggestions.

Karim Mezhoud

[[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-es] Acceso gratuito durante un mes a la plataforma DataCamp...

2015-03-26 Thread Ruben Tobalina Ramirez
que bien!! justamente hoy he comenzado un curso de los gratis en
datacamp. Muchas gracias, le daré buen uso!

El día 26 de marzo de 2015, 18:45, Isidro Hidalgo ihida...@jccm.es escribió:
 Muy interesante. Había visto la oferta de 9$, pero NO GRATIS...
 Como siempre, gracias.

 Isidro Hidalgo Arellano
 Observatorio Regional de Empleo
 Consejería de Empleo y Economía
 http://www.jccm.es

 -Mensaje original-
 De: R-help-es [mailto:r-help-es-boun...@r-project.org] En nombre de
 Carlos Ortega
 Enviado el: jueves, 26 de marzo de 2015 18:36
 Para: Lista R
 Asunto: [R-es] Acceso gratuito durante un mes a la plataforma
 DataCamp...

 Buenas a todos,

 La gente de DataCamp se han puesto en contacto con el grupo de Madrid
 para ofrecernos una oferta para usar gratuitamente su plataforma con
 diferentes cursos de R durante un mes.

 Les hemos preguntado si sería posible compartir este ofrecimiento con
 toda la lista de R-Help-es y no ven mayor problema, les ha parecido muy
 bien la posibilidad.

 El link de acceso es el siguiente:

 https://www.datacamp.com/enroll-meetup

 ?Cuidado que los cursos son en inglés y para darse de alta, aun siendo
 gratuitio este primer mes, hay que asociar una tarjeta de crédito o una
 cuenta Paypal. Pasado este mes el estar dado de alta en la plataforma
 cuesta ?25$/mes.
 ?Durante este mes gratuito, uno se puede a puntar a cualquier curso
 (necesitan de una dedicación de de 5-8 horas aprox.). Los cursos van
 desde Introducción a R? hasta el uso de la solución RevoScale para
 BigData de Revolution Analytics.

 Saludos,
 Carlos Ortega
 www.qualityexcellence.es

   [[alternative HTML version deleted]]

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

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

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


Re: [R] basic help with as.Date()

2015-03-26 Thread Marc Schwartz

 On Mar 26, 2015, at 4:11 PM, Simon Kiss sjk...@gmail.com wrote:
 
 Hi there: normally I’m quite comfortable with as.Date(). But this data set is 
 causing problems.
 
 The core of the data frame looks like the sample data frame below, but my 
 attempt to convert df$mydate to a date object returns only NA. Can anyone 
 provide a suggestion?
 
 Thank you, Simon Kiss
 
 #sample data frame
 df-data.frame(mydate=factor(c('Jan-15', 'Feb-13', 'Mar-11', 'Jul-12')), 
 other=rnorm(4, 3))
 #Attempt to convert
 as.Date(as.character(df$mydate), format='%b-%y')


Hi,

R's default date class object requires a full date, with a month, day and year. 

You might look at the 'zoo' package on CRAN, which has a yearmon() function.

Regards,

Marc Schwartz

__
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] basic help with as.Date()

2015-03-26 Thread Prof Brian Ripley

On 26/03/2015 21:11, Simon Kiss wrote:

Hi there: normally I’m quite comfortable with as.Date(). But this data set is 
causing problems.

The core of the data frame looks like the sample data frame below, but my 
attempt to convert df$mydate to a date object returns only NA. Can anyone 
provide a suggestion?

Thank you, Simon Kiss

#sample data frame
df-data.frame(mydate=factor(c('Jan-15', 'Feb-13', 'Mar-11', 'Jul-12')), 
other=rnorm(4, 3))
#Attempt to convert
as.Date(as.character(df$mydate), format='%b-%y')


You would be on surer ground with something like

as.Date(paste0('01-',as.character(df$mydate)), format='%d-%b-%y')

since it is unclear what dates you expected to get.

--
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] basic help with as.Date()

2015-03-26 Thread Simon Kiss
Hi there: normally I’m quite comfortable with as.Date(). But this data set is 
causing problems.

The core of the data frame looks like the sample data frame below, but my 
attempt to convert df$mydate to a date object returns only NA. Can anyone 
provide a suggestion?

Thank you, Simon Kiss

#sample data frame
df-data.frame(mydate=factor(c('Jan-15', 'Feb-13', 'Mar-11', 'Jul-12')), 
other=rnorm(4, 3))
#Attempt to convert
as.Date(as.character(df$mydate), format='%b-%y')

__
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] Using and abusing %% (was Re: Why can't I access this type?)

2015-03-26 Thread Patrick Connolly
On Wed, 25-Mar-2015 at 03:14PM +0100, Henric Winell wrote:

...

| Well...  Opinions may perhaps differ, but apart from '%%' being
| butt-ugly it's also fairly slow:

Beauty, it is said, is in the eye of the beholder.  I'm impressed by
the way using %% reduces or eliminates complicated nested brackets.
In this tiny example it's not obvious but it's very clear if the
objective is to sort the dataframe by three or four columns and
various lots of aggregation then returning a largish number of
consecutive columns, omitting the rest.  It's very easy to see what's
going on without the need for intermediate objects.

|
|  .

| Unit: microseconds
| 
|expr
|  subset(all.states, all.states$Frost  150, select = c(state,
| Frost))
|all.states[all.states$Frost  150,
| c(state, Frost)]
|all.states %% filter(Frost  150) %%
| select(state, Frost)
|   min   lq  meanmedianuq  max neval cld
|   139.112  148.673  163.3960  159.1760  170.7895 1763.200  1000  b
|   104.039  111.973  127.2138  120.4395  128.6640 1381.809  1000 a
|  1010.076 1033.519 1133.1469 1107.8480 1175.1800 2932.206  1000   c

It's no surprise that instructing a computer in something closer to
human language is an order of magnitude slower.  I'm sure you'd get
something even quicker using machine code.  I spend 3 or 4 orders of
magnitude more time writing code than running it.  It's much more
important to me to be able to read and modify than it is to have it
run at optimum speed.

| 
| Of course, this doesn't matter for interactive one-off use.  But
| lately I've seen examples of the '%%' operator creeping into
| functions in packages. 

That could indicate that %% is seductively easy to use.  It's
probably true that there are places where it should be done the hard
way.


|  However, it would be nice to see a fast pipe operator as part of
| base R.

| 
| 
| Henric Winell
| 

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
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] Fitting a line on trellis plot

2015-03-26 Thread Frederic Ntirenganya
Thanks for the help.

Frederic Ntirenganya
Maseno University,
African Maths Initiative,
Kenya.
Mobile:(+254)718492836
Email: fr...@aims.ac.za
https://sites.google.com/a/aims.ac.za/fredo/

On Wed, Mar 25, 2015 at 4:48 PM, S Ellison s.elli...@lgcgroup.com wrote:


  Call:
  lm(formula = curr_data[[tmin_col]] ~ curr_data[[year_col]] -
  1 | curr_data[[month_col]])


 First, this is not a sensible formula for lm; lm() does not use '|' to
 denote grouping. It would be a valid formula for xyplot, in which |
 specifies grouping variables. In lm(), '|' is simply being treated as 'or',
 which is why one of your coefficients is for ' curr_data[[year_col]]  |
 curr_data[[month_col]]TRUE'

 Second, you should not normally need things like curr_data[[month_col]],
 either in lm or xyplot. If curr_data is a data frame, things like

 lm(tmin ~ year, data=curr_data)

 should work.

 Third, 'nested' models in lm use the nesting operator '/', not '|'. So if
 you want 12 lines with separate intercept and gradient from an lm, you need
 (with month as a factor and the default intercept suppressed)
 lm(tmin~month+year/month -1, data=curr_data) #-1 suppresses the intercept
 and provides a zero-based intercept for each month

 This gives you 12 'month' intercepts and one gradient per month. If you
 wanted a common intercept you'd do
 lm(tmin~ year/month, data=curr_data)
 But beware; the coefficients in both cases cannot be interpreted as a
 simple gradient and intercept for each month: if I recall correctly, the
 gradients for month2 and on are modelled as an additive increment on the
 first month gradient. Use predict() if you want an easy way to predict a
 value for a given (possibly fractional) time of year and 'month'.
 [Incidentally I don’t immediately see why that is a sensible thing to do -
 this fits a monthly summary against a numeric year. But I'm going to assume
 you know what you want there.]

 Finally, though, this model will not help you much with lattice as there's
 no _simple_ way of putting those lines on different panels in a lattice
 plot. If you just want a line on each of 12 panels, that's much easier. You
 can  use the panel() function with panel.lmline to put it there. For
 example, if you want to plot a line over the data, use

 xyplot(tmin~year|month, curr_data,
 panel=function(x, y, ...) {
 panel.xyplot(x, y, ...)
 panel.lmline(x, y, ...)
 }
 )


 S Ellison




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

__
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-es] Conectividad con Excel

2015-03-26 Thread miguel.angel.rodriguez.muinos
Hola Our Utopy.

Te puedo comentar cómo hago yo con XLConnect para acceder a un fichero
de Excel (por si es ésto lo que pretendes)
Veamos..

  require(XLConnect)
  file.import=/trayecto_del_fichero_Excel/fichero.xlsx
  file.load=loadWorkbook(file.import, create=FALSE)
  misdatos=readWorksheet(file.load, sheet=1)

Es esto lo que buscas?

Un Saludo,
Miguel Rodríguez
Consellería de Sanidade
Xunta de Galicia




El 26/03/2015 a las 15:04, Our Utopy escribió:
 Hola amigos, buenos días

 Esto sigue avanzando. Estoy ahora tratando de establecer la conectividad de
 R con Excel y he seguido dos viídeos en YouTube de una profesora llamada
 Bebilda que se explica muy bien.

 Con ambos tengo el mismo problema así que planteo uno de ellos, éste es:
   https://youtu.be/_pSJQO_9I4k?list=PL7DA3FDA21A1A6310

 Pero os lo explico brevemente:

 Cargo el paquete RODBC   install.packages(RODBC)
 Instalo la librería   library(RODBC)

 Todo bien hasta aqui...

 Se supone, que en esa librería hay unas funciones que me permiten conectar
 con Excel, esas funciones son:

 o-odncConnectExcel2007 o-odncConnectExcel

 DE tal manera que ahora podría abrir una canal

 canalexcel - odbcConnectExcel2007(lbw.xlsx)
 Pues esas funciones no están. R me da el error

 Error: no se pudo encontrar la función odbcConnectExcel2007

 lo mismo con la otra función

 canalexcel - odbcConnectExcel(lbw.xlsx)
 Y lo curioso es que también me pasa algo similar con la otra posibilidad
 que es el paquete XLConnect

 Y es que, además, si miro la documentación de este paquete RODBC no figuran
 esas funciones.

 ¿ ?

 ¿Me podéis nuevamente ayudar?

 Un saludo










Nota: A información contida nesta mensaxe e os seus posibles documentos 
adxuntos é privada e confidencial e está dirixida únicamente ó seu 
destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe, por 
favor elimínea. A distribución ou copia desta mensaxe non está autorizada.

Nota: La información contenida en este mensaje y sus posibles documentos 
adjuntos es privada y confidencial y está dirigida únicamente a su 
destinatario/a. Si usted no es el/la destinatario/a original de este mensaje, 
por favor elimínelo. La distribución o copia de este mensaje no está autorizada.

See more languages: http://www.sergas.es/aviso_confidencialidad.htm

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