[R] Setting a class / outcome variable for Weka Principal Components Analysis
Hi everyone, I've relatively new to R, and i'm trying to use it to perform a Principal Components analysis (PCA) I've done this using WEKA previously, and now i'm trying to do so using R's prcomp and princomp (both options would work for me). One problem i've found is that while WEKA PCA allows us to specify a class / outcome variable / column for the dataset, apparently R project (both prcomp and princomp) don't. I've read through a number of documents including this http://cran.r-project.org/web/packages/HSAUR/vignettes/Ch_principal_components_analysis.pdf with limited success, so wanted to raise this question here. How does one set the class variable when performing a PCA ? Any advice would be greatly appreciated ! -- Best Regards, Suranga [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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] Standard variance / devistion clarification
Dear gurus, Im a newbie, and I want to ask a very general question. Assume that I have a set of numbers as follows, 1, 1, 2, 10, 100, 10,1 From these, I need to identify which number is the most different as compared to others. (in this case, it will be 100, since its way larger than the other numbers). It doesnt have to be specifically this way, but I need to identify which number(s) are most different compared to the others. Any idea as to what I need to do this ? Im a math noob, so I'm also going to need to ask it this is called 'standard deviation' or 'variance' :-) -- Best Regards, Suranga [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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] Standard variance / devistion clarification
On 2 Mar 2012 09:12, Suranga Kasthurirathne suranga...@gmail.com wrote: Hi, thank you very much for the advice. I'll try it out, and see where I can take it from there. @david, your point is noted. I will avoid such mails in the future. On 2 Mar 2012 04:27, Peter Ehlers ehl...@ucalgary.ca wrote: On 2012-03-01 13:52, John Kane wrote: No it's an outlier problem, I think. If you have a fairly small number of sets of these numbers simple visual inspection of a boxplot for each set would probably acomplish what you want. Try this in R for an example. Just paste the next two lines into R xx- c(1, 1, 2, 10, 100, 10,1) boxplot(xx) For graphical analysis, I would prefer plot(xx, type=h). But most different as compared to the others is not well-defined. Possibly something like scale(xx) would help. Peter Ehlers After this it gets more complicated, but it you're new here let's take it one step at a time John Kane Kingston ON Canada -Original Message- From: suranga...@gmail.com Sent: Thu, 1 Mar 2012 09:30:59 -0800 To: r-help@r-project.org Subject: [R] Standard variance / devistion clarification Dear gurus, Im a newbie, and I want to ask a very general question. Assume that I have a set of numbers as follows, 1, 1, 2, 10, 100, 10,1 From these, I need to identify which number is the most different as compared to others. (in this case, it will be 100, since its way larger than the other numbers). It doesnt have to be specifically this way, but I need to identify which number(s) are most different compared to the others. Any idea as to what I need to do this ? Im a math noob, so I'm also going to need to ask it this is called 'standard deviation' or 'variance' :-) -- Best Regards, Suranga [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/**posting-guide.htmlhttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __**__ Send your photos by email in seconds... TRY FREE IM TOOLPACK at http://www.imtoolpack.com/**default.aspx?rc=if3http://www.imtoolpack.com/default.aspx?rc=if3 Works in all emails, instant messengers, blogs, forums and social networks. __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html 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 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] Standard variance / devistion clarification
Hi, thank you very much for the advice. I'll try it out, and see where I can take it from there. @david, your point is noted. I will avoid such mails in the future. On Fri, Mar 2, 2012 at 4:57 AM, Peter Ehlers ehl...@ucalgary.ca wrote: On 2012-03-01 13:52, John Kane wrote: No it's an outlier problem, I think. If you have a fairly small number of sets of these numbers simple visual inspection of a boxplot for each set would probably acomplish what you want. Try this in R for an example. Just paste the next two lines into R xx- c(1, 1, 2, 10, 100, 10,1) boxplot(xx) For graphical analysis, I would prefer plot(xx, type=h). But most different as compared to the others is not well-defined. Possibly something like scale(xx) would help. Peter Ehlers After this it gets more complicated, but it you're new here let's take it one step at a time John Kane Kingston ON Canada -Original Message- From: suranga...@gmail.com Sent: Thu, 1 Mar 2012 09:30:59 -0800 To: r-help@r-project.org Subject: [R] Standard variance / devistion clarification Dear gurus, Im a newbie, and I want to ask a very general question. Assume that I have a set of numbers as follows, 1, 1, 2, 10, 100, 10,1 From these, I need to identify which number is the most different as compared to others. (in this case, it will be 100, since its way larger than the other numbers). It doesnt have to be specifically this way, but I need to identify which number(s) are most different compared to the others. Any idea as to what I need to do this ? Im a math noob, so I'm also going to need to ask it this is called 'standard deviation' or 'variance' :-) -- Best Regards, Suranga [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/**posting-guide.htmlhttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __**__ Send your photos by email in seconds... TRY FREE IM TOOLPACK at http://www.imtoolpack.com/**default.aspx?rc=if3http://www.imtoolpack.com/default.aspx?rc=if3 Works in all emails, instant messengers, blogs, forums and social networks. __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Best Regards, Suranga [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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 advice for a poLCA newbie
Hi everyone / poLCA gurus, I'm facing a problem regarding conditional dependence and poLCA. Using a few data sets composed of only 1's and 2's, i'm able to do a latent class analysis for independent data columns using poLCA. The commands I use to do this are something like, bcs = read.csv(data.csv, header=T); response = data.frame(bcs[0:5]); names(response) attach(response) f = cbind(A,B,C,D,E)~1 poLCA(f,data=response, nclass=2); However, my question is, how must I modify this for conditional dependence ? assuming that some columns are dependent or each other, and that instead of just 1 and 2, dependent columns have been merged and may bear values 1,2,3 or 4, how should I modify the above command for latent class analysis ? Please advice... -- Thanks and Best Regards, Suranga [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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] poLCA and conditional dependence
Hi everyone / poLCA gurus, I'm facing a problem regarding conditional dependence and poLCA. Using a few data sets composed of only 1's and 2's, i'm able to do a latent class analysis for independent data columns using poLCA. The commands I use to do this are something like, bcs = read.csv(data.csv, header=T); response = data.frame(bcs[0:5]); names(response) attach(response) f = cbind(A,B,C,D,E)~1 poLCA(f,data=response, nclass=2); However, my question is, how must I modify this for conditional dependence ? assuming that some columns are dependent or each other, and that instead of just 1 and 2, dependent columns have been merged and may bear values 1,2,3 or 4, how should I modify the above command for latent class analysis ? Please advice... -- Thanks and Best Regards, Suranga [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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] Writing output into a file
Hi everyone, I tried writing this data into a file using the save(myList, file=test1.bin) command, but unfortunately, the numerical values seem to get garbled when I do so. The numbers in my RGui look like 0, 0.5, 0, 1 etc. etc. But when I stored it into a .bin file, and retrieved it using java code, it returns data such as, 2272919233031569408 1701436416123530 -2278152494445862686 7161955281552955800 Etc. etc. I also tried the second method (using a # Open a file connection) Unfortunately, here too the data gets extremely garbled. Has anyone faced such a situation before? Any help / comments / useful links would be much appreciated Thanks and best regards, Suranga On Mon, Feb 13, 2012 at 10:37 AM, Suranga Kasthurirathne suranga...@gmail.com wrote: Hi, Thank you very much for sharing these ideas. I really appreciate them. Let me go try them out :-) On Mon, Feb 13, 2012 at 4:37 AM, Rui Barradas rui1...@sapo.pt wrote: Hello One way is # Write the file save(myList, file=test1.bin) # Reload the data, under the same name, 'myList' load(file=test1.bin) Another way is a bit more complicated # Open a file connection and write the list to it (using comma as separator) fileCon - file(test2.txt, open=wt) lapply(myList, function(x) writeLines(paste(x, collapse=,), con=fileCon)) close(fileCon) # Load the data, maybe under another name strsplit(readLines(con=test2.txt), split=,) If you use the first method, the list is retrieved as it was. If you use the second, you lose the list's members' names. Hope this helps, Rui Barradas -- View this message in context: http://r.789695.n4.nabble.com/Writing-output-into-a-file-tp4382243p4382310.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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. -- Best Regards, Suranga -- Best Regards, Suranga -- Best Regards, Suranga [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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] Retrieve by Id from an R list
Hi everyone, I'm using the poLCA module for some analysis work. Basically, Im using the command poLCA(f, data=response,nclass=2) This returns a poLCA object (a list) From this data, I need to retrieve certain indexes, such as[[5]] as seen below. [[5]] Pr(1) Pr(2) Pr(3) class 1: 01.00.0 class 2: 00.50.5 1) The structure shown in [[5]] above is a matrix, isn't it ? 2) how can I specifically retrieve this matrix (retrieve by ID, I guess) ? Any help / suggestions or helpful links would be very much welcome :-) -- Thanks and Best Regards, Suranga [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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] Writing output into a file
Hi, many thanks for the reply. I really appreciate it. Since I'm still very new to R, I think I should take some time to research what you suggested. (I don't want to keep posting basic questions to the list all the time) But still, thank you so much for being helpful... On Mon, Feb 13, 2012 at 7:23 PM, Rui Barradas rui1...@sapo.pt wrote: Hello, I tried writing this data into a file using the save(myList, file=test1.bin) command, but unfortunately, the numerical values seem to get garbled when I do so. The numbers in my RGui look like 0, 0.5, 0, 1 etc. etc. But when I stored it into a .bin file, and retrieved it using java code, it returns data such as, The problem should be in the use of java, 'save' uses a R format , RDA. You can use 'ascii=TRUE'and see it with a text editor. Also see ?save I also tried the second method (using a # Open a file connection) Unfortunately, here too the data gets extremely garbled. Don't understand why, check the output file with a text editor and let us know what is wrong. The problem I've seen is that the use of 'strsplit' coerses the numeric data to character, but this is easy to solve. Does your list have sub-lists? Rui Barradas -- View this message in context: http://r.789695.n4.nabble.com/Writing-output-into-a-file-tp4382243p4383741.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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. -- Best Regards, Suranga [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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] Writing output into a file
Hi everyone, I'm an R newbie working with the poLCA module. I achieved my target without having to bother anyone, but It seems that I've got stuck at the last minute. My problem is simple. I need to write my results into a file. My results are in the shape of a list (unbalanced columns) I've considered several methods (sink(), write.file) etc. etc. Unfortunately, I'm not the best brains in the market on this subject. I've also faced some difficulty in converting the list so that it can be written using write.file(). Therefore, I'm wondering if anyone can point me towards a good example that shows me how to write a list into a file safely. -- Thanks and Best Regards, Suranga [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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] Writing output into a file
Hi, Thank you very much for sharing these ideas. I really appreciate them. Let me go try them out :-) On Mon, Feb 13, 2012 at 4:37 AM, Rui Barradas rui1...@sapo.pt wrote: Hello One way is # Write the file save(myList, file=test1.bin) # Reload the data, under the same name, 'myList' load(file=test1.bin) Another way is a bit more complicated # Open a file connection and write the list to it (using comma as separator) fileCon - file(test2.txt, open=wt) lapply(myList, function(x) writeLines(paste(x, collapse=,), con=fileCon)) close(fileCon) # Load the data, maybe under another name strsplit(readLines(con=test2.txt), split=,) If you use the first method, the list is retrieved as it was. If you use the second, you lose the list's members' names. Hope this helps, Rui Barradas -- View this message in context: http://r.789695.n4.nabble.com/Writing-output-into-a-file-tp4382243p4382310.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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. -- Best Regards, Suranga [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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] poLCA and conditional dependence
Dear all, I'm an Sri Lankan undergraduate student. I'm also a total newbie to R. My aim is to use the poLCA package to do a latent class analysis. I found the documentation very helpful, but need to make a small clarification that has stumped me awhile. In my work, I need to make provision for conditional dependence. I'm told that poLCA lets you do that. Unfortunately, I couldn't find a specific example on how to do this. However, I did find a reference to latent class regression using cbind(Y1,Y2,Y3)~X1+X2*X3 etc. Forgive my ignorance, but is this the same as conditional dependence ? I dont think so -- Best Regards, Suranga [[alternative HTML version deleted]] __ R-help@r-project.org mailing list 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.