[R] how to get the numbers of factors in a matrix
Dear friends, I have a question do not know how to resolve. I have a big matrix composed of different columns (I use N here). A column is species and another one is latitudes. Now, I want to know how I can get the number of different latitudes for every species. I have tried to split the matrix according to species (X-split(N, N$species) and then use sapply(X, function(m){nlevels(m$latitudes)}) to get that. But the result shows the total factor numbers of latitudes but not the factor numbers of every species I splitted. Also, I have tried to use tapply(N$latitudes, N$species, nlevels) to do this. The result is the same. I am confused about this. Can someone help me with that? Thank you very much! Best regards, Yichun [[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] My problem with R
Hi, I am a student in trouble with R. please help me! I have a 16 huge data(.csv). data1-read.csv(D://data1.csv, header=FALSE) . . . data16-read.csv(D://data16.csv, header=FALSE) and then, I tried to seperated data w/ column. a1-cbind(data1[1:36568,1]) b1-cbind(data1[1:36568,2]) . . . ac16-cbind(data16[1:85207,31]) a column is a Date(-mm-dd) b column is a Time(hh:mm:ss) c to ac is a numeric data. finished this work, use rbind function. date-rbind(a1,a2,a3,a4,.,a16) time-rbind(b1,b2,b3,..,b16) . . . . ac-rbind(ac1,ac2,ac3,...,ac16) I want to see -mm-dd format, but It does not work. b [,1] [1,] 17753 [2,] 17754 [3,] 17755 [4,] 17756 [5,] 17757 [6,] 17758 a [,1] [1,]1 [2,]1 [3,]1 [4,]1 [5,]1 [6,]1 I don't know why... Question 1. I want to paste a and b -mm-dd hh:mm:ss Question 2. I want to averaging mean, median for every each minute groups. for example) Time c de f . . . 2014-01-20 00:00:00 3.1428 1.99 0.123455 7.5526 2014-01-20 00:00:01 3.1887 1.03 0.176545 7.5234 2014-01-20 00:00:02 2.1876 1.27 0.987455 7.5996 ... 2014-01-20 00:01:00 5.4428 1.96 0.164455 7.8666 2014-01-20 00:01:01 1.5658 1.39 0.176545 7.7786 2014-01-20 00:01:02 3.1776 1.67 0.254655 7.4567 then, Time average_C c de f . . . 2014-01-20 00:00:00 here 3.1428 1.99 0.123455 7.5526 2014-01-20 00:00:01 3.1887 1.03 0.176545 7.5234 2014-01-20 00:00:02 2.1876 1.27 0.987455 7.5996 ... 2014-01-20 00:01:00 here 5.4428 1.96 0.164455 7.8666 2014-01-20 00:01:01 1.5658 1.39 0.176545 7.7786 2014-01-20 00:01:02 3.1776 1.67 0.254655 7.4567 PLEASE HELP ME, R-help!!! [[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] how to replace NA values
First of all I thank all the friends. Though I have written zero to replace NA in previous email, I will replace with extreme value (9). On Tuesday, 21 January 2014 7:05 AM, jwd [via R] ml-node+s789695n4683894...@n4.nabble.com wrote: On Sun, 19 Jan 2014 11:39:43 -0800 (PST) kingsly [hidden email] wrote: The age variable is being read in as a factor because of the .  If you were to replace it with NA, the type becomes numerical: Before replacement: str(Elder1) 'data.frame':  5 obs. of  2 variables:  $ ID : Factor w/ 5 levels ID1,ID2,ID3,..: 1 2 3 4 5  $ age: Factor w/ 3 levels ,35,38: 3 2 1 NA NA Notice that the is treated as a factor level. After: str(Elder1) 'data.frame':  5 obs. of  2 variables:  $ ID : Factor w/ 5 levels ID1,ID2,ID3,..: 1 2 3 4 5  $ age: num  38 35 NA NA NA SO, the question, is what do you want to do with that column?  An NA value tells you honestly that the information is missing.  Replacing it with a zero can be misleading and can bias some basic parameter estimates. After you know how you want to treat the data in that field, you may have a better idea of how to handle the missing data. JWD __ [hidden email] 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. If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/how-to-replace-NA-values-tp4683831p4683894.html To start a new topic under R help, email ml-node+s789695n78969...@n4.nabble.com To unsubscribe from R help, click here. NAML -- View this message in context: http://r.789695.n4.nabble.com/how-to-replace-NA-values-tp4683831p4683896.html Sent from the R help mailing list archive at Nabble.com. [[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] lattice
hello If I have a a program trend - read.table(txx.csv, header=T, sep=,) library(lattice) trellis.par.set(theme = canonical.theme(postscript, col=FALSE)) trellis.par.set(list(fontsize=list(text=8), par.xlab.text=list(cex=1.5), add.text=list(cex=3.5), superpose.symbol=list(cex=1.0))) key - simpleKey(levels(trend$Season), space = right) key$text$cex - 1.5 print( dotplot(Ville ~ Slope , data = trend, groups = Season, key = key, xlab = NULL, aspect=0.8, layout = c(1,1), ylab=NULL) ) and my dat det is Ville Season Slope significance Alh DJF -0.3 0.02 Ben DJF 0.13 0.7 Cas MAM 0.1 0.1 Ess JJA 0.4 0.03 Fes SON 0.9 0.02 how can i change the color of symbole of slope value if the significance is below 0.05 thank you FILAHI [[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] how to get the numbers of factors in a matrix
Dear YZ, I guess this is what you want: 1. http://stackoverflow.com/questions/3418128/how-to-convert-a-factor-to-an-integer-numeric-without-a-loss-of-information 2. http://stackoverflow.com/questions/6979625/arithmetic-operations-on-r-factors/6980780#6980780 3. http://toddjobe.blogspot.jp/2010/08/converting-r-contingency-tables-to-data.html but beware of that “If you really want the levels of the factor to be used, you're either doing something very wrong or too clever for its own good. All the best JY -- From: 张以春 yczh...@nigpas.ac.cn Reply: 张以春 yczh...@nigpas.ac.cn Date: 21 January 2014 at 16:57:38 To: r-help@r-project.org r-help@r-project.org Subject: [R] how to get the numbers of factors in a matrix Dear friends, I have a question do not know how to resolve. I have a big matrix composed of different columns (I use N here). A column is species and another one is latitudes. Now, I want to know how I can get the number of different latitudes for every species. I have tried to split the matrix according to species (X-split(N, N$species) and then use sapply(X, function(m){nlevels(m$latitudes)}) to get that. But the result shows the total factor numbers of latitudes but not the factor numbers of every species I splitted. Also, I have tried to use tapply(N$latitudes, N$species, nlevels) to do this. The result is the same. I am confused about this. Can someone help me with that? Thank you very much! Best regards, Yichun [[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-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] (no subject)
Hello to everyone! I'm a new to R and I don't succed in updating a variable (SR) in a for loop. The script created is the following one: path=c(C:/Users/memeo/Documents/Dottorato/soggetti visus danneggiato/) subjects=list.files(path) # subjects=subjects[c(1:35,37)] n_gradini=rep(c(1,2,4),length(subjects)) allsubjects=c(rep(subjects,each=3)) for (i in length(subjects)) { path_each_subj=paste0(path,subjects[i]) no_thumbs-grep(Thumbs,subjects) n=1:length(subjects) clear_thumbs=n!=no_thumbs if(clear_thumbs[i]) { each_subject=list.files(path_each_subj) find_gradini-grep(gradini,each_subject) file_gradini=each_subject[find_gradini] path_file_gradini=paste0(path_each_subj,/,file_gradini) SR-(rep(0,3)) # SR-matrix(data=NA,nrow=36*3,ncol=1) for(j in length(path_file_gradini)) { gradini-read.table(file=path_file_gradini[j],header=T,quote=\,skip=1) data-data.frame(gradini) names(data)=c(Id,Time,X,Y,H,Sound) #Calculate derivatives for isolate the positive contributes Hdiff=diff(data$H) Height=Hdiff[Hdiff0] SR[j]-length(Height)/tSR } blind=data.frame(Names=allsubjects,Gradini=n_gradini,StimuliRate=SR) print(SR) } else i=i+1 } write.table(blind,file=10Blind,sep= , eol=\r\n) CAN ANYONE HELP ME? Thank you very much! -- *M. Memeo* [[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] how to replace NA values
Hi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of kingsly Sent: Tuesday, January 21, 2014 7:22 AM To: r-help@r-project.org Subject: Re: [R] how to replace NA values First of all I thank all the friends. Though I have written zero to replace NA in previous email, I will replace with extreme value (9). Why? Many R functions has ability to work smoothly with NA values but AFAIK none is able to work with 9 values. It is the same as if you wanted to change bicycle tyres to wooden rim. You could ride but not with the same comfort. Regards Petr On Tuesday, 21 January 2014 7:05 AM, jwd [via R] ml- node+s789695n4683894...@n4.nabble.com wrote: On Sun, 19 Jan 2014 11:39:43 -0800 (PST) kingsly [hidden email] wrote: The age variable is being read in as a factor because of the . If you were to replace it with NA, the type becomes numerical: Before replacement: str(Elder1) 'data.frame': 5 obs. of 2 variables: $ ID : Factor w/ 5 levels ID1,ID2,ID3,..: 1 2 3 4 5 $ age: Factor w/ 3 levels ,35,38: 3 2 1 NA NA Notice that the is treated as a factor level. After: str(Elder1) 'data.frame': 5 obs. of 2 variables: $ ID : Factor w/ 5 levels ID1,ID2,ID3,..: 1 2 3 4 5 $ age: num 38 35 NA NA NA SO, the question, is what do you want to do with that column? An NA value tells you honestly that the information is missing. Replacing it with a zero can be misleading and can bias some basic parameter estimates. After you know how you want to treat the data in that field, you may have a better idea of how to handle the missing data. JWD __ [hidden email] 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. If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/how-to-replace-NA- values-tp4683831p4683894.html To start a new topic under R help, email ml- node+s789695n78969...@n4.nabble.com To unsubscribe from R help, click here. NAML -- View this message in context: http://r.789695.n4.nabble.com/how-to- replace-NA-values-tp4683831p4683896.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům. Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému. Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat. Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu. V případě, že je tento e-mail součástí obchodního jednání: - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu. - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou. - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech. - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá. This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system. If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner. The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email. In case that this e-mail forms part of business dealings: - the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning. - if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation. - the sender insists on that the respective contract is
Re: [R] My problem with R
Hi see in line -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Lee Marine Sent: Tuesday, January 21, 2014 7:17 AM To: r-help@r-project.org Subject: [R] My problem with R Hi, I am a student in trouble with R. please help me! I have a 16 huge data(.csv). data1-read.csv(D://data1.csv, header=FALSE) . . . data16-read.csv(D://data16.csv, header=FALSE) and then, I tried to seperated data w/ column. a1-cbind(data1[1:36568,1]) b1-cbind(data1[1:36568,2]) . . . ac16-cbind(data16[1:85207,31]) a column is a Date(-mm-dd) b column is a Time(hh:mm:ss) c to ac is a numeric data. finished this work, use rbind function. date-rbind(a1,a2,a3,a4,.,a16) time-rbind(b1,b2,b3,..,b16) . . . . ac-rbind(ac1,ac2,ac3,...,ac16) I want to see -mm-dd format, but It does not work. b [,1] [1,] 17753 [2,] 17754 [3,] 17755 [4,] 17756 [5,] 17757 [6,] 17758 a [,1] [1,]1 [2,]1 [3,]1 [4,]1 [5,]1 [6,]1 I don't know why... It is because you did not bother to make a glimpse to R-Intro to learn about data types and how to work with them. 1. Reading such data to R means that they are transformed to character or factor. See ?str ?factor 2. Functions rbind and cbind produce matrices if input is not a data frame. Matrices can not hold different types of data as data frames. Question 1. I want to paste a and b -mm-dd hh:mm:ss timestamp -strptime(paste(data1[,1], data1[,2], sep= ), format = ) see ?paste ?strptime ?as.POSIXct how to do it exactly Question 2. I want to averaging mean, median for every each minute groups. for example) see ?aggregate for averaging and ?format how to specify minute chunks. Final remarks. If you prototype the code for one file, you can do all computation in cycle. Do not post in HTML Post some data eg. by dput Do your homework and read help pages. They are available, usually well written and much effort is invested to them to be simply overlooked. Regards Petr Time c de f . . . 2014-01-20 00:00:00 3.1428 1.99 0.123455 7.5526 2014-01-20 00:00:01 3.1887 1.03 0.176545 7.5234 2014-01-20 00:00:02 2.1876 1.27 0.987455 7.5996 ... 2014-01-20 00:01:00 5.4428 1.96 0.164455 7.8666 2014-01-20 00:01:01 1.5658 1.39 0.176545 7.7786 2014-01-20 00:01:02 3.1776 1.67 0.254655 7.4567 then, Time average_C c de f . . . 2014-01-20 00:00:00 here 3.1428 1.99 0.123455 7.5526 2014-01-20 00:00:01 3.1887 1.03 0.176545 7.5234 2014-01-20 00:00:02 2.1876 1.27 0.987455 7.5996 ... 2014-01-20 00:01:00 here 5.4428 1.96 0.164455 7.8666 2014-01-20 00:01:01 1.5658 1.39 0.176545 7.7786 2014-01-20 00:01:02 3.1776 1.67 0.254655 7.4567 PLEASE HELP ME, R-help!!! [[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. Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům. Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému. Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat. Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu. V případě, že je tento e-mail součástí obchodního jednání: - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu. - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou. - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech. - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá. This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system. If you are not the
Re: [R] how to get the numbers of factors in a matrix
Hi It is rather difficult to understand what problem you have. post some data e.g. by dput(head(bigmatrix)) Maybe your problem is in a factor feature that it preserves also empty levels until you specifically drop them. ff-factor(letters[1:5]) levels(ff[1:2]) [1] a b c d e fff-ff[1:2] nlevels(fff) [1] 5 fff [1] a b Levels: a b c d e Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of ??? Sent: Tuesday, January 21, 2014 7:36 AM To: r-help@r-project.org Subject: [R] how to get the numbers of factors in a matrix Dear friends, I have a question do not know how to resolve. I have a big matrix composed of different columns (I use N here). A column is species and another one is latitudes. Now, I want to know how I can get the number of different latitudes for every species. I have tried to split the matrix according to species (X-split(N, N$species) and then use sapply(X, function(m){nlevels(m$latitudes)}) to get that. But the result shows the total factor numbers of latitudes but not the factor numbers of every species I splitted. Also, I have tried to use tapply(N$latitudes, N$species, nlevels) to do this. The result is the same. I am confused about this. Can someone help me with that? Thank you very much! Best regards, Yichun [[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. Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům. Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému. Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat. Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu. V případě, že je tento e-mail součástí obchodního jednání: - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu. - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou. - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech. - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá. This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system. If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner. The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email. In case that this e-mail forms part of business dealings: - the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning. - if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation. - the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects. - the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person represented by the recipient. __ 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] lattice
On Jan 21, 2014, at 2:02 AM, Said Filahi wrote: hello If I have a a program trend - read.table(txx.csv, header=T, sep=,) library(lattice) trellis.par.set(theme = canonical.theme(postscript, col=FALSE)) trellis.par.set(list(fontsize=list(text=8), par.xlab.text=list(cex=1.5), add.text=list(cex=3.5), superpose.symbol=list(cex=1.0))) key - simpleKey(levels(trend$Season), space = right) key$text$cex - 1.5 print( dotplot(Ville ~ Slope , data = trend, groups = Season, key = key, xlab = NULL, aspect=0.8, layout = c(1,1), ylab=NULL) ) and my dat det is Ville Season Slope significance Alh DJF -0.3 0.02 Ben DJF 0.13 0.7 Cas MAM 0.1 0.1 Ess JJA 0.4 0.03 Fes SON 0.9 0.02 how can i change the color of symbole of slope value if the significance is below 0.05 My early efforts were sabotaged by the groups argument. Removing it allowed the expected behavior to occur. dotplot(Ville ~ Slope , data = trend, key = key, col=c(red,blue)[1+(trend$Slope 0.05)], xlab = NULL, aspect=0.8, layout = c(1,1), ylab=NULL) -- David Winsemius, MD Alameda, CA, USA __ 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] how to get the numbers of factors in a matrix
Dear Pikal, Thank you very much for your answer. I think your example is just the problem I have. In the following example you gave to me, ff-factor(letters[1:5]) levels(ff[1:2]) [1] a b c d e fff-ff[1:2] nlevels(fff) [1] 5 fff [1] a b Levels: a b c d e In my understanding, fff is a subset of ff. Why fff's levels is not a, b but a,b,c,d,e. My problem is quite similar to the example. I just want to split the matrix into many subsets and calculate the levels of every subset. Can you tell me how to do? Thank you very much! Best regards, Yichun -åå§é®ä»¶- å件人: PIKAL Petr petr.pi...@precheza.cz åéæ¶é´: 2014å¹´1æ21æ¥ ææäº æ¶ä»¶äºº: å¼ ä»¥æ¥ yczh...@nigpas.ac.cn, r-help@r-project.org r-help@r-project.org æé: 主é¢: RE: [R] how to get the numbers of factors in a matrix Hi It is rather difficult to understand what problem you have. post some data e.g. by dput(head(bigmatrix)) Maybe your problem is in a factor feature that it preserves also empty levels until you specifically drop them. ff-factor(letters[1:5]) levels(ff[1:2]) [1] a b c d e fff-ff[1:2] nlevels(fff) [1] 5 fff [1] a b Levels: a b c d e Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of ??? Sent: Tuesday, January 21, 2014 7:36 AM To: r-help@r-project.org Subject: [R] how to get the numbers of factors in a matrix Dear friends, I have a question do not know how to resolve. I have a big matrix composed of different columns (I use N here). A column is species and another one is latitudes. Now, I want to know how I can get the number of different latitudes for every species. I have tried to split the matrix according to species (X-split(N, N$species) and then use sapply(X, function(m){nlevels(m$latitudes)}) to get that. But the result shows the total factor numbers of latitudes but not the factor numbers of every species I splitted. Also, I have tried to use tapply(N$latitudes, N$species, nlevels) to do this. The result is the same. I am confused about this. Can someone help me with that? Thank you very much! Best regards, Yichun [[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. Tento e-mail a jakékoliv k nÄmu pÅipojené dokumenty jsou důvÄrné a jsou urÄeny pouze jeho adresátům. Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavÄ neprodlenÄ jeho odesÃlatele. Obsah tohoto emailu i s pÅÃlohami a jeho kopie vymažte ze svého systému. Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávnÄni tento email jakkoliv užÃvat, rozÅ¡iÅovat, kopÃrovat Äi zveÅejÅovat. OdesÃlatel e-mailu neodpovÃdá za eventuálnà škodu způsobenou modifikacemi Äi zpoždÄnÃm pÅenosu e-mailu. V pÅÃpadÄ, že je tento e-mail souÄástà obchodnÃho jednánÃ: - vyhrazuje si odesÃlatel právo ukonÄit kdykoliv jednánà o uzavÅenà smlouvy, a to z jakéhokoliv důvodu i bez uvedenà důvodu. - a obsahuje-li nabÃdku, je adresát oprávnÄn nabÃdku bezodkladnÄ pÅijmout; OdesÃlatel tohoto e-mailu (nabÃdky) vyluÄuje pÅijetà nabÃdky ze strany pÅÃjemce s dodatkem Äi odchylkou. - trvá odesÃlatel na tom, že pÅÃsluÅ¡ná smlouva je uzavÅena teprve výslovným dosaženÃm shody na vÅ¡ech jejÃch náležitostech. - odesÃlatel tohoto emailu informuje, že nenà oprávnÄn uzavÃrat za spoleÄnost žádné smlouvy s výjimkou pÅÃpadů, kdy k tomu byl pÃsemnÄ zmocnÄn nebo pÃsemnÄ povÄÅen a takové povÄÅenà nebo plná moc byly adresátovi tohoto emailu pÅÃpadnÄ osobÄ, kterou adresát zastupuje, pÅedloženy nebo jejich existence je adresátovi Äi osobÄ jÃm zastoupené známá. This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system. If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner. The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email. In case that this e-mail forms part of business dealings: - the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning. - if the e-mail contains an offer,
Re: [R] how to get the numbers of factors in a matrix
Dear Jun Yi, Thank you very much for your help. But, the link you attached can not resolve my question. What I want is to get the numbers of factor levels for every subsets of a vector. When I do this, it always gives me the total numbers of levels for the whole vector. It really makes me confused. Best, Yichun -åå§é®ä»¶- å件人: Liu, Jun Yi 7yu...@gmail.com åéæ¶é´: 2014å¹´1æ21æ¥ ææäº æ¶ä»¶äºº: å¼ ä»¥æ¥ yczh...@nigpas.ac.cn, r-help@r-project.org æé: 主é¢: Re: [R] how to get the numbers of factors in a matrix Dear YZ, I guess this is what you want: 1. http://stackoverflow.com/questions/3418128/how-to-convert-a-factor-to-an-integer-numeric-without-a-loss-of-information 2. http://stackoverflow.com/questions/6979625/arithmetic-operations-on-r-factors/6980780#6980780 3. http://toddjobe.blogspot.jp/2010/08/converting-r-contingency-tables-to-data.html but beware of that âIf you really want the levels of the factor to be used, you're either doing something very wrong or too clever for its own good. All the best JY -- From: å¼ ä»¥æ¥ yczh...@nigpas.ac.cn Reply: å¼ ä»¥æ¥ yczh...@nigpas.ac.cn Date: 21 January 2014 at 16:57:38 To: r-help@r-project.org r-help@r-project.org Subject: [R] how to get the numbers of factors in a matrix Dear friends, I have a question do not know how to resolve. I have a big matrix composed of different columns (I use N here). A column is species and another one is latitudes. Now, I want to know how I can get the number of different latitudes for every species. I have tried to split the matrix according to species (X-split(N, N$species) and then use sapply(X, function(m){nlevels(m$latitudes)}) to get that. But the result shows the total factor numbers of latitudes but not the factor numbers of every species I splitted. Also, I have tried to use tapply(N$latitudes, N$species, nlevels) to do this. The result is the same. I am confused about this. Can someone help me with that? Thank you very much! Best regards, Yichun [[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. -- Dr Yichun Zhang State Key Laboratory of Palaeobiology and Stratigraphy, Nanjing Institute of Geology and Palaeontology 39 East Beijing Road, Nanjing, China, 210008 [[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] how to get the numbers of factors in a matrix
You are mis-using factors. Would you pretend that women do not exist just because your sample happens to include only men? If you really need to ignore those other levels, convert your factor to character and summarize those values. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. 张以春 yczh...@nigpas.ac.cn wrote: Dear Pikal, Thank you very much for your answer. I think your example is just the problem I have. In the following example you gave to me, ff-factor(letters[1:5]) levels(ff[1:2]) [1] a b c d e fff-ff[1:2] nlevels(fff) [1] 5 fff [1] a b Levels: a b c d e In my understanding, fff is a subset of ff. Why fff's levels is not a, b but a,b,c,d,e. My problem is quite similar to the example. I just want to split the matrix into many subsets and calculate the levels of every subset. Can you tell me how to do? Thank you very much! Best regards, Yichun -- �: PIKAL Petr petr.pi...@precheza.cz : 2014���1���21��� � �: � yczh...@nigpas.ac.cn, r-help@r-project.org r-help@r-project.org ��: ��: RE: [R] how to get the numbers of factors in a matrix Hi It is rather difficult to understand what problem you have. post some data e.g. by dput(head(bigmatrix)) Maybe your problem is in a factor feature that it preserves also empty levels until you specifically drop them. ff-factor(letters[1:5]) levels(ff[1:2]) [1] a b c d e fff-ff[1:2] nlevels(fff) [1] 5 fff [1] a b Levels: a b c d e Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of ??? Sent: Tuesday, January 21, 2014 7:36 AM To: r-help@r-project.org Subject: [R] how to get the numbers of factors in a matrix Dear friends, I have a question do not know how to resolve. I have a big matrix composed of different columns (I use N here). A column is species and another one is latitudes. Now, I want to know how I can get the number of different latitudes for every species. I have tried to split the matrix according to species (X-split(N, N$species) and then use sapply(X, function(m){nlevels(m$latitudes)}) to get that. But the result shows the total factor numbers of latitudes but not the factor numbers of every species I splitted. Also, I have tried to use tapply(N$latitudes, N$species, nlevels) to do this. The result is the same. I am confused about this. Can someone help me with that? Thank you very much! Best regards, Yichun [[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. Tento e-mail a jak��koliv k n��mu p��ipojen�� dokumenty jsou d��v��rn�� a jsou ur��eny pouze jeho adres��t��m. Jestli��e jste obdr��el(a) tento e-mail omylem, informujte laskav�� neprodlen�� jeho odes��latele. Obsah tohoto emailu i s plohami a jeho kopie vyma��te ze sv��ho syst��mu. Nejste-li zamlen��m adres��tem tohoto emailu, nejste opr��vn��ni tento email jakkoliv uvat, roz��i��ovat, kop��rovat ��i zve��ej��ovat. Odes��latel e-mailu neodpov��d�� za eventu��ln�� ��kodu zp��sobenou modifikacemi ��i zpo��d��n��m p��enosu e-mailu. V ppad��, ��e je tento e-mail soust�� obchodn��ho jedn��n��: - vyhrazuje si odes��latel pr��vo ukon��it kdykoliv jedn��n�� o uzav��en�� smlouvy, a to z jak��hokoliv d��vodu i bez uveden�� d��vodu. - a obsahuje-li nab��dku, je adres��t opr��vn��n nab��dku bezodkladn�� p��ijmout; Odes��latel tohoto e-mailu (nab��dky) vylu��uje p��ijet�� nab��dky ze strany pjemce s dodatkem ��i odchylkou. - trv�� odes��latel na tom, ��e pslu��n�� smlouva je uzav��ena teprve v��slovn��m dosa��en��m shody na v��ech jej��ch n��le��itostech. - odes��latel tohoto emailu informuje, ��e nen�� opr��vn��n uzav��rat za spole��nost dn�� smlouvy s v��jimkou ppad��, kdy k tomu byl p��semn�� zmocn��n nebo p��semn�� poven a takov�� poven�� nebo pln�� moc byly adres��tovi tohoto emailu ppadn�� osob��, kterou adres��t zastupuje, p��edlo��eny nebo jejich existence je adres��tovi ��i osob�� j��m zastoupen�� zn��m��. This e-mail and any documents
[R] repeated measures ANOVA using Anova in car library
Dear all, I am trying to do a repeated-measures ANOVA using Anova of the car package. I have a quite basic design with 24 subjects and only 2 within-subject factors (condition (2 levels: legal an illegal) and day (1,2,3)). I found the Examples (see https://stat.ethz.ch/pipermail/r-help/2008-December/181981.html) in ?Anova, but I don't know what to do if there are only within-subject factors. What should I do with the mod.ok model object? --snip- name_test_fribbles-read.csv('Naming_test_Fribbles.csv') # Import cond-factor(rep(c(legal,illegal),c(3,3)),levels=c(legal,illegal)) day-ordered(rep(1:3,2)) idata-data.frame(cond,day) mod.ok-lm(cbind(legTag1,legTag2,legTag3,illegTag1,illegTag2,illegTag3) ~ THIS IS MISSING ,data=name_test_fribbles) ---snip- I would be glad if anyone could help me! Thanks a lot! Rudi __ 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] how to replace NA values
I'm pretty sure that what you have is not what you think you have. Do a str(Elder1) on the data set and you will see that age is a factor not a numerical variable. Bascally you have a mangled data set from the look of it. Why would you want to change NA's to 0's? John Kane Kingston ON Canada -Original Message- From: ecoking...@yahoo.co.in Sent: Sun, 19 Jan 2014 11:39:43 -0800 (PST) To: r-help@r-project.org Subject: [R] how to replace NA values Dear R community B I have a large data set contain some empty cells. BecauseB of that,B may be I am wrong, NA values are produced. Now I want replace both empty and NA values with zero. B Elder1 - data.frame( B ID=c(ID1,ID2,ID3,ID6,ID8), B age=c(38,35,,NA,NA)) Output I am expecting B IDB B age ID1B 38 ID2B 35 ID3B 0 ID6B 0 ID8B 0 B In advance I thank your help. -- View this message in context: http://r.789695.n4.nabble.com/how-to-replace-NA-values-tp4683831.html Sent from the R help mailing list archive at Nabble.com. [[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. Send your photos by email in seconds... TRY FREE IM TOOLPACK at http://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-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] repeated measures ANOVA using Anova in car library
You should post this instead on r-sig-mixed-models, rather than here. They are specifically concerned with such statistical issues; here the concern is primarily R programming. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Tue, Jan 21, 2014 at 9:56 AM, Rüdiger Wolf r.h.w...@gmx.net wrote: Dear all, I am trying to do a repeated-measures ANOVA using Anova of the car package. I have a quite basic design with 24 subjects and only 2 within-subject factors (condition (2 levels: legal an illegal) and day (1,2,3)). I found the Examples (see https://stat.ethz.ch/pipermail/r-help/2008-December/181981.html) in ?Anova, but I don't know what to do if there are only within-subject factors. What should I do with the mod.ok model object? --snip- name_test_fribbles-read.csv('Naming_test_Fribbles.csv') # Import cond-factor(rep(c(legal,illegal),c(3,3)),levels=c(legal,illegal)) day-ordered(rep(1:3,2)) idata-data.frame(cond,day) mod.ok-lm(cbind(legTag1,legTag2,legTag3,illegTag1,illegTag2,illegTag3) ~ THIS IS MISSING ,data=name_test_fribbles) ---snip- I would be glad if anyone could help me! Thanks a lot! Rudi __ 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-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] how to get the numbers of factors in a matrix
On 21 Jan 2014, at 15:58 , Jeff Newmiller jdnew...@dcn.davis.ca.us wrote: You are mis-using factors. Would you pretend that women do not exist just because your sample happens to include only men? If you really need to ignore those other levels, convert your factor to character and summarize those values. Actually, just factor(fff) will do. Or droplevels(fff). -- Peter Dalgaard, Professor Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.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.
[R] Strange gcfit output in R package Grofit
Hi all, I'm trying to use the R growth curve analysis package Grofit. I've used it successfully before but the protocol which previously worked for me is now not giving me the expected output. Entering my data and time info and running Test-grofit(time,data,FALSE) gives me the expected growth curves as plots for my consideration. However, when I try to access the output of gcfit using either summary(Test,gcfit) or summary(Test$gcfit) I don't get the raw growth curve data which I expect, i.e. the 'hard' quantified info from the fitted growth curves, but instead seem to get information about the data that I entered and the running of the process: summary(TestRun2,gcfit) Length Class Mode time55 data.frame list data58 data.frame list gcFit7 gcFit list drFit1 -none- logical control 16 grofit.control list I've tried using the in-package generated data and get the same output. I can't see why the same protocol now doesn't work, except that the package is a later version than the one I previously used. Also, the package is now 'orphaned'. Can anyone give any advice? Would loading an earlier version of the package from the tar.gz file be an option? I'm a bit shaky on getting this to work (I had a bit of a go using the instructions here): http://stat.ethz.ch/pipermail/r-help/2008-August/169599.html but wasn't entirely successful Thanks for any suggestions! [[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] PCA factominer package, question about changing labels in individuals factor map
I am looking to do a PCA with the factominer package on a dataset of mine, named dat. The individuals in my dataset have character names, represented in the first column of my dataset, but since they aren't quantitative I can't include that column in my PCA analysis. Leading to the command res.pca = PCA(dat[,3:8], scale.unit=TRUE, ncp=5, graph=T) This is all well and good, except when my individuals factor map shows up, each data point is labeled as a number and not as their actual character names. http://r.789695.n4.nabble.com/file/n4683924/Screen_Shot_2014-01-21_at_12.19.23_PM.png How do I go about getting the map to display the character names? If I include the column with the names I get an error because it's not quantitative. I know it can be done because I've seen it on the decathlon dataset, I just don't know what they're doing differently to get those character names on the map. -- View this message in context: http://r.789695.n4.nabble.com/PCA-factominer-package-question-about-changing-labels-in-individuals-factor-map-tp4683924.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.
Re: [R] how do I extract all possible combinations of rows from a column
Hi, May be this helps: library(gtools) as.data.frame(t(combinations(5,3,1:5))) # V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 #1 1 1 1 1 1 1 2 2 2 3 #2 2 2 2 3 3 4 3 3 4 4 #3 3 4 5 4 5 5 4 5 5 5 A.K. For a column of data, I need to extract all possible unique combinations of 3 rows and combine the results into a data frame (as columns). So, for example, if I had a column called test that had five rows (the contents of which were the numbers 1:5) all possible combinations of 3 rows would be 1,2,3 1,2,4 1,2,5 1,3,4 1,3,5 1,4,5 2,3,4 2,4,5 2,4,5 3,4,5 So for this example, R would extract all the combinations shown, and I would get a data frame that looked like this 1 1 1 1 1 1 2 2 2 3 2 2 2 3 3 4 3 3 4 4 3 4 5 4 5 5 4 5 5 5 Note: I am not considering rearrangements of the same three rows to be unique. In other words, the combinations 123, 132, 213, 231, 312, 321 are all the same as far as I am concerned. If it is not possible to do it that way, it will still be helpful, but not quite as helpful. Thanks for the help! __ 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] how do I extract all possible combinations of rows from a column
... or combn() in utils. which was the first hit when I googled on finding combinations in R. So moral: Use search engines before you post. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Tue, Jan 21, 2014 at 12:57 PM, arun smartpink...@yahoo.com wrote: Hi, May be this helps: library(gtools) as.data.frame(t(combinations(5,3,1:5))) # V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 #1 1 1 1 1 1 1 2 2 2 3 #2 2 2 2 3 3 4 3 3 4 4 #3 3 4 5 4 5 5 4 5 5 5 A.K. For a column of data, I need to extract all possible unique combinations of 3 rows and combine the results into a data frame (as columns). So, for example, if I had a column called test that had five rows (the contents of which were the numbers 1:5) all possible combinations of 3 rows would be 1,2,3 1,2,4 1,2,5 1,3,4 1,3,5 1,4,5 2,3,4 2,4,5 2,4,5 3,4,5 So for this example, R would extract all the combinations shown, and I would get a data frame that looked like this 1 1 1 1 1 1 2 2 2 3 2 2 2 3 3 4 3 3 4 4 3 4 5 4 5 5 4 5 5 5 Note: I am not considering rearrangements of the same three rows to be unique. In other words, the combinations 123, 132, 213, 231, 312, 321 are all the same as far as I am concerned. If it is not possible to do it that way, it will still be helpful, but not quite as helpful. Thanks for the help! __ 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-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] repeated measures ANOVA using Anova in car library
Dear Rudiger, See the following paper in the R Journal, which, among other things, shows how to set up a repeated-measures ANOVA or MANOVA using Anova(): http://journal.r-project.org/archive/2013-1/fox-friendly-weisberg.pdf. I hope this helps, John John Fox McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Tue, 21 Jan 2014 18:56:56 +0100 Rüdiger Wolf r.h.w...@gmx.net wrote: Dear all, I am trying to do a repeated-measures ANOVA using Anova of the car package. I have a quite basic design with 24 subjects and only 2 within-subject factors (condition (2 levels: legal an illegal) and day (1,2,3)). I found the Examples (see https://stat.ethz.ch/pipermail/r-help/2008-December/181981.html) in ?Anova, but I don't know what to do if there are only within-subject factors. What should I do with the mod.ok model object? --snip- name_test_fribbles-read.csv('Naming_test_Fribbles.csv') # Import cond-factor(rep(c(legal,illegal),c(3,3)),levels=c(legal,illegal)) day-ordered(rep(1:3,2)) idata-data.frame(cond,day) mod.ok-lm(cbind(legTag1,legTag2,legTag3,illegTag1,illegTag2,illegTag3) ~ THIS IS MISSING ,data=name_test_fribbles) ---snip- I would be glad if anyone could help me! Thanks a lot! Rudi __ 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-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] PCA factominer package, question about changing labels in individuals factor map
Try rownames(dat) - dat[,1] before running PCA. - David L Carlson Department of Anthropology Texas AM University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Andy.P Sent: Tuesday, January 21, 2014 12:18 PM To: r-help@r-project.org Subject: [R] PCA factominer package, question about changing labels in individuals factor map I am looking to do a PCA with the factominer package on a dataset of mine, named dat. The individuals in my dataset have character names, represented in the first column of my dataset, but since they aren't quantitative I can't include that column in my PCA analysis. Leading to the command res.pca = PCA(dat[,3:8], scale.unit=TRUE, ncp=5, graph=T) This is all well and good, except when my individuals factor map shows up, each data point is labeled as a number and not as their actual character names. http://r.789695.n4.nabble.com/file/n4683924/Screen_Shot_2014-01 -21_at_12.19.23_PM.png How do I go about getting the map to display the character names? If I include the column with the names I get an error because it's not quantitative. I know it can be done because I've seen it on the decathlon dataset, I just don't know what they're doing differently to get those character names on the map. -- View this message in context: http://r.789695.n4.nabble.com/PCA-factominer-package-question-ab out-changing-labels-in-individuals-factor-map-tp4683924.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. __ 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] [datatable-help] Error in structure(ordered, dim = ns) : dims [product 1] do not match the length of object [0]
Hi, Couldn't reproduce the error after running your code: d - dcast(d, date ~ id, value.var=simple_return) dim(d) #[1] 356 9 sessionInfo() R version 3.0.2 (2013-09-25) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8 [5] LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8 [7] LC_PAPER=en_CA.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] plyr_1.8 quantmod_0.4-0 TTR_0.22-0 xts_0.9-7 zoo_1.7-10 [6] Defaults_1.1-1 stringr_0.6.2 reshape2_1.2.2 loaded via a namespace (and not attached): [1] grid_3.0.2 lattice_0.20-23 A.K. On Tuesday, January 21, 2014 2:57 PM, rcse2006 rcse2...@gmail.com wrote: Trying to run below code. library(quantmod) symbols - c(AAPL, DELL, GOOG, MSFT, AMZN, BIDU, EBAY, YHOO) d - list() for(s in symbols) { tmp - getSymbols(s, auto.assign=FALSE, verbose=TRUE) tmp - Ad(tmp) names(tmp) - price tmp - data.frame( date=index(tmp), id=s, price=coredata(tmp) ) d[[s]] - tmp } d - do.call(rbind, d) d - d[ d$date = as.Date(2007-01-01), ] rownames(d) - NULL # Weekly returns library(plyr) library(reshape2) d$next_friday - d$date - as.numeric(format(d$date, %u)) + 5 d - subset(d, date==next_friday) d - ddply(d, id, mutate, previous_price = lag(xts(price,date)), log_return = log(price / previous_price), simple_return = price / previous_price - 1 ) d - dcast(d, date ~ id, value.var=simple_return) Getting error d - dcast(d, date ~ id, value.var=simple_return) Error in structure(ordered, dim = ns) : dims [product 1] do not match the length of object [0] Please help me how to use ddply and dcast or using other similar function to get same data. -- View this message in context: http://r.789695.n4.nabble.com/Error-in-structure-ordered-dim-ns-dims-product-1-do-not-match-the-length-of-object-0-tp4683923.html Sent from the datatable-help mailing list archive at Nabble.com. ___ datatable-help mailing list datatable-h...@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help __ 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] obtain mean trait values by haplotype in haplo.stats package
Hello, I am using the haplo.stats package to calculate haplotype frequencies and test for associations of haplotype with a continuous phenotype (in this case BMI) in my population. My analysis is rather simple, as only 2 SNPs are included. I have a few questions related to the package: -How exactly is the hap-score calculated and what does it signify? -Is there a simple script I can use to obtain mean trait (BMI) values BY haplotype Thanks! -- View this message in context: http://r.789695.n4.nabble.com/obtain-mean-trait-values-by-haplotype-in-haplo-stats-package-tp4683930.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.
[R] Windows7, R-Studio, can't find package rJava,
example: getwd() # with RStudio you can read it off the console bar[1] C:/Users/ra`-/Documents/1ray/plans/learnR/week3liats library(xlsx)Loading required package: rJavaError : .onLoad failed in loadNamespace() for 'rJava', details: call: fun(libname, pkgname) error: JAVA_HOME cannot be determined from the RegistryIn addition: Warning messages:1: package xlsx was built under R version 3.0.2 2: package rJava was built under R version 3.0.2 Error: package rJava could not be loaded install.packages(rJava)Installing package into C:/Users/ra`-/Documents/R/win-library/3.0 (as lib is unspecified)trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.0/rJava_0.9-6.zip'Content type 'application/zip' length 758820 bytes (741 Kb)opened URLdownloaded 741 Kbpackage rJava successfully unpacked and MD5 sums checked The downloaded binary packages are in C:\Users\ra`-\AppData\Local\Temp\Rtmpq0N2f2\downloaded_packages library(rJava, lib.loc=C:/Users/ra`-/Documents/R/win-library/3.0)Error : .onLoad failed in loadNamespace() for 'rJava', details: call: fun(libname, pkgname) error: JAVA_HOME cannot be determined from the RegistryIn addition: Warning message:package rJava was built under R version 3.0.2 Error: package or namespace load failed for rJava I tried various things with searhpath, but can't figure out if this a windows 7 problem, an R problem, an R-studio problem, an R4 vs R3 problem, an rJava problem, a firewall problem, or some clever combination of such problems. Any tips greatly appreciated even if all they tell me is in which direction to look (e.g. give Windows a different searchpath?) TIA Ray Sachs [[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] [datatable-help] Error in structure(ordered, dim = ns) : dims [product 1] do not match the length of object [0]
When I use R-3.0.2 on Windows 7 the %u descriptor for format.Date() always gives , while on Linux in gives as.character(day-of-the-week). The resulting NA's on Windows could be the source of your problem. On Linux I get: format(as.Date(c(2014-01-21, 2014-01-22, 2014-01-28)), %u) [1] 2 3 2 as.numeric(.Last.value) [1] 2 3 2 cat(version$version.string, on, version$platform, \n) R version 3.0.2 (2013-09-25) on x86_64-unknown-linux-gnu while on Windows: format(as.Date(c(2014-01-21, 2014-01-22, 2014-01-28)), %u) [1] as.numeric(.Last.value) [1] NA NA NA cat(version$version.string, on, version$platform, \n) R version 3.0.2 (2013-09-25) on x86_64-w64-mingw32 d - subset(d, date==next_friday) d - ddply(d, id, mutate, previous_price = lag(xts(price,date)), log_return= log(price / previous_price), simple_return = price / previous_price - 1 ) d - dcast(d, date ~ id, value.var=simple_return) I you didn't reuse the same name, d, for the result of all these steps it would be easier to poke through the intermediate results to see where the trouble began (the output of subset() is a 0-row data.frame and dcast() dies when its input has zero rows). Bill Dunlap TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of arun Sent: Tuesday, January 21, 2014 12:48 PM To: R help Subject: Re: [R] [datatable-help] Error in structure(ordered, dim = ns) : dims [product 1] do not match the length of object [0] Hi, Couldn't reproduce the error after running your code: d - dcast(d, date ~ id, value.var=simple_return) dim(d) #[1] 356 9 sessionInfo() R version 3.0.2 (2013-09-25) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8 [5] LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8 [7] LC_PAPER=en_CA.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] plyr_1.8 quantmod_0.4-0 TTR_0.22-0 xts_0.9-7 zoo_1.7-10 [6] Defaults_1.1-1 stringr_0.6.2 reshape2_1.2.2 loaded via a namespace (and not attached): [1] grid_3.0.2 lattice_0.20-23 A.K. On Tuesday, January 21, 2014 2:57 PM, rcse2006 rcse2...@gmail.com wrote: Trying to run below code. library(quantmod) symbols - c(AAPL, DELL, GOOG, MSFT, AMZN, BIDU, EBAY, YHOO) d - list() for(s in symbols) { tmp - getSymbols(s, auto.assign=FALSE, verbose=TRUE) tmp - Ad(tmp) names(tmp) - price tmp - data.frame( date=index(tmp), id=s, price=coredata(tmp) ) d[[s]] - tmp } d - do.call(rbind, d) d - d[ d$date = as.Date(2007-01-01), ] rownames(d) - NULL # Weekly returns library(plyr) library(reshape2) d$next_friday - d$date - as.numeric(format(d$date, %u)) + 5 d - subset(d, date==next_friday) d - ddply(d, id, mutate, previous_price = lag(xts(price,date)), log_return = log(price / previous_price), simple_return = price / previous_price - 1 ) d - dcast(d, date ~ id, value.var=simple_return) Getting error d - dcast(d, date ~ id, value.var=simple_return) Error in structure(ordered, dim = ns) : dims [product 1] do not match the length of object [0] Please help me how to use ddply and dcast or using other similar function to get same data. -- View this message in context: http://r.789695.n4.nabble.com/Error-in-structure- ordered-dim-ns-dims-product-1-do-not-match-the-length-of-object-0-tp4683923.html Sent from the datatable-help mailing list archive at Nabble.com. ___ datatable-help mailing list datatable-h...@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help __ 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-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] [datatable-help] Error in structure(ordered, dim = ns) : dims [product 1] do not match the length of object [0]
You probably want to use %w instead of %u. On Linux 'man strftime' says %w The day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u. %u The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w. (SU) where (SU) means according to the Single Unix specification and the lack of (...) after %w means it is in some year's ANSI C standard. I assume Windows does not attempt to subscribe to the Single Unix standard. Bill Dunlap TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of William Dunlap Sent: Tuesday, January 21, 2014 2:33 PM To: arun; R help Subject: Re: [R] [datatable-help] Error in structure(ordered, dim = ns) : dims [product 1] do not match the length of object [0] When I use R-3.0.2 on Windows 7 the %u descriptor for format.Date() always gives , while on Linux in gives as.character(day-of-the-week). The resulting NA's on Windows could be the source of your problem. On Linux I get: format(as.Date(c(2014-01-21, 2014-01-22, 2014-01-28)), %u) [1] 2 3 2 as.numeric(.Last.value) [1] 2 3 2 cat(version$version.string, on, version$platform, \n) R version 3.0.2 (2013-09-25) on x86_64-unknown-linux-gnu while on Windows: format(as.Date(c(2014-01-21, 2014-01-22, 2014-01-28)), %u) [1] as.numeric(.Last.value) [1] NA NA NA cat(version$version.string, on, version$platform, \n) R version 3.0.2 (2013-09-25) on x86_64-w64-mingw32 d - subset(d, date==next_friday) d - ddply(d, id, mutate, previous_price = lag(xts(price,date)), log_return= log(price / previous_price), simple_return = price / previous_price - 1 ) d - dcast(d, date ~ id, value.var=simple_return) I you didn't reuse the same name, d, for the result of all these steps it would be easier to poke through the intermediate results to see where the trouble began (the output of subset() is a 0-row data.frame and dcast() dies when its input has zero rows). Bill Dunlap TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of arun Sent: Tuesday, January 21, 2014 12:48 PM To: R help Subject: Re: [R] [datatable-help] Error in structure(ordered, dim = ns) : dims [product 1] do not match the length of object [0] Hi, Couldn't reproduce the error after running your code: d - dcast(d, date ~ id, value.var=simple_return) dim(d) #[1] 356 9 sessionInfo() R version 3.0.2 (2013-09-25) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8 [5] LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8 [7] LC_PAPER=en_CA.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] plyr_1.8 quantmod_0.4-0 TTR_0.22-0 xts_0.9-7 zoo_1.7-10 [6] Defaults_1.1-1 stringr_0.6.2 reshape2_1.2.2 loaded via a namespace (and not attached): [1] grid_3.0.2 lattice_0.20-23 A.K. On Tuesday, January 21, 2014 2:57 PM, rcse2006 rcse2...@gmail.com wrote: Trying to run below code. library(quantmod) symbols - c(AAPL, DELL, GOOG, MSFT, AMZN, BIDU, EBAY, YHOO) d - list() for(s in symbols) { tmp - getSymbols(s, auto.assign=FALSE, verbose=TRUE) tmp - Ad(tmp) names(tmp) - price tmp - data.frame( date=index(tmp), id=s, price=coredata(tmp) ) d[[s]] - tmp } d - do.call(rbind, d) d - d[ d$date = as.Date(2007-01-01), ] rownames(d) - NULL # Weekly returns library(plyr) library(reshape2) d$next_friday - d$date - as.numeric(format(d$date, %u)) + 5 d - subset(d, date==next_friday) d - ddply(d, id, mutate, previous_price = lag(xts(price,date)), log_return = log(price / previous_price), simple_return = price / previous_price - 1 ) d - dcast(d, date ~ id, value.var=simple_return) Getting error d - dcast(d, date ~ id, value.var=simple_return) Error in structure(ordered, dim = ns) : dims [product 1] do not match the length of object [0] Please help me how to use ddply and dcast or using other similar function to get same data. -- View this message in context: http://r.789695.n4.nabble.com/Error-in-structure- ordered-dim-ns-dims-product-1-do-not-match-the-length-of-object-0-tp4683923.html Sent from the datatable-help mailing list archive at Nabble.com. ___ datatable-help mailing list datatable-h...@lists.r-forge.r-project.org
[R] Problems downloading and installing nlme under Linux Mint 15
I am running R under Linux Mint 15 and trying to download and install nlme. During the download I get an error message: Warning message: In install.packages(nlme) : installation of package ‘nlme’ had non-zero exit status When I try to load the package, I get an error message library(nlme) Error: package ‘nlme’ was built before R 3.0.0: please re-install it Why am I getting the error message, and what can I do to fix the problem? Please see output of R session below. Thank you, John version platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 3 minor 0.1 year 2013 month 05 day16 svn rev62743 language R version.string R version 3.0.1 (2013-05-16) nickname Good Sport install.packages(nlme) Installing package into ‘/home/john/R/i486-pc-linux-gnu-library/3.0’ (as ‘lib’ is unspecified) --- Please select a CRAN mirror for use in this session --- trying URL 'http://watson.nci.nih.gov/cran_mirror/src/contrib/nlme_3.1-113.tar.gz' Content type 'application/octet-stream' length 752188 bytes (734 Kb) opened URL == downloaded 734 Kb * installing *source* package ‘nlme’ ... ** package ‘nlme’ successfully unpacked and MD5 sums checked ** libs gfortran -fpic -O2 -pipe -g -c chol.f -o chol.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c corStruct.c -o corStruct.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c gnls.c -o gnls.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c init.c -o init.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c matrix.c -o matrix.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c nlOptimizer.c -o nlOptimizer.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c nlme.c -o nlme.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c nlmefit.c -o nlmefit.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c nls.c -o nls.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c pdMat.c -o pdMat.o gfortran -fpic -O2 -pipe -g -c rs.f -o rs.o gcc -std=gnu99 -shared -o nlme.so chol.o corStruct.o gnls.o init.o matrix.o nlOptimizer.o nlme.o nlmefit.o nls.o pdMat.o rs.o -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR installing to /home/john/R/i486-pc-linux-gnu-library/3.0/nlme/libs ** R ** data *** moving datasets to lazyload DB ** inst ** byte-compile and prepare package for lazy loading Error : package ‘lattice’ was built before R 3.0.0: please re-install it ERROR: lazy loading failed for package ‘nlme’ * removing ‘/home/john/R/i486-pc-linux-gnu-library/3.0/nlme’ The downloaded source packages are in ‘/tmp/Rtmpo7eFZf/downloaded_packages’ Warning message: In install.packages(nlme) : installation of package ‘nlme’ had non-zero exit status library(nlme) Error: package ‘nlme’ was built before R 3.0.0: please re-install it John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) CThis email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. __ 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] PCA factominer package, question about changing labels in individuals factor map
That worked! Wow easy fix, i feel dumb! Thanks! -- View this message in context: http://r.789695.n4.nabble.com/PCA-factominer-package-question-about-changing-labels-in-individuals-factor-map-tp4683924p4683941.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.
Re: [R] Problems downloading and installing nlme under Linux Mint 15
There is the error message: Error : package ‘lattice’ was built before R 3.0.0: please re-install it Perhaps the problem lies there. Clint BowmanINTERNET: cl...@ecy.wa.gov Air Quality Modeler INTERNET: cl...@math.utah.edu Department of Ecology VOICE: (360) 407-6815 PO Box 47600FAX:(360) 407-7534 Olympia, WA 98504-7600 USPS: PO Box 47600, Olympia, WA 98504-7600 Parcels:300 Desmond Drive, Lacey, WA 98503-1274 On Tue, 21 Jan 2014, John Sorkin wrote: I am running R under Linux Mint 15 and trying to download and install nlme. During the download I get an error message: Warning message: In install.packages(nlme) : installation of package ‘nlme’ had non-zero exit status When I try to load the package, I get an error message library(nlme) Error: package ‘nlme’ was built before R 3.0.0: please re-install it Why am I getting the error message, and what can I do to fix the problem? Please see output of R session below. Thank you, John version platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 3 minor 0.1 year 2013 month 05 day16 svn rev62743 language R version.string R version 3.0.1 (2013-05-16) nickname Good Sport install.packages(nlme) Installing package into ‘/home/john/R/i486-pc-linux-gnu-library/3.0’ (as ‘lib’ is unspecified) --- Please select a CRAN mirror for use in this session --- trying URL 'http://watson.nci.nih.gov/cran_mirror/src/contrib/nlme_3.1-113.tar.gz' Content type 'application/octet-stream' length 752188 bytes (734 Kb) opened URL == downloaded 734 Kb * installing *source* package ‘nlme’ ... ** package ‘nlme’ successfully unpacked and MD5 sums checked ** libs gfortran -fpic -O2 -pipe -g -c chol.f -o chol.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c corStruct.c -o corStruct.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c gnls.c -o gnls.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c init.c -o init.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c matrix.c -o matrix.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c nlOptimizer.c -o nlOptimizer.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c nlme.c -o nlme.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c nlmefit.c -o nlmefit.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c nls.c -o nls.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c pdMat.c -o pdMat.o gfortran -fpic -O2 -pipe -g -c rs.f -o rs.o gcc -std=gnu99 -shared -o nlme.so chol.o corStruct.o gnls.o init.o matrix.o nlOptimizer.o nlme.o nlmefit.o nls.o pdMat.o rs.o -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR installing to /home/john/R/i486-pc-linux-gnu-library/3.0/nlme/libs ** R ** data *** moving datasets to lazyload DB ** inst ** byte-compile and prepare package for lazy loading Error : package ‘lattice’ was built before R 3.0.0: please re-install it ERROR: lazy loading failed for package ‘nlme’ * removing ‘/home/john/R/i486-pc-linux-gnu-library/3.0/nlme’ The downloaded source packages are in ‘/tmp/Rtmpo7eFZf/downloaded_packages’ Warning message: In install.packages(nlme) : installation of package ‘nlme’ had non-zero exit status library(nlme) Error: package ‘nlme’ was built before R 3.0.0: please re-install it John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) CThis email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. __ 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] Problems downloading and installing nlme under Linux Mint 15
Clint, Thank you! Problem solved. John John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Clint Bowman cl...@ecy.wa.gov 1/21/2014 6:57 PM There is the error message: Error : package ‘lattice’ was built before R 3.0.0: please re-install it Perhaps the problem lies there. Clint BowmanINTERNET:cl...@ecy.wa.gov Air Quality ModelerINTERNET:cl...@math.utah.edu Department of EcologyVOICE:(360) 407-6815 PO Box 47600FAX:(360) 407-7534 Olympia, WA 98504-7600 USPS: PO Box 47600, Olympia, WA 98504-7600 Parcels:300 Desmond Drive, Lacey, WA 98503-1274 On Tue, 21 Jan 2014, John Sorkin wrote: I am running R under Linux Mint 15 and trying to download and install nlme. During the download I get an error message: Warning message: In install.packages(nlme) : installation of package ‘nlme’ had non-zero exit status When I try to load the package, I get an error message library(nlme) Error: package ‘nlme’ was built before R 3.0.0: please re-install it Why am I getting the error message, and what can I do to fix the problem? Please see output of R session below. Thank you, John version platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 3 minor 0.1 year 2013 month 05 day16 svn rev62743 language R version.string R version 3.0.1 (2013-05-16) nickname Good Sport install.packages(nlme) Installing package into ‘/home/john/R/i486-pc-linux-gnu-library/3.0’ (as ‘lib’ is unspecified) --- Please select a CRAN mirror for use in this session --- trying URL 'http://watson.nci.nih.gov/cran_mirror/src/contrib/nlme_3.1-113.tar.gz' Content type 'application/octet-stream' length 752188 bytes (734 Kb) opened URL == downloaded 734 Kb * installing *source* package ‘nlme’ ... ** package ‘nlme’ successfully unpacked and MD5 sums checked ** libs gfortran -fpic -O2 -pipe -g -c chol.f -o chol.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c corStruct.c -o corStruct.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c gnls.c -o gnls.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c init.c -o init.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c matrix.c -o matrix.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c nlOptimizer.c -o nlOptimizer.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c nlme.c -o nlme.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c nlmefit.c -o nlmefit.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c nls.c -o nls.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fvisibility=hidden -fpic -O2 -pipe -g -c pdMat.c -o pdMat.o gfortran -fpic -O2 -pipe -g -c rs.f -o rs.o gcc -std=gnu99 -shared -o nlme.so chol.o corStruct.o gnls.o init.o matrix.o nlOptimizer.o nlme.o nlmefit.o nls.o pdMat.o rs.o -lgfortran -lm -lquadmath -L/usr/lib/R/lib -lR installing to /home/john/R/i486-pc-linux-gnu-library/3.0/nlme/libs ** R ** data *** moving datasets to lazyload DB ** inst ** byte-compile and prepare package for lazy loading Error : package ‘lattice’ was built before R 3.0.0: please re-install it ERROR: lazy loading failed for package ‘nlme’ * removing ‘/home/john/R/i486-pc-linux-gnu-library/3.0/nlme’ The downloaded source packages are in ‘/tmp/Rtmpo7eFZf/downloaded_packages’ Warning message: In install.packages(nlme) : installation of package ‘nlme’ had non-zero exit status library(nlme) Error: package ‘nlme’ was built before R 3.0.0: please re-install it John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) CThis email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies
[R] Getting the current number of rows in windows R gui console (Carlos Arias)
Hello, I'm currently trying to set some default settings and I know how to get the width of the console with getOption(width), this corresponds to the number of columns of the console in the Rconsole file. I would also like to get the current number of rows from inside R. Is there an R option to get this value? Thank you, Carlos Arias Statistician at ICFES Colombia [[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] Getting the current number of rows in windows R gui console (Carlos Arias)
On 14-01-21 7:27 PM, Carlos Arias wrote: Hello, I'm currently trying to set some default settings and I know how to get the width of the console with getOption(width), this corresponds to the number of columns of the console in the Rconsole file. I would also like to get the current number of rows from inside R. Is there an R option to get this value? options(width) gives you the line length that various R functions use; it doesn't necessarily tell you the window width. (Setting the window width does update the option value, but not vice versa.) There aren't functions to get window size at the R level, though you could theoretically use getWindowsHandle() to get the handle of the R console Window, and use Windows API functions to get its measurements. You can use loadRconsole() to load new settings from a file. Duncan Murdoch __ 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] Porting Legacy R Code to Different Language
Hi, I'm trying to port a quite big piece of legacy R code to a different language ( Java or C# ). The package I'm trying to port is quite large but I'm only interested in one function in the package. I was just wondering if there's any tools that would allow me to get a trace of all the code that a R function executes when evaluating a given input : Example : g [[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] Windows7, R-Studio, can't find package rJava,
You need to install Java. That seems not to be in the rJava documentation: you get it from here: http://www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-1880261.html and need the version for the version of R (32- or 64-bit, x86 or x64 in Oracle parlance) you want to run. Please do follow the R-help posting guide and not send HTML, and give the 'at a minimum' information asked for (which includes that this is Windows i386 or x64). On 21/01/2014 20:49, Rainer K. SACHS wrote: example: getwd() # with RStudio you can read it off the console bar[1] C:/Users/ra`-/Documents/1ray/plans/learnR/week3liats library(xlsx)Loading required package: rJavaError : .onLoad failed in loadNamespace() for 'rJava', details: call: fun(libname, pkgname) error: JAVA_HOME cannot be determined from the RegistryIn addition: Warning messages:1: package ‘xlsx’ was built under R version 3.0.2 2: package ‘rJava’ was built under R version 3.0.2 Error: package ‘rJava’ could not be loaded install.packages(rJava)Installing package into ‘C:/Users/ra`-/Documents/R/win-library/3.0’ (as ‘lib’ is unspecified)trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.0/rJava_0.9-6.zip'Content type 'application/zip' length 758820 bytes (741 Kb)opened URLdownloaded 741 Kbpackage ‘rJava’ successfully unpacked and MD5 sums checked The downloaded binary packages are in C:\Users\ra`-\AppData\Local\Temp\Rtmpq0N2f2\downloaded_packages library(rJava, lib.loc=C:/Users/ra`-/Documents/R/win-library/3.0)Error : .onLoad failed in loadNamespace() for 'rJava', details: call: fun(libname, pkgname) error: JAVA_HOME cannot be determined from the RegistryIn addition: Warning message:package ‘rJava’ was built under R version 3.0.2 Error: package or namespace load failed for ‘rJava’ I tried various things with searhpath, but can't figure out if this a windows 7 problem, an R problem, an R-studio problem, an R4 vs R3 problem, an rJava problem, a firewall problem, or some clever combination of such problems. Any tips greatly appreciated even if all they tell me is in which direction to look (e.g. give Windows a different searchpath?) TIA Ray Sachs [[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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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] [datatable-help] Error in structure(ordered, dim = ns) : dims [product 1] do not match the length of object [0]
On 21/01/2014 22:45, William Dunlap wrote: You probably want to use %w instead of %u. On Linux 'man strftime' says %w The day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u. %u The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w. (SU) where (SU) means according to the Single Unix specification and the lack of (...) after %w means it is in some year's ANSI C standard. I assume Windows does not attempt to subscribe to the Single Unix standard. Maybe, but %u is in POSIX, standards Windows no long attempts to follow (and never did by default). If you need %u on Windows, try R-devel. strftime has been replaced there (by default on Windows, optionally on other platforms) by a POSIX-2008-compliant version. Bill Dunlap TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of William Dunlap Sent: Tuesday, January 21, 2014 2:33 PM To: arun; R help Subject: Re: [R] [datatable-help] Error in structure(ordered, dim = ns) : dims [product 1] do not match the length of object [0] When I use R-3.0.2 on Windows 7 the %u descriptor for format.Date() always gives , while on Linux in gives as.character(day-of-the-week). The resulting NA's on Windows could be the source of your problem. On Linux I get: format(as.Date(c(2014-01-21, 2014-01-22, 2014-01-28)), %u) [1] 2 3 2 as.numeric(.Last.value) [1] 2 3 2 cat(version$version.string, on, version$platform, \n) R version 3.0.2 (2013-09-25) on x86_64-unknown-linux-gnu while on Windows: format(as.Date(c(2014-01-21, 2014-01-22, 2014-01-28)), %u) [1] as.numeric(.Last.value) [1] NA NA NA cat(version$version.string, on, version$platform, \n) R version 3.0.2 (2013-09-25) on x86_64-w64-mingw32 d - subset(d, date==next_friday) d - ddply(d, id, mutate, previous_price = lag(xts(price,date)), log_return= log(price / previous_price), simple_return = price / previous_price - 1 ) d - dcast(d, date ~ id, value.var=simple_return) I you didn't reuse the same name, d, for the result of all these steps it would be easier to poke through the intermediate results to see where the trouble began (the output of subset() is a 0-row data.frame and dcast() dies when its input has zero rows). Bill Dunlap TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of arun Sent: Tuesday, January 21, 2014 12:48 PM To: R help Subject: Re: [R] [datatable-help] Error in structure(ordered, dim = ns) : dims [product 1] do not match the length of object [0] Hi, Couldn't reproduce the error after running your code: d - dcast(d, date ~ id, value.var=simple_return) dim(d) #[1] 356 9 sessionInfo() R version 3.0.2 (2013-09-25) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_CA.UTF-8LC_COLLATE=en_CA.UTF-8 [5] LC_MONETARY=en_CA.UTF-8LC_MESSAGES=en_CA.UTF-8 [7] LC_PAPER=en_CA.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] plyr_1.8 quantmod_0.4-0 TTR_0.22-0 xts_0.9-7 zoo_1.7-10 [6] Defaults_1.1-1 stringr_0.6.2 reshape2_1.2.2 loaded via a namespace (and not attached): [1] grid_3.0.2 lattice_0.20-23 A.K. On Tuesday, January 21, 2014 2:57 PM, rcse2006 rcse2...@gmail.com wrote: Trying to run below code. library(quantmod) symbols - c(AAPL, DELL, GOOG, MSFT, AMZN, BIDU, EBAY, YHOO) d - list() for(s in symbols) { tmp - getSymbols(s, auto.assign=FALSE, verbose=TRUE) tmp - Ad(tmp) names(tmp) - price tmp - data.frame( date=index(tmp), id=s, price=coredata(tmp) ) d[[s]] - tmp } d - do.call(rbind, d) d - d[ d$date = as.Date(2007-01-01), ] rownames(d) - NULL # Weekly returns library(plyr) library(reshape2) d$next_friday - d$date - as.numeric(format(d$date, %u)) + 5 d - subset(d, date==next_friday) d - ddply(d, id, mutate, previous_price = lag(xts(price,date)), log_return= log(price / previous_price), simple_return = price / previous_price - 1 ) d - dcast(d, date ~ id, value.var=simple_return) Getting error d - dcast(d, date ~ id, value.var=simple_return) Error in structure(ordered, dim = ns) : dims [product 1] do not match the length of object [0] Please help me how to use ddply and dcast or using other similar function to get same data. -- View this message in context: http://r.789695.n4.nabble.com/Error-in-structure- ordered-dim-ns-dims-product-1-do-not-match-the-length-of-object-0-tp4683923.html Sent from the datatable-help mailing list archive at Nabble.com.
[R] Strange error on text assignment to variable
Hello folks, I am using R version 3.0.2 (2013-09-25) -- Frisbee Sailing Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin10.8.0 (64-bit) on Mac OS 10.9.1 When I try a simple assignment as below, the first For works but the second for gives me an error. P_for - expression(P[For]) P_for - expression(P[for]) Error: unexpected ']' in P_for - expression(P[for] I have tested the following to work just fine: P_for - expression(P[For]) P_for - expression(P[F]) P_for - expression(P[f]) P_for - expression(P[fo]) P_for - expression(P[Fo]) P_for - expression(P[or]) Thanks for any help you can provide. Regards, Sumit __ 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] Strange error on text assignment to variable
Hi Well, for is a basic control-flow construct and as such a reserved word in R. See e.g. ?for Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Sumitrajit Dhar Sent: 22. januar 2014 08:01 To: r-help@r-project.org Subject: [R] Strange error on text assignment to variable Hello folks, I am using R version 3.0.2 (2013-09-25) -- Frisbee Sailing Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin10.8.0 (64-bit) on Mac OS 10.9.1 When I try a simple assignment as below, the first For works but the second for gives me an error. P_for - expression(P[For]) P_for - expression(P[for]) Error: unexpected ']' in P_for - expression(P[for] I have tested the following to work just fine: P_for - expression(P[For]) P_for - expression(P[F]) P_for - expression(P[f]) P_for - expression(P[fo]) P_for - expression(P[Fo]) P_for - expression(P[or]) Thanks for any help you can provide. Regards, Sumit __ 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-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] My problem with R
Hi From: Lee Marine [mailto:marine1...@gmail.com] Sent: Wednesday, January 22, 2014 2:01 AM To: PIKAL Petr Subject: Re: [R] My problem with R ps. str(timestamp3) POSIXlt[1:36568], format: 2013-10-04 04:42:00 2013-10-04 04:42:01 ... POSIX format can have list structure or vector structure which is appropriate for your case. see ?as.POSIXct However did you consider to use merge which is probably more appropriate than rbind and does not have matrix side effect. If I understand correctly you want to import several files with same structure and stack them together file1-data.frame(a=rnorm(10), b=1:10) file1 a b 1 1.1507791 1 2 1.1080384 2 3 1.4140105 3 4 0.5001733 4 5 -0.2109147 5 6 0.4318809 6 7 0.7652300 7 8 -0.3629509 8 9 -0.1579185 9 10 -0.3710052 10 file2-data.frame(a=rnorm(10), b=11:20) file2 a b 1 0.38297419 11 2 -0.77735905 12 3 1.50438015 13 4 0.30632757 14 5 0.30045189 15 6 0.66224030 16 7 1.64338395 17 8 -0.84172668 18 9 -0.33173291 19 10 0.0207 20 merge(file1, file2, all=T) a b 1 -0.84172668 18 2 -0.77735905 12 3 -0.37100523 10 4 -0.36295093 8 5 -0.33173291 19 6 -0.21091468 5 7 -0.15791848 9 8 0.0207 20 9 0.30045189 15 10 0.30632757 14 11 0.38297419 11 12 0.43188092 6 13 0.50017333 4 14 0.66224030 16 15 0.76522999 7 16 1.10803836 2 17 1.15077911 1 18 1.41401048 3 19 1.50438015 13 20 1.64338395 17 After merging you can convert date and time to POSIX and sort or aggregate your file . AFAIK merge can stack only two data frames but you can do it easily in cycle or by hand. Assuming your objects are named data1-datan, you can do final -merge(data1, data2, all=T) final - merge(final, data3, all=T) Regards Petr mode(timestamp3) [1] list Time-data.frame(rbind(timestamp3,timestamp4,timestamp5,timestamp6,timestamp7,timestamp8,timestamp9, timestamp10,timestamp11,timestamp12,timestamp13,timestamp14,timestamp15,timestamp16)) str(Time) 'data.frame': 14 obs. of 9 variables: $ sec :List of 14 ..$ timestamp3 : num 0 1 2 3 4 5 6 7 8 9 ... ..$ timestamp4 : num 0 1 2 3 4 5 6 7 8 9 ... ..$ timestamp5 : num 0 1 2 3 4 5 6 7 8 9 ... ..$ timestamp6 : num 0 1 2 3 4 5 6 7 8 9 ... ..$ timestamp7 : num 0 1 2 3 4 5 6 7 8 9 ... ..$ timestamp8 : num 0 1 2 3 4 5 6 7 8 9 ... ..$ timestamp9 : num 0 1 2 3 4 5 6 7 8 9 ... ..$ timestamp10: num 0 1 2 3 4 5 6 7 8 9 ... ..$ timestamp11: num 0 1 2 3 4 5 6 7 8 9 ... ..$ timestamp12: num 0 1 2 4 5 6 7 8 9 10 ... ..$ timestamp13: num 0 1 2 3 4 5 6 7 8 9 ... ..$ timestamp14: num 0 1 2 3 4 5 6 7 8 9 ... ..$ timestamp15: num 1 2 3 4 5 6 7 8 9 10 ... ..$ timestamp16: num 0 1 2 3 4 5 6 7 8 9 ... $ min :List of 14 ..$ timestamp3 : int 42 42 42 42 42 42 42 42 42 42 ... ..$ timestamp4 : int 0 0 0 0 0 0 0 0 0 0 ... ..$ timestamp5 : int 0 0 0 0 0 0 0 0 0 0 ... ..$ timestamp6 : int 0 0 0 0 0 0 0 0 0 0 ... ..$ timestamp7 : int 0 0 0 0 0 0 0 0 0 0 ... ..$ timestamp8 : int 0 0 0 0 0 0 0 0 0 0 ... ..$ timestamp9 : int 0 0 0 0 0 0 0 0 0 0 ... ..$ timestamp10: int 0 0 0 0 0 0 0 0 0 0 ... ..$ timestamp11: int 0 0 0 0 0 0 0 0 0 0 ... ..$ timestamp12: int 0 0 0 0 0 0 0 0 0 0 ... ..$ timestamp13: int 0 0 0 0 0 0 0 0 0 0 ... ..$ timestamp14: int 0 0 0 0 0 0 0 0 0 0 ... ..$ timestamp15: int 0 0 0 0 0 0 0 0 0 0 ... ..$ timestamp16: int 0 0 0 0 0 0 0 0 0 0 ... $ hour :List of 14 ..$ timestamp3 : int 4 4 4 4 4 4 4 4 4 4 ... ..$ timestamp4 : int 15 15 15 15 15 15 15 15 15 15 ... ..$ timestamp5 : int 15 15 15 15 15 15 15 15 15 15 ... ..$ timestamp6 : int 15 15 15 15 15 15 15 15 15 15 ... ..$ timestamp7 : int 15 15 15 15 15 15 15 15 15 15 ... ..$ timestamp8 : int 15 15 15 15 15 15 15 15 15 15 ... ..$ timestamp9 : int 15 15 15 15 15 15 15 15 15 15 ... ..$ timestamp10: int 15 15 15 15 15 15 15 15 15 15 ... ..$ timestamp11: int 15 15 15 15 15 15 15 15 15 15 ... ..$ timestamp12: int 15 15 15 15 15 15 15 15 15 15 ... ..$ timestamp13: int 15 15 15 15 15 15 15 15 15 15 ... ..$ timestamp14: int 15 15 15 15 15 15 15 15 15 15 ... ..$ timestamp15: int 15 15 15 15 15 15 15 15 15 15 ... ..$ timestamp16: int 15 15 15 15 15 15 15 15 15 15 ... $ mday :List of 14 ..$ timestamp3 : int 4 4 4 4 4 4 4 4 4 4 ... ..$ timestamp4 : int 4 4 4 4 4 4 4 4 4 4 ... ..$ timestamp5 : int 5 5 5 5 5 5 5 5 5 5 ... ..$ timestamp6 : int 6 6 6 6 6 6 6 6 6 6 ... ..$ timestamp7 : int 7 7 7 7 7 7 7 7 7 7 ... ..$ timestamp8 : int 8 8 8 8 8 8 8 8 8 8 ... ..$ timestamp9 : int 9 9 9 9 9 9 9 9 9 9 ... ..$ timestamp10: int 10 10 10 10 10 10 10 10 10 10 ... ..$ timestamp11: int 11 11 11 11 11 11 11 11 11 11 ... ..$ timestamp12: int 12 12 12 12 12 12 12 12 12 12 ... ..$ timestamp13: int 13 13 13 13 13 13 13 13 13 13 ... ..$ timestamp14: int 14 14 14 14 14 14 14 14 14 14 ... ..$ timestamp15: int 15 15 15 15 15 15 15 15 15 15 ... ..$
Re: [R] how to get the numbers of factors in a matrix
Hi elaborating answers you already got sapply(X, function(m){nlevels(factor(m$latitudes))}) tapply(N$latitudes, N$species, function(x) nlevels(factor(x))) shall do the trick Petr From: å¼ ä»¥æ¥ [mailto:yczh...@nigpas.ac.cn] Sent: Tuesday, January 21, 2014 2:58 PM To: PIKAL Petr Cc: r-help@r-project.org Subject: Re: RE: [R] how to get the numbers of factors in a matrix Dear Pikal, Thank you very much for your answer. I think your example is just the problem I have. In the following example you gave to me, ff-factor(letters[1:5]) levels(ff[1:2]) [1] a b c d e fff-ff[1:2] nlevels(fff) [1] 5 fff [1] a b Levels: a b c d e In my understanding, fff is a subset of ff. Why fff's levels is not a, b but a,b,c,d,e. My problem is quite similar to the example. I just want to split the matrix into many subsets and calculate the levels of every subset. Can you tell me how to do? Thank you very much! Best regards, Yichun -åå§é®ä»¶- å件人: PIKAL Petr petr.pi...@precheza.czmailto:petr.pi...@precheza.cz åéæ¶é´: 2014å¹´1æ21æ¥ ææäº æ¶ä»¶äºº: å¼ ä»¥æ¥ yczh...@nigpas.ac.cnmailto:yczh...@nigpas.ac.cn, r-help@r-project.orgmailto:r-help@r-project.org r-help@r-project.orgmailto:r-help@r-project.org æé: 主é¢: RE: [R] how to get the numbers of factors in a matrix Hi It is rather difficult to understand what problem you have. post some data e.g. by dput(head(bigmatrix)) Maybe your problem is in a factor feature that it preserves also empty levels until you specifically drop them. ff-factor(letters[1:5]) levels(ff[1:2]) [1] a b c d e fff-ff[1:2] nlevels(fff) [1] 5 fff [1] a b Levels: a b c d e Regards Petr -Original Message- From: r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.orgmailto:r-help-bounces@r-%0b%3e %3e project.org] On Behalf Of ??? Sent: Tuesday, January 21, 2014 7:36 AM To: r-help@r-project.orgmailto:r-help@r-project.org Subject: [R] how to get the numbers of factors in a matrix Dear friends, I have a question do not know how to resolve. I have a big matrix composed of different columns (I use N here). A column is species and another one is latitudes. Now, I want to know how I can get the number of different latitudes for every species. I have tried to split the matrix according to species (X-split(N, N$species) and then use sapply(X, function(m){nlevels(m$latitudes)}) to get that. But the result shows the total factor numbers of latitudes but not the factor numbers of every species I splitted. Also, I have tried to use tapply(N$latitudes, N$species, nlevels) to do this. The result is the same. I am confused about this. Can someone help me with that? Thank you very much! Best regards, Yichun [[alternative HTML version deleted]] __ R-help@r-project.orgmailto: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. Tento e-mail a jakékoliv k nÄmu pÅipojené dokumenty jsou důvÄrné a jsou urÄeny pouze jeho adresátům. Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavÄ neprodlenÄ jeho odesÃlatele. Obsah tohoto emailu i s pÅÃlohami a jeho kopie vymažte ze svého systému. Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávnÄni tento email jakkoliv užÃvat, rozÅ¡iÅovat, kopÃrovat Äi zveÅejÅovat. OdesÃlatel e-mailu neodpovÃdá za eventuálnà škodu způsobenou modifikacemi Äi zpoždÄnÃm pÅenosu e-mailu. V pÅÃpadÄ, že je tento e-mail souÄástà obchodnÃho jednánÃ: - vyhrazuje si odesÃlatel právo ukonÄit kdykoliv jednánà o uzavÅenà smlouvy, a to z jakéhokoliv důvodu i bez uvedenà důvodu. - a obsahuje-li nabÃdku, je adresát oprávnÄn nabÃdku bezodkladnÄ pÅijmout; OdesÃlatel tohoto e-mailu (nabÃdky) vyluÄuje pÅijetà nabÃdky ze strany pÅÃjemce s dodatkem Äi odchylkou. - trvá odesÃlatel na tom, že pÅÃsluÅ¡ná smlouva je uzavÅena teprve výslovným dosaženÃm shody na vÅ¡ech jejÃch náležitostech. - odesÃlatel tohoto emailu informuje, že nenà oprávnÄn uzavÃrat za spoleÄnost žádné smlouvy s výjimkou pÅÃpadů, kdy k tomu byl pÃsemnÄ zmocnÄn nebo pÃsemnÄ povÄÅen a takové povÄÅenà nebo plná moc byly adresátovi tohoto emailu pÅÃpadnÄ osobÄ, kterou adresát zastupuje, pÅedloženy nebo jejich existence je adresátovi Äi osobÄ jÃm zastoupené známá. This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of