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

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

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

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

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

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")), ]

[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

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

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

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

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

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,

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

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

[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],

[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

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

[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

[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")