[R] RQDA/RGtk2 Installation Problem

2018-04-14 Thread Ryoko Yamamoto
Greetings,

I have been having a problem installing RQDA on my Mac (OS 10.13.2). I
followed the installation process on the RQDA page (
http://rqda.r-forge.r-project.org/), but I keep getting an error message
saying that I am missing pkg-config and GTK. I reinstalled XQuartz and GTK+
2.24.17 multiple times (and reinstalled R version 3.4.4), but kept
receiving the same error message. I also tried to install RGtk2 from
MacPort, but got the same error messages. I am posting the log below, in
hope it will help someone to see the problem/solution.

In my Googling for solution, I saw some other people posting the same
problem, but have not seen a solution. I'd appreciate if anyone could help
me to fix this. I really would love to be able to use RQDA!

Thanks in advance for your help.

Ryoko



> install.packages('RQDA')
--- Please select a CRAN mirror for use in this session ---
also installing the dependencies ‘cairoDevice’, ‘gWidgetsRGtk2’, ‘RGtk2’

Packages which are only available in source form, and may need
  compilation of C/C++/Fortran: ‘cairoDevice’ ‘RGtk2’
Do you want to attempt to install these from sources?
y/n: y

installing the source packages ‘cairoDevice’, ‘gWidgetsRGtk2’, ‘RGtk2’,
‘RQDA’

trying URL 'https://cran.ism.ac.jp/src/contrib/cairoDevice_2.24.tar.gz'
Content type 'application/x-gzip' length 39639 bytes (38 KB)
==
downloaded 38 KB

trying URL 'https://cran.ism.ac.jp/src/contrib/gWidgetsRGtk2_0.0-86.tar.gz'
Content type 'application/x-gzip' length 165187 bytes (161 KB)
==
downloaded 161 KB

trying URL 'https://cran.ism.ac.jp/src/contrib/RGtk2_2.20.34.tar.gz'
Content type 'application/x-gzip' length 2793069 bytes (2.7 MB)
==
downloaded 2.7 MB

trying URL 'https://cran.ism.ac.jp/src/contrib/RQDA_0.3-1.tar.gz'
Content type 'application/x-gzip' length 134113 bytes (130 KB)
==
downloaded 130 KB

* installing *source* package ‘cairoDevice’ ...
** package ‘cairoDevice’ successfully unpacked and MD5 sums checked
checking for pkg-config... no
ERROR: Cannot find pkg-config.
ERROR: configuration failed for package ‘cairoDevice’
* removing
‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/cairoDevice’
* installing *source* package ‘RGtk2’ ...
** package ‘RGtk2’ successfully unpacked and MD5 sums checked
checking for pkg-config... no
checking for INTROSPECTION... no
checking for GTK... no
configure: error: GTK version 2.8.0 required
ERROR: configuration failed for package ‘RGtk2’
* removing
‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/RGtk2’
ERROR: dependencies ‘RGtk2’, ‘cairoDevice’ are not available for package
‘gWidgetsRGtk2’
* removing
‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/gWidgetsRGtk2’
ERROR: dependencies ‘gWidgetsRGtk2’, ‘RGtk2’ are not available for package
‘RQDA’
* removing
‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/RQDA’

The downloaded source packages are in

‘/private/var/folders/1_/59k3mmjd42q869s4tkbpb020gn/T/RtmpeYrG4k/downloaded_packages’
Warning messages:
1: In install.packages("RQDA") :
  installation of package ‘cairoDevice’ had non-zero exit status
2: In install.packages("RQDA") :
  installation of package ‘RGtk2’ had non-zero exit status
3: In install.packages("RQDA") :
  installation of package ‘gWidgetsRGtk2’ had non-zero exit status
4: In install.packages("RQDA") :
  installation of package ‘RQDA’ had non-zero exit status

[[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] Averiguar qué variables tiene el máximo valor

2018-04-14 Thread Carlos Ortega
Hola,
Solo te falta incluir ese vector de índices en el vector de nombres.
Aquí tienes un ejemplo:

> head(airquality)
  Ozone Solar.R Wind Temp Month Day
141 190  7.4   67 5   1
236 118  8.0   72 5   2
312 149 12.6   74 5   3
418 313 11.5   62 5   4
5NA  NA 14.3   56 5   5
628  NA 14.9   66 5   6
> val_ind <- apply(airquality, 1, which.max)
> col_val <- names(airquality)[val_ind]
> col_val
  [1] "Solar.R" "Solar.R" "Solar.R" "Solar.R" "Temp""Temp""Solar.R"
"Solar.R" "Temp""Solar.R" "Temp""Solar.R" "Solar.R"
 [14] "Solar.R" "Solar.R" "Solar.R" "Solar.R" "Solar.R" "Solar.R" "Temp"
"Temp""Solar.R" "Temp""Solar.R" "Solar.R" "Solar.R"
 [27] "Temp""Temp""Solar.R" "Solar.R" "Solar.R" "Solar.R" "Solar.R"
"Solar.R" "Solar.R" "Solar.R" "Solar.R" "Solar.R" "Solar.R"
 [40] "Solar.R" "Solar.R" "Solar.R" "Solar.R" "Solar.R" "Solar.R" "Solar.R"
"Solar.R" "Solar.R" "Temp""Solar.R" "Solar.R" "Solar.R"
 [53] "Temp""Solar.R" "Solar.R" "Solar.R" "Solar.R" "Temp""Solar.R"
"Temp""Solar.R" "Solar.R" "Solar.R" "Solar.R" "Solar.R"
 [66] "Solar.R" "Solar.R" "Solar.R" "Solar.R" "Solar.R" "Solar.R" "Solar.R"
"Solar.R" "Solar.R" "Solar.R" "Temp""Solar.R" "Solar.R"
 [79] "Solar.R" "Solar.R" "Solar.R" "Temp""Solar.R" "Solar.R" "Solar.R"
"Solar.R" "Temp""Temp""Solar.R" "Solar.R" "Solar.R"
 [92] "Solar.R" "Solar.R" "Temp""Temp""Temp""Temp""Temp"
"Solar.R" "Solar.R" "Solar.R" "Solar.R" "Solar.R" "Solar.R"
[105] "Solar.R" "Solar.R" "Temp""Temp""Temp""Solar.R" "Solar.R"
"Solar.R" "Solar.R" "Temp""Solar.R" "Solar.R" "Solar.R"
[118] "Solar.R" "Solar.R" "Solar.R" "Solar.R" "Solar.R" "Solar.R" "Solar.R"
"Solar.R" "Solar.R" "Solar.R" "Solar.R" "Solar.R" "Solar.R"
[131] "Solar.R" "Solar.R" "Solar.R" "Solar.R" "Solar.R" "Solar.R" "Temp"
"Solar.R" "Solar.R" "Solar.R" "Temp""Solar.R" "Solar.R"
[144] "Solar.R" "Temp""Solar.R" "Temp""Temp""Solar.R" "Solar.R"
"Solar.R" "Solar.R" "Solar.R"

Gracias,
Carlos Ortega
www.qualityexcellence.es



El 14 de abril de 2018, 23:23, Manuel Mendoza 
escribió:

>
> Hola de nuevo. Mi problema es parecido al anterior.
>
> Tengo una df con n filas con un valor para cada una de las 5 variables (v1
> a v5), y necesito construir un vector con la variable para la que cada fila
> tiene el valor máximo. El vector tendrá n elementos del tipo
> v3,v2,v2,v5,
>
> vec<- apply(df,1,which.max) me funciona, pero nuevamente me da la posición
> de las variables en vez de sus nombres. Quizás haya otra opción.
>
> Gracias nuevamente,
> Manuel
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> Dr Manuel Mendoza
> Department of Biogeography and Global Change
> National Museum of Natural History (MNCN)
> Spanish Scientific Council (CSIC)
> C/ Serrano 115bis, 28006 MADRID
> Spain
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
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] about family=binomial in glm funtion

2018-04-14 Thread Duncan Murdoch

On 14/04/2018 5:33 PM, Zhang Wilson wrote:

Hei,
   I just wonder the use of family=binomial in glm function.
   As I learned from book (e.g. Andy Field) that logistic regression (binary
logit) can use glm funtion with family = binomial. Here the y is a factor
variable (e.g. value = 1 or 2).

  But I have also seen i many other cases, same function glm with
family=binomial, but y is a variable with several column , like y=
cbind(y1, y2), and here y1  and y2 are the success number, failure number
respectively.


What I'd suggest is that you read the documentation.  In this case ?glm 
doesn't give the answer, but it links to ?family, which does.


Duncan Murdoch




What is the difference between these cases ? For my opinion the first one
is a logit model, and second one is a binomial probability model , right?

Many thanks.

[[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] about family=binomial in glm funtion

2018-04-14 Thread Zhang Wilson
Hei,
  I just wonder the use of family=binomial in glm function.
  As I learned from book (e.g. Andy Field) that logistic regression (binary
logit) can use glm funtion with family = binomial. Here the y is a factor
variable (e.g. value = 1 or 2).

 But I have also seen i many other cases, same function glm with
family=binomial, but y is a variable with several column , like y=
cbind(y1, y2), and here y1  and y2 are the success number, failure number
respectively.


What is the difference between these cases ? For my opinion the first one
is a logit model, and second one is a binomial probability model , right?

Many thanks.

[[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] Fwd: Re: Reading xpt files into R

2018-04-14 Thread William Dunlap via R-help
 > When I look at the SASxport::read.xport function code, it is in fact,
_not_ the
> same function. But it does have the R statement about what it thinks
> qualifies as a SAS xprot file:
>
> xport.file.header <- "HEADER RECORD***LIBRARY HEADER 
> RECORD!!!00
"
>
> It checks to see whether the file starts with that string.

Version 8 SAS xport files have the header
  HEADER RECORD***LIBV8 HEADER RECORD!!!0
0
It is easy to check for that in your text editor or in R.

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Sat, Apr 14, 2018 at 1:30 PM, David Winsemius 
wrote:

>
> > On Apr 14, 2018, at 12:18 PM, WRAY NICHOLAS via R-help <
> r-help@r-project.org> wrote:
> >
> >
> >  Original Message --
> > From: WRAY NICHOLAS 
> > To: peter dalgaard 
> > Date: 14 April 2018 at 20:18
> > Subject: Re: [R] Reading xpt files into R
> >
> >
> > Well yesterday I'd downloaded the "foreign" package and tried to open
> the xpt file using that:
> >
> > library(foreign)
> > read.xport("test.xpt")
> >
> > I got the following error and warning messages:
> >
> >> read.xport("test.xpt")
> > Error in read.xport("test.xpt") :
> > The specified file does not start with a SAS xport file header!
> > In addition: Warning message:
> > In readBin(file, what = character(0), n = 1, size =
> nchar(xport.file.header,  :
> > null terminator not found: breaking string at 1 bytes
> >
> > I can open the xpt using wordpad and there is a header but it seems to
> be just text.  I really don't know what constitutes an "
> > SAS xport file header"
>
> I'm not sure why Peter deleted my copy of a sample of a SAS xport header
> that I took from an NHANES data distribution. He seemed to think I was
> confused about the function you had been using. The reason I mentioned that
> `read.xport` was from the 'foreign' package is that one generally loads
> that package to make the function available, while it appears you were
> using a different package, SASxport, and I didn't know whether that package
> had a function which had the same name as the one from pkg-foreign, and if
> it did whether it might depend on the read.xport function in foreign. You
> should not need to download the 'foreign' package, since it ships with
> every distribution of R. These are the arguments accepted by that function:
>
> SASxport::read.xport
> function (file, force.integer = TRUE, formats = NULL, name.chars = NULL,
> names.tolower = FALSE, keep = NULL, drop = NULL, as.is = 0.95,
> verbose = FALSE, as.list = FALSE, include.formats = FALSE)
>
>
>  When I look at the SASxport::read.xport function code, it is in fact,
> _not_ the same function. But it does have the R statement about what it
> thinks qualifies as a SAS xprot file:
>
> xport.file.header <- "HEADER RECORD***LIBRARY HEADER 
> RECORD!!!00
> "
>
> It checks to see whether the file starts with that string.
>
> This is what appeared in my first message:
>
> >
> > The "export" or "transfer format from SA is supposed to make reading
> data less difficult and standardized. This is what a header from the
> version used by the NHANES releases (that's all one line):
> >
> > HEADER RECORD***LIBRARY HEADER 
> > RECORD!!!00
> SAS SAS SASLIB  9.2 XP_PRO
> 16SEP09:09:39:2516SEP09:09:39:25
>   HEADER RECORD***MEMBER  HEADER 
> RECORD!!!016140
> HEADER RECORD***DSCRPTR HEADER RECORD!!!00
> SAS DEMOSASDATA 9.2 XP_PRO
> 16SEP09:09:39:2516SEP09:09:39:25
>   HEADER RECORD***NAMESTR HEADER 
> RECORD!!!000144
>SEQNRespondent sequence number
>
> So the header is text, but it is text with a particular structure. If your
> file doesn't have that structure, then it's not a SAS xport file. The .xpt
> extension is also used for Mozilla Firefox plugins.
>
>
> >
> > Nick
> >
> >
> >
> > On 14 April 2018 at 10:32 peter dalgaard  wrote:
> >
> > That's what he tried,
>
> Actually not, Peter. Wray was using a function of the same name, but not
> from pkg-foreign. Perhaps he was following the tutorial at:
>
> http://www.phusewiki.org/wiki/index.php?title=Open_XPT_File_with_R
>
>
> > but the bottom line is that just because something is called foo.xpt
> there is no guarantee that it actually is a SAS XPORT file. Firefox plugins
> use the same extension but it could really be anything - naming conventions
> are just that: conventions.
> >
> > So dig deeper and find out what the file really is (or was supposed to
> be).
>
> Peter and I agree agree on that advice.
>
> >
> > -pd
> >
> >>
> >>On 14 Apr 2018, at 00:18 , David Winsemius <
> dwinsem...@comcast.net> wrote:
> >>
> >>There is a read.xport function in 

[R-es] Averiguar qué variables tiene el máximo valor

2018-04-14 Thread Manuel Mendoza


Hola de nuevo. Mi problema es parecido al anterior.

Tengo una df con n filas con un valor para cada una de las 5 variables  
(v1 a v5), y necesito construir un vector con la variable para la que  
cada fila tiene el valor máximo. El vector tendrá n elementos del tipo  
v3,v2,v2,v5,


vec<- apply(df,1,which.max) me funciona, pero nuevamente me da la  
posición de las variables en vez de sus nombres. Quizás haya otra  
opción.


Gracias nuevamente,
Manuel



























--
Dr Manuel Mendoza
Department of Biogeography and Global Change
National Museum of Natural History (MNCN)
Spanish Scientific Council (CSIC)
C/ Serrano 115bis, 28006 MADRID
Spain

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


Re: [R] Fwd: Re: Reading xpt files into R

2018-04-14 Thread David Winsemius

> On Apr 14, 2018, at 12:18 PM, WRAY NICHOLAS via R-help  
> wrote:
> 
> 
>  Original Message --
> From: WRAY NICHOLAS 
> To: peter dalgaard 
> Date: 14 April 2018 at 20:18
> Subject: Re: [R] Reading xpt files into R
> 
> 
> Well yesterday I'd downloaded the "foreign" package and tried to open the xpt 
> file using that:
> 
> library(foreign)
> read.xport("test.xpt")
> 
> I got the following error and warning messages:
> 
>> read.xport("test.xpt")
> Error in read.xport("test.xpt") : 
> The specified file does not start with a SAS xport file header!
> In addition: Warning message:
> In readBin(file, what = character(0), n = 1, size = nchar(xport.file.header,  
> :
> null terminator not found: breaking string at 1 bytes
> 
> I can open the xpt using wordpad and there is a header but it seems to be 
> just text.  I really don't know what constitutes an "
> SAS xport file header"

I'm not sure why Peter deleted my copy of a sample of a SAS xport header that I 
took from an NHANES data distribution. He seemed to think I was confused about 
the function you had been using. The reason I mentioned that `read.xport` was 
from the 'foreign' package is that one generally loads that package to make the 
function available, while it appears you were using a different package, 
SASxport, and I didn't know whether that package had a function which had the 
same name as the one from pkg-foreign, and if it did whether it might depend on 
the read.xport function in foreign. You should not need to download the 
'foreign' package, since it ships with every distribution of R. These are the 
arguments accepted by that function:

SASxport::read.xport
function (file, force.integer = TRUE, formats = NULL, name.chars = NULL, 
names.tolower = FALSE, keep = NULL, drop = NULL, as.is = 0.95, 
verbose = FALSE, as.list = FALSE, include.formats = FALSE) 


 When I look at the SASxport::read.xport function code, it is in fact, _not_ 
the same function. But it does have the R statement about what it thinks 
qualifies as a SAS xprot file:

xport.file.header <- "HEADER RECORD***LIBRARY HEADER 
RECORD!!!00  "

It checks to see whether the file starts with that string.

This is what appeared in my first message:

> 
> The "export" or "transfer format from SA is supposed to make reading data 
> less difficult and standardized. This is what a header from the version used 
> by the NHANES releases (that's all one line):
> 
> HEADER RECORD***LIBRARY HEADER 
> RECORD!!!00  SAS SAS SASLIB  9.2 
> XP_PRO16SEP09:09:39:2516SEP09:09:39:25
> HEADER RECORD***MEMBER  
> HEADER RECORD!!!016140  HEADER 
> RECORD***DSCRPTR HEADER RECORD!!!00  SAS  
>DEMOSASDATA 9.2 XP_PRO
> 16SEP09:09:39:2516SEP09:09:39:25  
>   HEADER RECORD***NAMESTR HEADER 
> RECORD!!!000144  SEQNRespondent sequence 
> number 

So the header is text, but it is text with a particular structure. If your file 
doesn't have that structure, then it's not a SAS xport file. The .xpt extension 
is also used for Mozilla Firefox plugins.


> 
> Nick
> 
> 
> 
> On 14 April 2018 at 10:32 peter dalgaard  wrote:
> 
> That's what he tried,

Actually not, Peter. Wray was using a function of the same name, but not from 
pkg-foreign. Perhaps he was following the tutorial at:

http://www.phusewiki.org/wiki/index.php?title=Open_XPT_File_with_R


> but the bottom line is that just because something is called foo.xpt there is 
> no guarantee that it actually is a SAS XPORT file. Firefox plugins use the 
> same extension but it could really be anything - naming conventions are just 
> that: conventions.
> 
> So dig deeper and find out what the file really is (or was supposed to be).

Peter and I agree agree on that advice.

> 
> -pd
> 
>> 
>>On 14 Apr 2018, at 00:18 , David Winsemius 
>>  wrote:
>> 
>>There is a read.xport function in the foreign package and I think 
>> most people would have chosen that one as a first attemp. It's part of the 
>> standard R distribution. It refers you to 
>> https://support.sas.com/techsup/technote/ts140.pdf for details on the format.
> 
-- 

David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'   
-Gehm's Corollary to Clarke's Third Law

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

Re: [R] Fwd: Re: Reading xpt files into R

2018-04-14 Thread William Dunlap via R-help
Does read.xport read both version 5 and version 8 xpt files?  This link to
the Library of Congress can get you started on how to interpret the
header.  (It states that Version 8 was introduced in 2012 but was not in
wide use as of early 2017.)

https://www.loc.gov/preservation/digital/formats/fdd/fdd000464.shtml

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Sat, Apr 14, 2018 at 12:18 PM, WRAY NICHOLAS via R-help <
r-help@r-project.org> wrote:

>
>  Original Message --
> From: WRAY NICHOLAS 
> To: peter dalgaard 
> Date: 14 April 2018 at 20:18
> Subject: Re: [R] Reading xpt files into R
>
>
> Well yesterday I'd downloaded the "foreign" package and tried to open the
> xpt file using that:
>
> library(foreign)
> read.xport("test.xpt")
>
> I got the following error and warning messages:
>
> > read.xport("test.xpt")
> Error in read.xport("test.xpt") :
> The specified file does not start with a SAS xport file header!
> In addition: Warning message:
> In readBin(file, what = character(0), n = 1, size =
> nchar(xport.file.header,  :
> null terminator not found: breaking string at 1 bytes
>
> I can open the xpt using wordpad and there is a header but it seems to be
> just text.  I really don't know what constitutes an "
> SAS xport file header"
>
> Nick
>
>
>
> On 14 April 2018 at 10:32 peter dalgaard  wrote:
>
> That's what he tried, but the bottom line is that just because something
> is called foo.xpt there is no guarantee that it actually is a SAS XPORT
> file. Firefox plugins use the same extension but it could really be
> anything - naming conventions are just that: conventions.
>
> So dig deeper and find out what the file really is (or was supposed to be).
>
> -pd
>
> >
> > On 14 Apr 2018, at 00:18 , David Winsemius <
> dwinsem...@comcast.net> wrote:
> >
> > There is a read.xport function in the foreign package and I
> think most people would have chosen that one as a first attemp. It's part
> of the standard R distribution. It refers you to https://support.sas.com/
> techsup/technote/ts140.pdf for details on the format.
> >
> >
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd@cbs.dk Priv: pda...@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.
>

[[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] Encontrar el más votado

2018-04-14 Thread Manuel Mendoza

Funciona, gracias una vez más,
Manuel

Quoting "Carlos J. Gil Bellosta" :


Probaría con

apply(data, 1,  function(x) names(table(x))[which.max(table(x))])

No sé si he contado los paréntesis bien.

El sáb., 14 abr. 2018 a las 20:33, Manuel Mendoza ()
escribió:



Gracias Carlos J., sale bien, pero me transforma las 6 categorías en
números del 1 al 6
¿sabes cómo evitarlo?


Quoting "Carlos J. Gil Bellosta" :

> apply(data, 1,  function(x) which.max(table(x)))
>
> El sáb., 14 abr. 2018 a las 19:54, Manuel Mendoza (<
mmend...@mncn.csic.es>)
> escribió:
>
>>
>> Buenas tardes de sábado. LLevo más de una hora intentando una cosa que
>> debe ser una chorrada; a ver si alguien puede ayudarme.
>>
>> Tengo una matriz (data) de 1000 muestras (filas) y 6 categorías
>> posibles. Hay 100 columnas, es decir, 100 votos para cada muestra, y
>> necesito crear un vector con la categoría más votada de las 6.
>>
>>   which.max(table(data[i,])) me da la más votada de la muestra i.
>> Estoy intentando crear el vector con un for y de momento no me sale.
>> ¡ya! es muy fácil, pero no me sale, y estoy seguro de que hay una
>> forma mucho más fácil.
>>
>> Gracias,
>> Manuel
>> --
>> Dr Manuel Mendoza
>> Department of Biogeography and Global Change
>> National Museum of Natural History (MNCN)
>> Spanish Scientific Council (CSIC)
>> C/ Serrano 115bis, 28006 MADRID
>> Spain
>>
>> ___
>> R-help-es mailing list
>> R-help-es@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-help-es
>>


--
Dr Manuel Mendoza
Department of Biogeography and Global Change
National Museum of Natural History (MNCN)
Spanish Scientific Council (CSIC)
C/ Serrano 115bis, 28006 MADRID
Spain





--
Dr Manuel Mendoza
Department of Biogeography and Global Change
National Museum of Natural History (MNCN)
Spanish Scientific Council (CSIC)
C/ Serrano 115bis, 28006 MADRID
Spain

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


[R] Fwd: Re: Reading xpt files into R

2018-04-14 Thread WRAY NICHOLAS via R-help

 Original Message --
From: WRAY NICHOLAS 
To: peter dalgaard 
Date: 14 April 2018 at 20:18
Subject: Re: [R] Reading xpt files into R


Well yesterday I'd downloaded the "foreign" package and tried to open the xpt 
file using that:

library(foreign)
read.xport("test.xpt")

I got the following error and warning messages:

> read.xport("test.xpt")
Error in read.xport("test.xpt") : 
The specified file does not start with a SAS xport file header!
In addition: Warning message:
In readBin(file, what = character(0), n = 1, size = nchar(xport.file.header,  :
null terminator not found: breaking string at 1 bytes

I can open the xpt using wordpad and there is a header but it seems to be just 
text.  I really don't know what constitutes an "
SAS xport file header"

Nick



On 14 April 2018 at 10:32 peter dalgaard  wrote:

That's what he tried, but the bottom line is that just because something is 
called foo.xpt there is no guarantee that it actually is a SAS XPORT file. 
Firefox plugins use the same extension but it could really be anything - naming 
conventions are just that: conventions.

So dig deeper and find out what the file really is (or was supposed to be).

-pd

> 
> On 14 Apr 2018, at 00:18 , David Winsemius 
>  wrote:
> 
> There is a read.xport function in the foreign package and I think 
> most people would have chosen that one as a first attemp. It's part of the 
> standard R distribution. It refers you to 
> https://support.sas.com/techsup/technote/ts140.pdf for details on the format.
> 
> 
--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk Priv: pda...@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-es] Encontrar el más votado

2018-04-14 Thread Manuel Mendoza


Gracias Carlos J., sale bien, pero me transforma las 6 categorías en  
números del 1 al 6

¿sabes cómo evitarlo?


Quoting "Carlos J. Gil Bellosta" :


apply(data, 1,  function(x) which.max(table(x)))

El sáb., 14 abr. 2018 a las 19:54, Manuel Mendoza ()
escribió:



Buenas tardes de sábado. LLevo más de una hora intentando una cosa que
debe ser una chorrada; a ver si alguien puede ayudarme.

Tengo una matriz (data) de 1000 muestras (filas) y 6 categorías
posibles. Hay 100 columnas, es decir, 100 votos para cada muestra, y
necesito crear un vector con la categoría más votada de las 6.

  which.max(table(data[i,])) me da la más votada de la muestra i.
Estoy intentando crear el vector con un for y de momento no me sale.
¡ya! es muy fácil, pero no me sale, y estoy seguro de que hay una
forma mucho más fácil.

Gracias,
Manuel
--
Dr Manuel Mendoza
Department of Biogeography and Global Change
National Museum of Natural History (MNCN)
Spanish Scientific Council (CSIC)
C/ Serrano 115bis, 28006 MADRID
Spain

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




--
Dr Manuel Mendoza
Department of Biogeography and Global Change
National Museum of Natural History (MNCN)
Spanish Scientific Council (CSIC)
C/ Serrano 115bis, 28006 MADRID
Spain

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


Re: [R-es] Encontrar el más votado

2018-04-14 Thread Carlos J. Gil Bellosta
apply(data, 1,  function(x) which.max(table(x)))

El sáb., 14 abr. 2018 a las 19:54, Manuel Mendoza ()
escribió:

>
> Buenas tardes de sábado. LLevo más de una hora intentando una cosa que
> debe ser una chorrada; a ver si alguien puede ayudarme.
>
> Tengo una matriz (data) de 1000 muestras (filas) y 6 categorías
> posibles. Hay 100 columnas, es decir, 100 votos para cada muestra, y
> necesito crear un vector con la categoría más votada de las 6.
>
>   which.max(table(data[i,])) me da la más votada de la muestra i.
> Estoy intentando crear el vector con un for y de momento no me sale.
> ¡ya! es muy fácil, pero no me sale, y estoy seguro de que hay una
> forma mucho más fácil.
>
> Gracias,
> Manuel
> --
> Dr Manuel Mendoza
> Department of Biogeography and Global Change
> National Museum of Natural History (MNCN)
> Spanish Scientific Council (CSIC)
> C/ Serrano 115bis, 28006 MADRID
> Spain
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-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-es] Encontrar el más votado

2018-04-14 Thread Manuel Mendoza


Buenas tardes de sábado. LLevo más de una hora intentando una cosa que  
debe ser una chorrada; a ver si alguien puede ayudarme.


Tengo una matriz (data) de 1000 muestras (filas) y 6 categorías  
posibles. Hay 100 columnas, es decir, 100 votos para cada muestra, y  
necesito crear un vector con la categoría más votada de las 6.


 which.max(table(data[i,])) me da la más votada de la muestra i.  
Estoy intentando crear el vector con un for y de momento no me sale.  
¡ya! es muy fácil, pero no me sale, y estoy seguro de que hay una  
forma mucho más fácil.


Gracias,
Manuel
--
Dr Manuel Mendoza
Department of Biogeography and Global Change
National Museum of Natural History (MNCN)
Spanish Scientific Council (CSIC)
C/ Serrano 115bis, 28006 MADRID
Spain

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


Re: [R] Reading xpt files into R

2018-04-14 Thread peter dalgaard
That's what he tried, but the bottom line is that just because something is 
called foo.xpt there is no guarantee that it actually is a SAS XPORT file. 
Firefox plugins use the same extension but it could really be anything - naming 
conventions are just that: conventions.

So dig deeper and find out what the file really is (or was supposed to be). 

-pd

> On 14 Apr 2018, at 00:18 , David Winsemius  wrote:
> 
> There is a read.xport function in the foreign package and I think most people 
> would have chosen that one as a first attemp. It's part of the standard R 
> distribution. It refers you to 
> https://support.sas.com/techsup/technote/ts140.pdf for details on the format.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
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.


Re: [ESS] ess-dump-object-into-edit-buffer

2018-04-14 Thread Patrick Connolly
G'day Ista,

I'm having trouble getting an example small enough to show.  Some work
properly and others (usually longer ones) don't.  Can't imagine what
makes the difference.

I'll be at the machine where I normally work and there I'll find a
small example.

Thanks for looking at my problem.

best
Patrick


On Thu, 12-Apr-2018 at 11:08PM -0400, Ista Zahn wrote:

|> Hi Patrick,
|> 
|> I don't use ess-dump-object-into-edit-buffer, so I'm not sure what
|> exactly you expect it to do. A specific example would help, i.e., a
|> description of exactly what you did, exactly what happened, and how
|> what happened differed from you expectation.
|> 
|> For example, if I start R with 'M-x R ' and do 'M-x
|> ess-dump-object-into-edit-buffer  getwd ' I see a new buffer
|> is created containing
|> 
|> getwd <-
|> function ()
|> .Internal(getwd())
|> 
|> Is that what you see? If so, how does it differ from what you expect?
|> If you see something different, how does your setup differ from mine?
|> I'm running Emacs 25.3 and ESS 17.11 [elpa: 20180412.315]
|> 
|> Best,
|> Ista
|> 
|> On Thu, Apr 12, 2018 at 7:19 PM, Patrick Connolly
|>  wrote:
|> > Thanks Ista.
|> >
|> > The result is not the same, but it's equally useless.  It produces almost
|> > the same as typing the name of the function and pressing . That is 
to
|> > say, unless the function has been edited in the working directory, it lists
|> > all the code without any of the comments almost in the form of a list
|> > element labelled "structure" and a second element labelled "source" which
|> > contains all the source in the form of a character vector.   Quite a lot of
|> > text wrangling is required to get that text into the form of an editable
|> > function.
|> >
|> > There is a slight difference from what results from typing the function 
name
|> > and pressing   in that the word "structure" is not in the latter and
|> > the source is an attr.
|> >
|> > (I say "almost" because neither form is exactly the same as how a list is
|> > displayed.)
|> >
|> > Is that intended behaviour?
|> >
|> > TIA
|> > Patrick
|> >
|> > On 04/13/2018 01:48 AM, Ista Zahn wrote:
|> >
|> > On Thu, Apr 12, 2018 at 3:56 AM, Patrick Connolly
|> >  wrote:
|> >
|> > Thanks for the response, however, if I start Emacs with a '-q' none of
|> > my ~/.emacs file is read, so Emacs doesn't know how to start R.  More
|> > to the point, I'm unable to run R within Emacs any other way.
|> >
|> > The usual recipe is to start with emacs -q and then evaluate
|> >
|> > (package-initialize)
|> > (require 'ess-site)
|> >
|> > in the scratch buffer, then check to see if you can reproduce the bug.
|> > If you have ESS installed in a way that it is not in your load-path by
|> > default you may have to do something along the lines of
|> >
|> > (add-to-list 'load-path "/path/to/ESS/lisp/")
|> > (load "ess-site")
|> >
|> > Best,
|> > Ista
|> >
|> >
|> >
|> > I gather there is a way of applying individual lines of the .emacs
|> > files but a bear with a small brain doesn't know how to do that (or
|> > where to look in the manual how to do it),
|> >
|> > It would appear, if it doesn't reproduce, that the problem is
|> > somewhere in my .emacs file.  That's a hodge-podge of various things
|> > I've picked up over the decades so it wouldn't be surprising to find
|> > some incompatibilities.
|> >
|> > Ideas appreciated.
|> >
|> >
|> > On Wed, 11-Apr-2018 at 07:44AM -0400, Ista Zahn wrote:
|> >
|> > |> I can't reproduce it with the latest ESS from melpa. Can you give
|> > |> reproduction steps starting with
|> > |>
|> > |> emacs -q
|> > |>
|> > |> ?
|> > |>
|> > |> --Ista
|> > |>
|> > |> On Wed, Apr 11, 2018 at 4:58 AM, Patrick Connolly
|> > |>  wrote:
|> > |> > For a long time I used to be able to use
|> > |> >
|> > |> > ess-dump-object-into-edit-buffer
|> > |> >
|> > |> > to create a buffer that could be used to edit the designated function
|> > |> > from anywhere on the search path to make a local version.
|> > |> >
|> > |> > Starting at about ess-15.x, only the first 5 or so lines of code is
|> > |> > made available which I took to be a bug that would be fixed.  However,
|> > |> > I was mistaken.  I installed ess-17.11 and it's still the same.  Being
|> > |> > a bear with only a small brain, I can't imagine what use that would be
|> > |> > if it's what is intended.
|> > |> >
|> > |> > Could it be that there is an additional setting that allows all of the
|> > |> > function (including comments) to be dumped into that buffer?  Perhaps,
|> > |> > more difficult to track down, I have something else in my ~/.emacs
|> > |> > file that is incompatible.
|> > |> >
|> > |> > TIA for suggestions.
|> > |> >
|> > |> > --
|> > |> >
|> > ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
|> > |> >___Patrick Connolly
|> > |> >  {~._.~}   Great minds discuss ideas
|> > |> >  _( Y )_