Re: [R] Importing data using Foreign

2020-08-26 Thread peter dalgaard
It is because you don't know whether you want it or not. 

It is a bit more obvious with integer indexing, as in color[race]: if race is 
NA you don't know what color to put in, but the result should be the same 
length as race. 

With logical indices, the behaviour is a bit annoying, but ultimately follows 
from the coercion rules: You might think that you could treat NA as FALSE (& 
the subset() function does just that), but then you'd get the problem that 
x[NA] would differ from x[as.integer(NA)] because NA is of mode "logical", 
lowest in the coercion hierarchy.

-pd

> On 26 Aug 2020, at 17:06 , Elham Daadmehr  wrote:
> 
> Thanks guys. but I'm a bit confused. the input is the first column (z[,1] and 
> z1[,1]).
> How is it possible that a subset of a non-NA vector, contains NA?
> 
> On Wed, Aug 26, 2020 at 4:58 PM Eric Berger  wrote:
> Good point! :-)
> 
> 
> On Wed, Aug 26, 2020 at 5:55 PM peter dalgaard  wrote:
> Offhand, I suspect that the NAs are in the 8th column.
> 
> > On 26 Aug 2020, at 10:57 , Elham Daadmehr  wrote:
> > 
> > Hi all,
> > 
> > I have a simple problem. I get stuck in using the imported spss data (.sav)
> > using "read.spss".
> > I imported data (z) without any problem. After importing, the first column
> > doesn't contain any "NA". but when I choose a subset of it (like:
> > z[z[,8]=="11"|z[,8]=="12"|z[,8]=="14",]), lots of NA appears (even in the
> > first column).
> > 
> > The (.sav) file is the output of Compustat (WRDS).
> > 
> > It is terrible, I can't find the mistake.
> > 
> > Thank you in advance for your help,
> > Elham
> > 
> >   [[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
> 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.

-- 
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: [R] Importing data using Foreign

2020-08-26 Thread Eric Berger
c(1:3)[c(1,NA,3)]
[1] 1 NA 3


On Wed, Aug 26, 2020 at 6:06 PM Elham Daadmehr  wrote:

> Thanks guys. but I'm a bit confused. the input is the first column (z[,1]
> and z1[,1]).
> How is it possible that a subset of a non-NA vector, contains NA?
>
> On Wed, Aug 26, 2020 at 4:58 PM Eric Berger  wrote:
>
>> Good point! :-)
>>
>>
>> On Wed, Aug 26, 2020 at 5:55 PM peter dalgaard  wrote:
>>
>>> Offhand, I suspect that the NAs are in the 8th column.
>>>
>>> > On 26 Aug 2020, at 10:57 , Elham Daadmehr 
>>> wrote:
>>> >
>>> > Hi all,
>>> >
>>> > I have a simple problem. I get stuck in using the imported spss data
>>> (.sav)
>>> > using "read.spss".
>>> > I imported data (z) without any problem. After importing, the first
>>> column
>>> > doesn't contain any "NA". but when I choose a subset of it (like:
>>> > z[z[,8]=="11"|z[,8]=="12"|z[,8]=="14",]), lots of NA appears (even in
>>> the
>>> > first column).
>>> >
>>> > The (.sav) file is the output of Compustat (WRDS).
>>> >
>>> > It is terrible, I can't find the mistake.
>>> >
>>> > Thank you in advance for your help,
>>> > Elham
>>> >
>>> >   [[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
>>> 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.
>>>
>>

[[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] Importing data using Foreign

2020-08-26 Thread Eric Berger
Good point! :-)


On Wed, Aug 26, 2020 at 5:55 PM peter dalgaard  wrote:

> Offhand, I suspect that the NAs are in the 8th column.
>
> > On 26 Aug 2020, at 10:57 , Elham Daadmehr  wrote:
> >
> > Hi all,
> >
> > I have a simple problem. I get stuck in using the imported spss data
> (.sav)
> > using "read.spss".
> > I imported data (z) without any problem. After importing, the first
> column
> > doesn't contain any "NA". but when I choose a subset of it (like:
> > z[z[,8]=="11"|z[,8]=="12"|z[,8]=="14",]), lots of NA appears (even in the
> > first column).
> >
> > The (.sav) file is the output of Compustat (WRDS).
> >
> > It is terrible, I can't find the mistake.
> >
> > Thank you in advance for your help,
> > Elham
> >
> >   [[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
> 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.
>

[[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] Importing data using Foreign

2020-08-26 Thread peter dalgaard
Offhand, I suspect that the NAs are in the 8th column.

> On 26 Aug 2020, at 10:57 , Elham Daadmehr  wrote:
> 
> Hi all,
> 
> I have a simple problem. I get stuck in using the imported spss data (.sav)
> using "read.spss".
> I imported data (z) without any problem. After importing, the first column
> doesn't contain any "NA". but when I choose a subset of it (like:
> z[z[,8]=="11"|z[,8]=="12"|z[,8]=="14",]), lots of NA appears (even in the
> first column).
> 
> The (.sav) file is the output of Compustat (WRDS).
> 
> It is terrible, I can't find the mistake.
> 
> Thank you in advance for your help,
> Elham
> 
>   [[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
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: [R] readxl question

2020-08-26 Thread PIKAL Petr
Hi

As OP has only about 250 files and in read_excel you cannot specify several
ranges at once, reading those values separately and concatenating them
together in one step seems to be the most efficient way. One probably could
design such function, but time spent on the function performing the task
only once is probably bigger than performing 250*3 reads.

I see inefficiency in writing each column into separate text file and
coppying it back to Excel file.

Cheers
Petr

> -Original Message-
> From: Upton, Stephen (Steve) (CIV) 
> Sent: Wednesday, August 26, 2020 2:44 PM
> To: PIKAL Petr ; Thomas Subia 
> Cc: r-help@r-project.org
> Subject: RE: [R] readxl question
> 
> From your example, it appears you are reading in the same excel file for
> each function to get a value. I would look at creating a function that
> extracts what you need from each file all at once, rather than separate
> reads.
> 
> Stephen C. Upton
> SEED (Simulation Experiments & Efficient Designs) Center for Data Farming
> SEED Center website: https://harvest.nps.edu
> 
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of PIKAL Petr
> Sent: Wednesday, August 26, 2020 3:50 AM
> To: Thomas Subia 
> Cc: r-help@r-project.org
> Subject: Re: [R] readxl question
> 
> NPS WARNING: *external sender* verify before acting.
> 
> 
> Hi
> 
> 
> Are you sure that your command read values from respective cells?
> 
> I tried it and got empty data frame with names
> > WO <- lapply(files, read_excel, sheet=1, range=("B3"))
> > as.data.frame(WO)
> [1] ano TP303   X96
> [4] X0  X3.7518 X26.7
> <0 rows> (or 0-length row.names)
> 
> To get data, col_names argument should be set to FALSE WO <- lapply(files,
> read_excel, sheet=1, range=("B3"), col_names=FALSE)
> WO2 <- lapply(files, read_excel, sheet=1, range=("B5"), col_names=FALSE)
> 
> After that unlist and one rbind together with t should be enough to give
you
> one table WO <- unlist(WO)
> WO2 <- unlist(WO2)
> result <- t(rbind(WO, WO2))
> result
>  WO  WO2
> ...1 "ano"   "ano"
> ...1 "TP303" "261119/2"
> ...1 "96""288"
> ...1 "0" "192"
> ...1 "3.752" "25.92094"
> ...1 "26.7"  "38.6"
> >
> 
> And instead txt document you could do
> 
> write.table(result, "result.xls", sep = "\t", row.names = F)
> 
> And now "result.xls" is directly readable with Excel
> 
> Cheers
> Petr
> 
> >
> > -Original Message-
> > From: R-help  On Behalf Of Thomas Subia
> > via R-help
> > Sent: Saturday, August 22, 2020 6:25 AM
> > To: r-help@r-project.org
> > Subject: [R] readxl question
> >
> > Colleagues,
> >
> >
> >
> > I have 250 Excel files in a directory. Each of those files has the
> > same
> layout.
> > The problem is that the data in each Excel data is not in rectangular
> form. I've
> > been using readxl to extract the data which I need.
> > Each of my metrics are stored in a particular cell. For each metric, I
> create text
> > files which stores my metrics.
> >
> >
> >
> > library(plyr)
> >
> > library(readxl)
> >
> >
> >
> > files <- list.files(pattern="*.xls", full.names = FALSE)
> >
> >
> >
> > # Extract Work Order
> >
> > WO <- lapply(files, read_excel, sheet="Sheet1", range=("B9")) WO_list
> > <-
> > as.data.frame(WO) trans_WO <- t(WO_list) write.table(trans_WO
> > ,"WO.txt")
> >
> >
> >
> > # Extract bubble 14_1
> >
> > BUBBLE_14_1 <- lapply(files, read_excel, sheet="Sheet1",
> > range=("c46")) BUBBLE_14_1_list <- as.data.frame(BUBBLE_14_1)
> >
> > trans_BUBBLE_14_1 <- t(BUBBLE_14_1_list)
> >
> >
> >
> > write.table(trans_BUBBLE_14_1,"BUBBLE_14_1.txt")
> >
> >
> >
> >
> >
> > # Extract bubble 14_2
> >
> > BUBBLE_14_2 <- lapply(files, read_excel, sheet="Sheet1",
> > range=("c62")) BUBBLE_14_2_list <- as.data.frame(BUBBLE_14_2)
> >
> > trans_BUBBLE_14_2 <- t(BUBBLE_14_2_list)
> >
> > write.table(trans_BUBBLE_14_2,"BUBBLE_14_2.txt")
> >
> >
> >
> > After the text files have been created, I cut and paste the contents
> > of
> each
> > text file to Excel.
> >
> > This has worked fine if the number of cells I am extracting from a
> > file is
> small.
> >
> > If the number gets larger, this method is inefficient.
> >
> >
> >
> > Any advice on how to do this would be appreciated.
> >
> >
> >
> > All the best,
> >
> >
> >
> > Thomas Subia
> >
> >
> >   [[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, 

Re: [R] Importing data using Foreign

2020-08-26 Thread Eric Berger
Hi Elham,
You are not giving us much to go on here.
Show us the commands that (a) confirm there are no NA's in the first column
of z
and (b) output a row of z that has an NA in the first column.
Here's how one might do this:
(a) sum(is.na(z[,1]))
(b) z[ match(TRUE, z[,8] %in% c("11","12","14")), ]

Eric


On Wed, Aug 26, 2020 at 3:56 PM Elham Daadmehr  wrote:

> Hi all,
>
> I have a simple problem. I get stuck in using the imported spss data (.sav)
> using "read.spss".
> I imported data (z) without any problem. After importing, the first column
> doesn't contain any "NA". but when I choose a subset of it (like:
> z[z[,8]=="11"|z[,8]=="12"|z[,8]=="14",]), lots of NA appears (even in the
> first column).
>
> The (.sav) file is the output of Compustat (WRDS).
>
> It is terrible, I can't find the mistake.
>
> Thank you in advance for your help,
> Elham
>
> [[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] Importing data using Foreign

2020-08-26 Thread Elham Daadmehr
Hi all,

I have a simple problem. I get stuck in using the imported spss data (.sav)
using "read.spss".
I imported data (z) without any problem. After importing, the first column
doesn't contain any "NA". but when I choose a subset of it (like:
z[z[,8]=="11"|z[,8]=="12"|z[,8]=="14",]), lots of NA appears (even in the
first column).

The (.sav) file is the output of Compustat (WRDS).

It is terrible, I can't find the mistake.

Thank you in advance for your help,
Elham

[[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] readxl question

2020-08-26 Thread Upton, Stephen (Steve) (CIV)
>From your example, it appears you are reading in the same excel file for
each function to get a value. I would look at creating a function that
extracts what you need from each file all at once, rather than separate
reads.

Stephen C. Upton
SEED (Simulation Experiments & Efficient Designs) Center for Data Farming
SEED Center website: https://harvest.nps.edu

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of PIKAL Petr
Sent: Wednesday, August 26, 2020 3:50 AM
To: Thomas Subia 
Cc: r-help@r-project.org
Subject: Re: [R] readxl question

NPS WARNING: *external sender* verify before acting.


Hi


Are you sure that your command read values from respective cells?

I tried it and got empty data frame with names
> WO <- lapply(files, read_excel, sheet=1, range=("B3"))
> as.data.frame(WO)
[1] ano TP303   X96
[4] X0  X3.7518 X26.7
<0 rows> (or 0-length row.names)

To get data, col_names argument should be set to FALSE WO <- lapply(files,
read_excel, sheet=1, range=("B3"), col_names=FALSE)
WO2 <- lapply(files, read_excel, sheet=1, range=("B5"), col_names=FALSE)

After that unlist and one rbind together with t should be enough to give you
one table WO <- unlist(WO)
WO2 <- unlist(WO2)
result <- t(rbind(WO, WO2))
result
 WO  WO2
...1 "ano"   "ano"
...1 "TP303" "261119/2"
...1 "96""288"
...1 "0" "192"
...1 "3.752" "25.92094"
...1 "26.7"  "38.6"
>

And instead txt document you could do

write.table(result, "result.xls", sep = "\t", row.names = F)

And now "result.xls" is directly readable with Excel

Cheers
Petr

>
> -Original Message-
> From: R-help  On Behalf Of Thomas Subia 
> via R-help
> Sent: Saturday, August 22, 2020 6:25 AM
> To: r-help@r-project.org
> Subject: [R] readxl question
>
> Colleagues,
>
>
>
> I have 250 Excel files in a directory. Each of those files has the 
> same
layout.
> The problem is that the data in each Excel data is not in rectangular
form. I've
> been using readxl to extract the data which I need.
> Each of my metrics are stored in a particular cell. For each metric, I
create text
> files which stores my metrics.
>
>
>
> library(plyr)
>
> library(readxl)
>
>
>
> files <- list.files(pattern="*.xls", full.names = FALSE)
>
>
>
> # Extract Work Order
>
> WO <- lapply(files, read_excel, sheet="Sheet1", range=("B9")) WO_list 
> <-
> as.data.frame(WO) trans_WO <- t(WO_list) write.table(trans_WO 
> ,"WO.txt")
>
>
>
> # Extract bubble 14_1
>
> BUBBLE_14_1 <- lapply(files, read_excel, sheet="Sheet1", 
> range=("c46")) BUBBLE_14_1_list <- as.data.frame(BUBBLE_14_1)
>
> trans_BUBBLE_14_1 <- t(BUBBLE_14_1_list)
>
>
>
> write.table(trans_BUBBLE_14_1,"BUBBLE_14_1.txt")
>
>
>
>
>
> # Extract bubble 14_2
>
> BUBBLE_14_2 <- lapply(files, read_excel, sheet="Sheet1", 
> range=("c62")) BUBBLE_14_2_list <- as.data.frame(BUBBLE_14_2)
>
> trans_BUBBLE_14_2 <- t(BUBBLE_14_2_list)
>
> write.table(trans_BUBBLE_14_2,"BUBBLE_14_2.txt")
>
>
>
> After the text files have been created, I cut and paste the contents 
> of
each
> text file to Excel.
>
> This has worked fine if the number of cells I am extracting from a 
> file is
small.
>
> If the number gets larger, this method is inefficient.
>
>
>
> Any advice on how to do this would be appreciated.
>
>
>
> All the best,
>
>
>
> Thomas Subia
>
>
>   [[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] paran package - error message

2020-08-26 Thread Rui Barradas

Hello,

Inline.

Às 09:00 de 26/08/20, PIKAL Petr escreveu:

Hi

IS is data frame so it is not numeric.

try str(IS) to see structure of your data.
maybe just

mat.IS <- as.matrix(IS)

gives you desired result, but it depends on (undisclosed) IS structure

BTW, do not use html formatting, it is useless in this list

BTW2, you should spend at least few minutes to read basic docs, kindly
offered by R-core in doc directory, especially R-intro which gives you quick
info about objects and their properties.

BTW3, your read.table is lacking header and sep and maybe dec specification
so I doubt it reads your data properly.


Since the file is a csv file (or at least its extension is) read.csv 
should solve those issues.


To the OP: read.csv is a way to call read.table but deliberately made 
inflexible. It sets some arguments to values other than their defaults, 
including


header = TRUE
sep = ","
fill = TRUE

The default dec = "," is the same. If you are reading files coming from 
countries like mine where the decimal separator is a comma read.csv2 
sets the values sep = ";" and dec = ",".


Read help("read.csv"), the difference from read.table is well explained.


Hope this helps,

Rui Barradas


Cheers
Petr


-Original Message-
From: R-help  On Behalf Of Lee, Deborah
Sent: Monday, August 24, 2020 12:52 PM
To: r-help@r-project.org
Subject: [R] paran package - error message

I am trying to using the "paran" package in R for Horn's parallel

analysis.

According to the "paran" manual, the highlighted yellow ought to be a
numerical matrix or data frame. It looks like this should be the file

name. Is

there something that I need to do

install.packages("paran")
library(paran)

IS<- read.table ("C:/Users/Deborah Lee/Documents/R/IS.csv") paran(IS,
cfa=TRUE, graph=TRUE, color=TRUE, col=c("black", "red", "blue"))

When I run the code above, I get the error message below.
in cor(x) : 'x' must be numeric

How do I set up my data (csv) file itself to make this a numerical matrix?

(FYI:

row 1 for headers for variables names).

Thank you for your help.


Deborah D. Lee, PhD
Associate Director of Student Affairs Research and Assessment The
Pennsylvania State University

105 White Building
University Park, PA 16802
(814) 863-9609


[[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-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] Error computing mlogit model

2020-08-26 Thread Jim Lemon
Hi Eric,
There are a few mysteries in your request. As we don't know what "des"
is, it is difficult to see why it does not have the correct number of
dimensions. It looks like it should be an n x 6 matrix, but is that
what it really is and does the mlogit function expect such a matrix?

JIm

On Wed, Aug 26, 2020 at 6:09 PM Nyarko Eric  wrote:
>
> Hi
>
>
>
> Please, I get this error message “Error in data[theorder, ] : incorrect
> number of dimensions” when I run the mlogit model presented below.
>
>
>
> Best regards,
>
> Eric
>
>
>
>
>
> library(mlogit)
>
> library(idefix)
>
> idefix.data *<- *aggregate_design
>
> idefix.data
>
> des *<- *as.matrix(idefix.data[, 3*:*8], ncol = 6)
>
> des
>
> y *<- *idefix.data[, 9]
>
> y
>
>
>
> mlogit.data *<- *Datatrans(pkg = "mlogit", des = des, y = y,
>
> n.alts = 2, n.sets = 8, n.resp = 7, bin = TRUE)
>
>
>
> gh3aP <- mlogit(y ~ -1 + par.1 +par.2 +par.3 +par.4+ par.5 +par.6, data =
> des)
>
> [[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] Help on plot from transition matrix

2020-08-26 Thread Jim Lemon
Hi Luis,
I had a quick look at the "diagram" package, which seems to accept
transition matrices. I don't have it installed, but the help pages are
fairly easy to follow and may do the job for you.

Jim

On Wed, Aug 26, 2020 at 5:50 PM Luis Fernando García
 wrote:
>
> Dear all,
>
>  I am wanting to make a flow diagram like the one attached as an example
> for the given dataset (
> https://drive.google.com/file/d/1CdtcJ5g6bp6jEoY7P6dKxO1mZWLEFZX7/view?usp=sharing
> ).
>
> The idea is to plot a flow diagram using the probabilities given by a
> transition matrix like the displayed in the example below. I have found
> some tools like DiagrammeR which might work for this purpose, but it works
> by introducing values manually. I wanted to know if there exists any
> package able to plot automatically the flow diagram, given the transition
> probabilities.
>
> Thanks in advance.
>
> ###
>
> library(TraMineR)
>
> h2a=c("Q-X-Q-Y-W-Z-P")
>
> h3a=c("Q-X-Q-Y-W-Z-P-Q-M-P-Q-A")
>
> h4a=c("Q-X-Q-X-Q-X-Q-Y-W-Z-C-B-Q-M-B-Q-A")
>
> h6a=c("Q-X-Q-X-Q-Y-W-Z-P-Q-P-Q-M-Q-A")
>
> h7a=c("Q-Y-W-Z-P-Q-B-Q-M-A")
>
> h8a=c("Q-Y-W-Z-P-B-Q-M-Q-A")
>
> h9a=c("Q-X-Q-W-Z-B-Q-A")
>
> h10a=c("Q-Y-W-Z-Q-A")
>
> h11a=c("Q-Y-W-Z-B-Q-P-B-Q-M-A")
>
> h12a=c("Q-W-Z-B-P-Q-A")
>
> h13a=c("Q-X-Q-Y-W-Z-P-Q-A")
>
> h14a=c("Q-X-B-X-Q-X-B-Q-X-Q-X-Q-Y-W-Z-B-P-B-Q-A")
>
> h15a=c("Q-X-Y-W-Z-B-P-Q-B-Q-A")
>
> h16a=c("Q-X-Q-B-Q-X-B-X-Q-Y-W-Z-P-B-Q-A")
>
> h17a=c("Q-X-Q-X-B-X-Q-W-Z-P-B-P-Q-A")
>
> h18a=c("Q-Y-W-Z-B-P-Q-B-Q-P-Q-M-B-P-A")
>
> h19a=c("Q-W-Z-B-P-Q-P-Q-M-Q-A")
>
> a=c(h2a,h3a,h4a,h6a,h7a,h8a,h9a,h10a,h11a,h12a,h13a,h14a,h15a,h16a,h17a,h18a,h19a)
>
> a
>
> library(TraMineR)
>
> i1=seqdef(c(h2a,h3a,h4a,h6a,h7a,h8a,h9a,h10a,h11a,h12a,h13a,h14a,h15a,h16a,h17a,h18a,h19a))
>
> seqtrate(i1)
>
> [[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] paran package - error message

2020-08-26 Thread Lee, Deborah
Thank you very much. I appreciate your help! 

Deborah D. Lee, PhD
Associate Director of Student Affairs Research and Assessment
The Pennsylvania State University

105 White Building
University Park, PA 16802
(814) 863-9609

-Original Message-
From: PIKAL Petr  
Sent: Wednesday, August 26, 2020 4:01 AM
To: Lee, Deborah ; r-help@r-project.org
Subject: RE: paran package - error message

Hi

IS is data frame so it is not numeric.

try str(IS) to see structure of your data.
maybe just

mat.IS <- as.matrix(IS)

gives you desired result, but it depends on (undisclosed) IS structure

BTW, do not use html formatting, it is useless in this list

BTW2, you should spend at least few minutes to read basic docs, kindly
offered by R-core in doc directory, especially R-intro which gives you quick
info about objects and their properties.

BTW3, your read.table is lacking header and sep and maybe dec specification
so I doubt it reads your data properly.

Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of Lee, Deborah
> Sent: Monday, August 24, 2020 12:52 PM
> To: r-help@r-project.org
> Subject: [R] paran package - error message
> 
> I am trying to using the "paran" package in R for Horn's parallel
analysis.
> According to the "paran" manual, the highlighted yellow ought to be a
> numerical matrix or data frame. It looks like this should be the file
name. Is
> there something that I need to do
> 
> install.packages("paran")
> library(paran)
> 
> IS<- read.table ("C:/Users/Deborah Lee/Documents/R/IS.csv") paran(IS,
> cfa=TRUE, graph=TRUE, color=TRUE, col=c("black", "red", "blue"))
> 
> When I run the code above, I get the error message below.
> in cor(x) : 'x' must be numeric
> 
> How do I set up my data (csv) file itself to make this a numerical matrix?
(FYI:
> row 1 for headers for variables names).
> 
> Thank you for your help.
> 
> 
> Deborah D. Lee, PhD
> Associate Director of Student Affairs Research and Assessment The
> Pennsylvania State University
> 
> 105 White Building
> University Park, PA 16802
> (814) 863-9609
> 
> 
>   [[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] readxl question

2020-08-26 Thread PIKAL Petr
Hi


Are you sure that your command read values from respective cells?

I tried it and got empty data frame with names 
> WO <- lapply(files, read_excel, sheet=1, range=("B3")) 
> as.data.frame(WO)
[1] ano TP303   X96
[4] X0  X3.7518 X26.7  
<0 rows> (or 0-length row.names)

To get data, col_names argument should be set to FALSE
WO <- lapply(files, read_excel, sheet=1, range=("B3"), col_names=FALSE)
WO2 <- lapply(files, read_excel, sheet=1, range=("B5"), col_names=FALSE)

After that unlist and one rbind together with t should be enough to give you
one table
WO <- unlist(WO)
WO2 <- unlist(WO2)
result <- t(rbind(WO, WO2))
result
 WO  WO2   
...1 "ano"   "ano" 
...1 "TP303" "261119/2"
...1 "96""288" 
...1 "0" "192" 
...1 "3.752" "25.92094"
...1 "26.7"  "38.6"
>

And instead txt document you could do

write.table(result, "result.xls", sep = "\t", row.names = F)

And now "result.xls" is directly readable with Excel

Cheers
Petr

>
> -Original Message-
> From: R-help  On Behalf Of Thomas Subia via
> R-help
> Sent: Saturday, August 22, 2020 6:25 AM
> To: r-help@r-project.org
> Subject: [R] readxl question
> 
> Colleagues,
> 
> 
> 
> I have 250 Excel files in a directory. Each of those files has the same
layout.
> The problem is that the data in each Excel data is not in rectangular
form. I've
> been using readxl to extract the data which I need.
> Each of my metrics are stored in a particular cell. For each metric, I
create text
> files which stores my metrics.
> 
> 
> 
> library(plyr)
> 
> library(readxl)
> 
> 
> 
> files <- list.files(pattern="*.xls", full.names = FALSE)
> 
> 
> 
> # Extract Work Order
> 
> WO <- lapply(files, read_excel, sheet="Sheet1", range=("B9")) WO_list <-
> as.data.frame(WO) trans_WO <- t(WO_list) write.table(trans_WO ,"WO.txt")
> 
> 
> 
> # Extract bubble 14_1
> 
> BUBBLE_14_1 <- lapply(files, read_excel, sheet="Sheet1", range=("c46"))
> BUBBLE_14_1_list <- as.data.frame(BUBBLE_14_1)
> 
> trans_BUBBLE_14_1 <- t(BUBBLE_14_1_list)
> 
> 
> 
> write.table(trans_BUBBLE_14_1,"BUBBLE_14_1.txt")
> 
> 
> 
> 
> 
> # Extract bubble 14_2
> 
> BUBBLE_14_2 <- lapply(files, read_excel, sheet="Sheet1", range=("c62"))
> BUBBLE_14_2_list <- as.data.frame(BUBBLE_14_2)
> 
> trans_BUBBLE_14_2 <- t(BUBBLE_14_2_list)
> 
> write.table(trans_BUBBLE_14_2,"BUBBLE_14_2.txt")
> 
> 
> 
> After the text files have been created, I cut and paste the contents of
each
> text file to Excel.
> 
> This has worked fine if the number of cells I am extracting from a file is
small.
> 
> If the number gets larger, this method is inefficient.
> 
> 
> 
> Any advice on how to do this would be appreciated.
> 
> 
> 
> All the best,
> 
> 
> 
> Thomas Subia
> 
> 
>   [[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] paran package - error message

2020-08-26 Thread PIKAL Petr
Hi

IS is data frame so it is not numeric.

try str(IS) to see structure of your data.
maybe just

mat.IS <- as.matrix(IS)

gives you desired result, but it depends on (undisclosed) IS structure

BTW, do not use html formatting, it is useless in this list

BTW2, you should spend at least few minutes to read basic docs, kindly
offered by R-core in doc directory, especially R-intro which gives you quick
info about objects and their properties.

BTW3, your read.table is lacking header and sep and maybe dec specification
so I doubt it reads your data properly.

Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of Lee, Deborah
> Sent: Monday, August 24, 2020 12:52 PM
> To: r-help@r-project.org
> Subject: [R] paran package - error message
> 
> I am trying to using the "paran" package in R for Horn's parallel
analysis.
> According to the "paran" manual, the highlighted yellow ought to be a
> numerical matrix or data frame. It looks like this should be the file
name. Is
> there something that I need to do
> 
> install.packages("paran")
> library(paran)
> 
> IS<- read.table ("C:/Users/Deborah Lee/Documents/R/IS.csv") paran(IS,
> cfa=TRUE, graph=TRUE, color=TRUE, col=c("black", "red", "blue"))
> 
> When I run the code above, I get the error message below.
> in cor(x) : 'x' must be numeric
> 
> How do I set up my data (csv) file itself to make this a numerical matrix?
(FYI:
> row 1 for headers for variables names).
> 
> Thank you for your help.
> 
> 
> Deborah D. Lee, PhD
> Associate Director of Student Affairs Research and Assessment The
> Pennsylvania State University
> 
> 105 White Building
> University Park, PA 16802
> (814) 863-9609
> 
> 
>   [[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 computing mlogit model

2020-08-26 Thread Nyarko Eric
Hi



Please, I get this error message “Error in data[theorder, ] : incorrect
number of dimensions” when I run the mlogit model presented below.



Best regards,

Eric





library(mlogit)

library(idefix)

idefix.data *<- *aggregate_design

idefix.data

des *<- *as.matrix(idefix.data[, 3*:*8], ncol = 6)

des

y *<- *idefix.data[, 9]

y



mlogit.data *<- *Datatrans(pkg = "mlogit", des = des, y = y,

n.alts = 2, n.sets = 8, n.resp = 7, bin = TRUE)



gh3aP <- mlogit(y ~ -1 + par.1 +par.2 +par.3 +par.4+ par.5 +par.6, data =
des)

[[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 on plot from transition matrix

2020-08-26 Thread Luis Fernando García
Dear all,

 I am wanting to make a flow diagram like the one attached as an example
for the given dataset (
https://drive.google.com/file/d/1CdtcJ5g6bp6jEoY7P6dKxO1mZWLEFZX7/view?usp=sharing
).

The idea is to plot a flow diagram using the probabilities given by a
transition matrix like the displayed in the example below. I have found
some tools like DiagrammeR which might work for this purpose, but it works
by introducing values manually. I wanted to know if there exists any
package able to plot automatically the flow diagram, given the transition
probabilities.

Thanks in advance.

###

library(TraMineR)

h2a=c("Q-X-Q-Y-W-Z-P")

h3a=c("Q-X-Q-Y-W-Z-P-Q-M-P-Q-A")

h4a=c("Q-X-Q-X-Q-X-Q-Y-W-Z-C-B-Q-M-B-Q-A")

h6a=c("Q-X-Q-X-Q-Y-W-Z-P-Q-P-Q-M-Q-A")

h7a=c("Q-Y-W-Z-P-Q-B-Q-M-A")

h8a=c("Q-Y-W-Z-P-B-Q-M-Q-A")

h9a=c("Q-X-Q-W-Z-B-Q-A")

h10a=c("Q-Y-W-Z-Q-A")

h11a=c("Q-Y-W-Z-B-Q-P-B-Q-M-A")

h12a=c("Q-W-Z-B-P-Q-A")

h13a=c("Q-X-Q-Y-W-Z-P-Q-A")

h14a=c("Q-X-B-X-Q-X-B-Q-X-Q-X-Q-Y-W-Z-B-P-B-Q-A")

h15a=c("Q-X-Y-W-Z-B-P-Q-B-Q-A")

h16a=c("Q-X-Q-B-Q-X-B-X-Q-Y-W-Z-P-B-Q-A")

h17a=c("Q-X-Q-X-B-X-Q-W-Z-P-B-P-Q-A")

h18a=c("Q-Y-W-Z-B-P-Q-B-Q-P-Q-M-B-P-A")

h19a=c("Q-W-Z-B-P-Q-P-Q-M-Q-A")

a=c(h2a,h3a,h4a,h6a,h7a,h8a,h9a,h10a,h11a,h12a,h13a,h14a,h15a,h16a,h17a,h18a,h19a)

a

library(TraMineR)

i1=seqdef(c(h2a,h3a,h4a,h6a,h7a,h8a,h9a,h10a,h11a,h12a,h13a,h14a,h15a,h16a,h17a,h18a,h19a))

seqtrate(i1)

[[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] Help on plot from transition matrix

2020-08-26 Thread Luis Fernando García
Thanks Jim,

I do not know what happened, I will try the question again.

Best

El lun., 24 ago. 2020 a las 5:47, Jim Lemon ()
escribió:

> Hi Luis,
> As so often happens, the image didn't make it. Try PNG or PDF format.
> Without seeing what you want, it's only guessing.
>
> Jim
>
> On Mon, Aug 24, 2020 at 6:34 PM Luis Fernando García
>  wrote:
> >
> > I am wanting to make a flow diagram like the one attached as an example
> for
> > the given dataset.
> >
> > The idea is to plot a flow diagramm using the probabilities given by a
> > transition matrix like the displayed in the example below. I have found
> > some tools like DiagrammeR which might work for this purpose, but it
> works
> > by introducing values manually. I wanted to know if there exists any
> > package able to plot automatically the flow diagram, given the transition
> > probabilities.
> >
> > Thanks in advance.
> >
> > ###
> >
> > library(TraMineR)
> >
> > h2a=c("Q-X-Q-Y-W-Z-P")
> >
> > h3a=c("Q-X-Q-Y-W-Z-P-Q-M-P-Q-A")
> >
> > h4a=c("Q-X-Q-X-Q-X-Q-Y-W-Z-C-B-Q-M-B-Q-A")
> >
> > h6a=c("Q-X-Q-X-Q-Y-W-Z-P-Q-P-Q-M-Q-A")
> >
> > h7a=c("Q-Y-W-Z-P-Q-B-Q-M-A")
> >
> > h8a=c("Q-Y-W-Z-P-B-Q-M-Q-A")
> >
> > h9a=c("Q-X-Q-W-Z-B-Q-A")
> >
> > h10a=c("Q-Y-W-Z-Q-A")
> >
> > h11a=c("Q-Y-W-Z-B-Q-P-B-Q-M-A")
> >
> > h12a=c("Q-W-Z-B-P-Q-A")
> >
> > h13a=c("Q-X-Q-Y-W-Z-P-Q-A")
> >
> > h14a=c("Q-X-B-X-Q-X-B-Q-X-Q-X-Q-Y-W-Z-B-P-B-Q-A")
> >
> > h15a=c("Q-X-Y-W-Z-B-P-Q-B-Q-A")
> >
> > h16a=c("Q-X-Q-B-Q-X-B-X-Q-Y-W-Z-P-B-Q-A")
> >
> > h17a=c("Q-X-Q-X-B-X-Q-W-Z-P-B-P-Q-A")
> >
> > h18a=c("Q-Y-W-Z-B-P-Q-B-Q-P-Q-M-B-P-A")
> >
> > h19a=c("Q-W-Z-B-P-Q-P-Q-M-Q-A")
> >
> >
> a=c(h2a,h3a,h4a,h6a,h7a,h8a,h9a,h10a,h11a,h12a,h13a,h14a,h15a,h16a,h17a,h18a,h19a)
> >
> > a
> >
> > library(TraMineR)
> >
> >
> i1=seqdef(c(h2a,h3a,h4a,h6a,h7a,h8a,h9a,h10a,h11a,h12a,h13a,h14a,h15a,h16a,h17a,h18a,h19a))
> >
> > seqtrate(i1)
> > __
> > 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 write an interface function for bootstrapping with clusterboot() in R?

2020-08-26 Thread Ja Müller via R-help
Dear all,
I am trying to write an interface function (CBI function) in order to use the 
bootstrapping function clusterboot() together with the clustering algorithm 
kmodes(). See here:

https://www.rdocumentation.org/packages/fpc/versions/2.2-7/topics/clusterboot
kmodes function | R Documentation
Has anyone already written interface functions for clusterboot() and can assist 
me or send me some example code for other interface functions for clusterboot()?

Please find my code below:   
   - I use the built-in dataset USArrests for the purpose of this minimal 
reproducible code only, which yields the same error message as when I use my 
actual data set.
   - mykmodesCBI = The name of the interface function I wish to create.
   - kmodes_boot10 = The result of the clusterboot() function using the 
interface function mykmodesCBI
   - I am getting the error message 'Error in matrix(0, nrow = c1$nc, ncol = B) 
:non-numeric matrix extent'
I have not found any assistance online so far, this is why I now turn to the 
R-help mailing list. Thank you in advance, any help is much appreciated!Julia

#--beginning of 
code 
snippet
library("fpc")
library("cluster")

data(USArrests)
mydata_example <- USArrests %>%
  na.omit() %>%  
  scale()

mykmodesCBI <- function(data, k) {
  result = kmodes(data, modes=k, iter.max = 50, weighted = FALSE ); 
  nc = n_distinct( kmodes(data, modes=k, iter.max = 50, weighted = FALSE 
)$cluster ) ; 
  clusterlist=  list( as.vector(lapply( kmodes(data, modes=1, iter.max = 50, 
weighted = FALSE )$cluster,function(x) if(x==1) {TRUE} else {FALSE} )),
  as.vector(lapply( kmodes(data, modes=2, iter.max = 50, 
weighted = FALSE )$cluster,function(x) if(x==2) {TRUE} else {FALSE} )),
  as.vector(lapply( kmodes(data, modes=3, iter.max = 50, 
weighted = FALSE )$cluster,function(x) if(x==3) {TRUE} else {FALSE} )),
  as.vector(lapply( kmodes(data, modes=4, iter.max = 50, 
weighted = FALSE )$cluster,function(x) if(x==5) {TRUE} else {FALSE} )),
  as.vector(lapply( kmodes(data, modes=5, iter.max = 50, 
weighted = FALSE )$cluster,function(x) if(x==5) {TRUE} else {FALSE} )),
  as.vector(lapply( kmodes(data, modes=6, iter.max = 50, 
weighted = FALSE )$cluster,function(x) if(x==6) {TRUE} else {FALSE} ))
)
  partition = as.vector(list( kmodes(data, modes=k, iter.max = 50, weighted = 
FALSE )$cluster )); 
  clustermethod = "kmodes"; 
  return( list( result, nc, clusterlist, partition, clustermethod ) )
}

kmodes_boot10 <- clusterboot(
data=mydata_example,  
B = 10,
distances=FALSE,
bootmethod = "boot",   
multipleboot = FALSE, 
clustermethod = mykmodesCBI, 
k = 6,   
seed = 123,   
datatomatrix=TRUE)   
kmodes_boot10#--end 
of code 
snippet



[[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] paran package - error message

2020-08-26 Thread Lee, Deborah
I am trying to using the "paran" package in R for Horn's parallel analysis. 
According to the "paran" manual, the highlighted yellow ought to be a numerical 
matrix or data frame. It looks like this should be the file name. Is there 
something that I need to do

install.packages("paran")
library(paran)

IS<- read.table ("C:/Users/Deborah Lee/Documents/R/IS.csv")
paran(IS, cfa=TRUE, graph=TRUE, color=TRUE, col=c("black", "red", "blue"))

When I run the code above, I get the error message below.
in cor(x) : 'x' must be numeric

How do I set up my data (csv) file itself to make this a numerical matrix? 
(FYI: row 1 for headers for variables names).

Thank you for your help.


Deborah D. Lee, PhD
Associate Director of Student Affairs Research and Assessment
The Pennsylvania State University

105 White Building
University Park, PA 16802
(814) 863-9609


[[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.