From jens.knispel at web.de Thu Mar 9 14:53:19 2017 From: jens.knispel at web.de (JayKay) Date: Thu, 9 Mar 2017 05:53:19 -0800 (PST) Subject: [datatable-help] Best approach to store data for R usage Message-ID: <1489067599851-4729528.post@n4.nabble.com> Dear community, I am having several pen-and-paper survey questionnaires which I want to process using R. Is there any recommendation which data entry program offers best advantages for data storage? Generally, I can use Excel or SPSS for data entry, but I want to know whether there is a better approach (e.g. for pre-preparing variable types during data entry, etc.). I am aware of the fact that R has many possibilities to import data. Thanks a lot in advance JayKay -- View this message in context: http://r.789695.n4.nabble.com/Best-approach-to-store-data-for-R-usage-tp4729528.html Sent from the datatable-help mailing list archive at Nabble.com. From nguyentuan393 at gmail.com Sun Mar 12 04:49:46 2017 From: nguyentuan393 at gmail.com (tuan173) Date: Sat, 11 Mar 2017 19:49:46 -0800 (PST) Subject: [datatable-help] Help coding Message-ID: <1489290586093-4729632.post@n4.nabble.com> Dear All, I am new to R, and trying to learn it. I need help with some coding. I have tried to make it, but it did not word. I have a data similar to this I want to make a table And then fill the table with the values in the dataframe My real data is much bigger than the example. I need advice to code for making a table, and then fill in the table. Thank you very much, Tuan -- View this message in context: http://r.789695.n4.nabble.com/Help-coding-tp4729632.html Sent from the datatable-help mailing list archive at Nabble.com. From serdar.akin at paylevo.com Sun Mar 12 09:51:15 2017 From: serdar.akin at paylevo.com (Serdar Akin) Date: Sun, 12 Mar 2017 09:51:15 +0100 Subject: [datatable-help] Help coding In-Reply-To: <1489290586093-4729632.post@n4.nabble.com> References: <1489290586093-4729632.post@n4.nabble.com> Message-ID: <6f890cc6-c511-edcf-0be2-db75a63ab444@paylevo.com> Hi, I would do something like this: ## Create the table DT <- data.table(colour = rep(c("red", "blue", "green"), each= 3), type = paste0('type', 1:3), value = as.integer( rnorm(9, mean= 6, sd = 5))) # Cast table and make it a contingence table DT1 <- dcast.data.table(DT, colour ~ type, value.var = 'value', FUN = function(x) sum(x, na.rm = TRUE)) Den 12/03/17 kl. 04:49, skrev tuan173: > Dear All, > I am new to R, and trying to learn it. > I need help with some coding. I have tried to make it, but it did not word. > I have a data similar to this > > I want to make a table > > And then fill the table with the values in the dataframe > > My real data is much bigger than the example. > I need advice to code for making a table, and then fill in the table. > Thank you very much, > Tuan > > > > > -- > View this message in context: http://r.789695.n4.nabble.com/Help-coding-tp4729632.html > Sent from the datatable-help mailing list archive at Nabble.com. > _______________________________________________ > datatable-help mailing list > datatable-help at lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help From bioglp at gmail.com Fri Mar 17 11:33:14 2017 From: bioglp at gmail.com (glaporta) Date: Fri, 17 Mar 2017 03:33:14 -0700 (PDT) Subject: [datatable-help] reorder data frame columns (not manually) Message-ID: <1489746794385-4729802.post@n4.nabble.com> Hi, is it possible to reorder (not manually) the data frame columns on the basis of their value? Thanks, Gianandrea xxx <- data.frame(matrix(runif(8), ncol=8)) -- View this message in context: http://r.789695.n4.nabble.com/reorder-data-frame-columns-not-manually-tp4729802.html Sent from the datatable-help mailing list archive at Nabble.com. From manabu.sakamoto at gmail.com Fri Mar 17 11:42:07 2017 From: manabu.sakamoto at gmail.com (Manabu Sakamoto) Date: Fri, 17 Mar 2017 10:42:07 +0000 Subject: [datatable-help] reorder data frame columns (not manually) In-Reply-To: <1489746794385-4729802.post@n4.nabble.com> References: <1489746794385-4729802.post@n4.nabble.com> Message-ID: I don't think this is a data.table specific question, but you can use order: dt[order(V), ] for data.table object... or df[order(df$V), ] for data.frame object On 17 March 2017 at 10:33, glaporta wrote: > Hi, > is it possible to reorder (not manually) the data frame columns on the > basis > of their value? > Thanks, > Gianandrea > > xxx <- data.frame(matrix(runif(8), ncol=8)) > > > > -- > View this message in context: http://r.789695.n4.nabble.com/ > reorder-data-frame-columns-not-manually-tp4729802.html > Sent from the datatable-help mailing list archive at Nabble.com. > _______________________________________________ > datatable-help mailing list > datatable-help at lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/ > listinfo/datatable-help > -- Manabu Sakamoto, PhD manabu.sakamoto at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From bioglp at gmail.com Fri Mar 17 11:41:19 2017 From: bioglp at gmail.com (glaporta) Date: Fri, 17 Mar 2017 03:41:19 -0700 (PDT) Subject: [datatable-help] reorder data frame columns (not manually) In-Reply-To: References: <1489746794385-4729802.post@n4.nabble.com> Message-ID: <1489747279279-4729804.post@n4.nabble.com> Hi, thank you for your quick reply. I don't want to order the values on a specific column. For a single row data frame, I want to rearrange the position of the columns: from X1, X2, X3, ... to X2, X3, X1 on the basis of their values. Cheers -- View this message in context: http://r.789695.n4.nabble.com/reorder-data-frame-columns-not-manually-tp4729802p4729804.html Sent from the datatable-help mailing list archive at Nabble.com. From bioglp at gmail.com Fri Mar 17 12:09:12 2017 From: bioglp at gmail.com (glaporta) Date: Fri, 17 Mar 2017 04:09:12 -0700 (PDT) Subject: [datatable-help] reorder data frame columns (not manually) In-Reply-To: <1489747279279-4729804.post@n4.nabble.com> References: <1489746794385-4729802.post@n4.nabble.com> <1489747279279-4729804.post@n4.nabble.com> Message-ID: <1489748952123-4729805.post@n4.nabble.com> > If you've only got a single row like in your example, can you not transpose it first and reorder the column on the transposed data.frame object? Thank you Manabu, I can't transpose for my real project, but the solution is xxx[,order(xxx)] -- View this message in context: http://r.789695.n4.nabble.com/reorder-data-frame-columns-not-manually-tp4729802p4729805.html Sent from the datatable-help mailing list archive at Nabble.com. From 743642404 at qq.com Fri Mar 17 12:39:09 2017 From: 743642404 at qq.com (white1551) Date: Fri, 17 Mar 2017 04:39:09 -0700 (PDT) Subject: [datatable-help] Error : incorrect number of dimensions Message-ID: <1489750749001-4729807.post@n4.nabble.com> Hi all, I tried to run the following code, but at the end it says 'Error in k[, 1] : incorrect number of dimensions'. I just copy-paste this code and have no experience on programming. Can any one tell me what's wrong and how to fix it? Thanks in advance! *x <- rbinom(1000, 8, 0.5) y <- rbinom(1000, 8, 0.5) k <- c(rep(0:8, times=9), rep(0:8, each=9)) K <- matrix(k, ncol = 2, byrow = FALSE) z <- k[, 1] + k[, 2] cdf <- rep(0.0, times = 81) for(i in 1:81) {cdf[i] <- sum(x+y <= z[i])/1000} scatterplot3d(k[, 1], k[, 2], cdf, highlight.3d = TRUE, col.axis = 'blue', mian='Plotting bivariate CDF', pch = 20, ylab = 'values of y', xlab = 'values of x', zlab = 'CDF of x+y')* -- View this message in context: http://r.789695.n4.nabble.com/Error-incorrect-number-of-dimensions-tp4729807.html Sent from the datatable-help mailing list archive at Nabble.com. From jholtman at gmail.com Fri Mar 17 13:09:22 2017 From: jholtman at gmail.com (jim holtman) Date: Fri, 17 Mar 2017 08:09:22 -0400 Subject: [datatable-help] Error : incorrect number of dimensions In-Reply-To: <1489750749001-4729807.post@n4.nabble.com> References: <1489750749001-4729807.post@n4.nabble.com> Message-ID: I think you meant: z <- K[,1] + K[,2] The capital "K" is the matrix, not the lower case "k". Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Fri, Mar 17, 2017 at 7:39 AM, white1551 <743642404 at qq.com> wrote: > Hi all, > > I tried to run the following code, but at the end it says 'Error in k[, 1] > : > incorrect number of dimensions'. I just copy-paste this code and have no > experience on programming. Can any one tell me what's wrong and how to fix > it? Thanks in advance! > > *x <- rbinom(1000, 8, 0.5) > y <- rbinom(1000, 8, 0.5) > > k <- c(rep(0:8, times=9), rep(0:8, each=9)) > K <- matrix(k, ncol = 2, byrow = FALSE) > z <- k[, 1] + k[, 2] > > cdf <- rep(0.0, times = 81) > > for(i in 1:81) {cdf[i] <- sum(x+y <= z[i])/1000} > > scatterplot3d(k[, 1], k[, 2], cdf, highlight.3d = TRUE, col.axis = 'blue', > mian='Plotting bivariate CDF', pch = 20, ylab = 'values of > y', > xlab = 'values of x', > zlab = 'CDF of x+y')* > > > > -- > View this message in context: http://r.789695.n4.nabble.com/ > Error-incorrect-number-of-dimensions-tp4729807.html > Sent from the datatable-help mailing list archive at Nabble.com. > _______________________________________________ > datatable-help mailing list > datatable-help at lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/ > listinfo/datatable-help > -------------- next part -------------- An HTML attachment was scrubbed... URL: From 743642404 at qq.com Fri Mar 17 13:09:27 2017 From: 743642404 at qq.com (white1551) Date: Fri, 17 Mar 2017 05:09:27 -0700 (PDT) Subject: [datatable-help] Error : incorrect number of dimensions In-Reply-To: References: <1489750749001-4729807.post@n4.nabble.com> Message-ID: <1489752567377-4729811.post@n4.nabble.com> Thanks a lot Jim! It works. I should have been more careful and try to get used to the whole bunch of codes. -- View this message in context: http://r.789695.n4.nabble.com/Error-incorrect-number-of-dimensions-tp4729807p4729811.html Sent from the datatable-help mailing list archive at Nabble.com. From 743642404 at qq.com Mon Mar 20 02:25:03 2017 From: 743642404 at qq.com (white1551) Date: Sun, 19 Mar 2017 18:25:03 -0700 (PDT) Subject: [datatable-help] data read problem. 'Error in make.names(col.names, unique = TRUE)' Message-ID: <1489973103955-4729896.post@n4.nabble.com> Hello all, I encountered this problem when trying to read a csv file. It says 'Error in make.names(col.names, unique = TRUE) : invalid multibyte string 1' Can anyone help me solve this problem? Thanks in advance. -- View this message in context: http://r.789695.n4.nabble.com/data-read-problem-Error-in-make-names-col-names-unique-TRUE-tp4729896.html Sent from the datatable-help mailing list archive at Nabble.com. From 743642404 at qq.com Mon Mar 20 02:40:28 2017 From: 743642404 at qq.com (white1551) Date: Sun, 19 Mar 2017 18:40:28 -0700 (PDT) Subject: [datatable-help] data read problem. 'Error in make.names(col.names, unique = TRUE)' In-Reply-To: <1489973103955-4729896.post@n4.nabble.com> References: <1489973103955-4729896.post@n4.nabble.com> Message-ID: <1489974028848-4729897.post@n4.nabble.com> To add the code, it is 'gender_data <- read.csv('Gender_Stat_Data.csv')' -- View this message in context: http://r.789695.n4.nabble.com/data-read-problem-Error-in-make-names-col-names-unique-TRUE-tp4729896p4729897.html Sent from the datatable-help mailing list archive at Nabble.com. From 214140739 at qq.com Tue Mar 28 10:37:54 2017 From: 214140739 at qq.com (shuangling) Date: Tue, 28 Mar 2017 01:37:54 -0700 (PDT) Subject: [datatable-help] Error in the example Message-ID: <1490690273864-4730721.post@n4.nabble.com> Dear all, I try to reapt the procedure from http://virginierondeau.com/BiostatisticalConsulting/example_shared.html > library(frailtypack) ###################################### ### Semi-parametric Shared frailty model ### ###################################### > data(readmission) > fit1<-frailtyPenal(Surv(t.start,t.stop,event)~as.factor(sex)+as.factor(dukes)+ > as.factor(charlson)+cluster(id),data=readmission, Frailty=TRUE, n.knots=6,kappa1=5000,recurrentAG=TRUE,cross.validation=TRUE,hazard="Splines") The R versions is R-3.3.3, the results showed: Error in frailtyPenal(Surv(t.start, t.stop, event) ~ as.factor(sex) + : It's no use parameters(Frailty = TRUE, kappa1 = 5000) I confuse why ? Anyone can explain this? Your friend Leo -- View this message in context: http://r.789695.n4.nabble.com/Error-in-the-example-tp4730721.html Sent from the datatable-help mailing list archive at Nabble.com.