[R] F test
Hi, I want to obtain the F test associated an ADF test In tseries, I can obtain t t stat of Dickey fuller, it is posible to obtain the related F test? Many thanks in advance [[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] Loop
Hi all, I want to execute a loop of a program: for (u in Timeframemin:Timeframe){} Imagine that Timeframemin<-10 Timefram<-1 Is it posible to execute the loop but only proving from 10 to 1 but jumping 10 each time, for example, execute for 10,20,30.to Timeframe. Other question is, when a program is "heavy" and has a lot of loops to execute (how can I know where loop is executing at the moment? There is some "print" or something to see in wich step of the loop is the program to see if the program is advancing? Many thanks in advance. [[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] plot
Hi all if I plot a graph on R, I press on the plot Export/Save Plot as Image I change name on "File name:" I select DirectoryBibliotecas\Documentos And select Width 800 and Height 800 And finally save in format JPEG It is posible to "type" code so that I can run my function and it is not necessary to make it manually? Thanks in advance. [[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] plot
Hi Many Thanks to all. dev.print(jpeg, file="test.jpeg", height=800,width=800) Works perfectly it saves in the default directory the jpeg file. I use RStudio. Many Thanks. 2013/4/1 David Winsemius > > On Apr 1, 2013, at 9:26 AM, R. Michael Weylandt wrote: > > > On Mon, Apr 1, 2013 at 5:05 PM, Trying To learn again > > wrote: > >> Hi all if I plot a graph on R, I press on the plot Export/Save Plot as > >> Image > > > > I assume this means you're using R-Studio? > > > >> > >> I change name on "File name:" > >> > >> I select DirectoryBibliotecas\Documentos > >> > >> And select Width 800 and Height 800 > >> > >> And finally save in format JPEG > >> > >> It is posible to "type" code so that I can run my function and it is not > >> necessary to make it manually? > > > > Yes -- in fact that's the way you're "supposed" to do it and the > > RStudio way you mentioned above is a shortcut. > > You might also try this if you have already tested your graphic > instructions on an interactive device and want to see if you can save it to > a different file device: > > dev.print(jpeg, file="test.jpeg", height=800,width=800) > > > > > E.g., > > > > jpeg() > > plot(1:5) > > dev.off() > > > > Read ?jpeg for more details. > > > > > > > David Winsemius > Alameda, CA, USA > > [[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] Tablet and executing R
Hi all, Have any of you instaled R on a Tablet, in this case, which Tablet. My family wants me to gift a Tablet but I suposse R can not be instaled on a Tablet. And my few "free" time I pass mainly trying to "improve" in R. Can yoy tell me, if there are, wich Tablets should be instaled? [[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] Obtaing the maximum
Hi all, I have a series whose tpe for that is like series I expose below. The thing is if a incremental number ends I´m in the first "type" of event in this success is named 5 (because of the maximum is 5). In the series I have this kind of events 5,3,1,1,5,3 But I don´t know extactly a priori what is the maximum and when "stops" there is some function in r doing something similar this? Thans in advance to all. 1 2 3 4 5 1 2 3 1 1 1 2 3 4 5 1 2 3 [[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] Brewer.pal error
Hi all, I have 35 years, I have been working since I exit from University. I have returned to make a phd...I´m fortunatelly I´m working so unfortunatelly I have few time to study (I have also a baby with 16 months). I´m trying to use R but sometimes it gets very difficult. I´m trying to put this code in my polygon function colramp=colorRampPalette(brewer.pal(9,"YlOrRd") to use brever.pal I have installed this lybrary library(RColorBrewer) but when I try to run it appears this message: Error in col2rgb(colors) : cannot find function "brewer.pal" If you want I can attach the zip I use. Can anyone please guide me how to make this run? MAny thanks in advance. I really think I have never will get my phd but it wa a key I have in mind and years before I´m trying. My neurons are limited but I will fight to achieve... [[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] Combinations
Hi all, I´ve been ill and I have lost a lot of time without seen the pc. I want you to help if you can if you want. Only I need an initial guide. I´ve been out a lot of time and I need a hope. Is only for "joby" purposes. The problem: I want to simulate each of the posible combination in a play. Imagine they play to games (football games) and you can choose "1", "X", "2" you must choose this 15 times. So finally you will get a colum 15x1 si you have (3^15) posible colums. I want to extract all the columns were in the row 3 you can find an "2". Or in the row 3 appears a "1" and row 3 "x". And extract them and save in a txt document. Sorry I know that I only ask but actually I feel very fool. If you give an initial guide will be sufficient. Many thanks for all in advace. [[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] Combinations
Hi all, Reading more I have find a partial solution on a part of the proble in some part of the code it should appea something like: # NC: All the potential combinations 3^15 if NC[price(i,j)=="1" & price(i,j)=="2"]> extract this column then save all the columns that contain this pre-requisite. 2010/10/4 Trying To learn again > Hi all, > > I´ve been ill and I have lost a lot of time without seen the pc. > > I want you to help if you can if you want. > > Only I need an initial guide. I´ve been out a lot of time and I need a > hope. Is only for "joby" purposes. > > The problem: > > I want to simulate each of the posible combination in a play. Imagine they > play to games (football games) and you can choose "1", "X", "2" you must > choose this 15 times. > > So finally you will get a colum 15x1 si you have (3^15) posible colums. > > I want to extract all the columns were in the row 3 you can find an "2". Or > in the row 3 appears a "1" and row 3 "x". > > And extract them and save in a txt document. > > Sorry I know that I only ask but actually I feel very fool. > > If you give an initial guide will be sufficient. > > Many thanks for all in advace. > > [[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] Add an arrow to a plot
Hi I want to plot an x,y plot something like an scatter plot. I always have the same doubt, were is the last point of my file? Imagine it is a time series so I want the last point to indicate with an arrow (but athomatically if posible). Someone knows if it is posible? Could it be posible to add additional arrows (with a small square with text?) I hope you can comprehead me? I suppose you will say: An arrow? Which width?size? I first need to see how it looks and if it is posible. Many thanks in advance¡¡¡ [[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] Add an arrow to a plot
Hi many thank¡¡¡ I promise work hard¡¡¡ Today I ´ve been very busy but I will wake up tomorrow on 5:00 to see what you have suggested I need work harder but working and having a children (1,5 years is very exhaust 2010/7/28 Greg Snow > In addition to the arrows function, look at the my.symbols and ms.arrows > functions in the TeachingDemos package, this is a wrapper around the arrows > function, but may be a more natural interface for what you want. > > -- > Gregory (Greg) L. Snow Ph.D. > Statistical Data Center > Intermountain Healthcare > greg.s...@imail.org > 801.408.8111 > > > > -Original Message- > > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > > project.org] On Behalf Of Trying To learn again > > Sent: Tuesday, July 27, 2010 3:07 PM > > To: r-help@r-project.org > > Subject: [R] Add an arrow to a plot > > > > Hi I want to plot an x,y plot something like an scatter plot. > > > > I always have the same doubt, were is the last point of my file? > > > > Imagine it is a time series so I want the last point to indicate with > > an > > arrow (but athomatically if posible). > > > > Someone knows if it is posible? > > > > Could it be posible to add additional arrows (with a small square with > > text?) > > > > I hope you can comprehead me? > > > > I suppose you will say: An arrow? Which width?size? I first need to see > > how > > it looks and if it is posible. > > > > Many thanks in advance¡¡¡ > > > > [[alternative HTML version deleted]] > > [[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] lm length
Hi all, I wanto to run a plot about the levels of a variable parting on an ols regression. The regression in done on the rate of return of the variable. Imagine R_{t}=a+b*R_{t-1} So If P, the "estimated" price would be P_{t}=P_{t-1}*R_{t} Imagine that I obtain lm fitted values and the original R_{t}, R_{t-1} are [1000,1] dimmension... How it is posible to obtain also 1000,1 fitted values? They should be 999,1, no? If I want to use the fitted values to multiply and obtain estimated pricesP_{t}=P_{t-1}*R_{t} how should I proceed? Many thanks in advance. I try it but I was surprised about the fitted values dimmensions¡¡¡ [[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] Item analysis
Hi all, For several reasons I have no used CARN R in monthsI have an idea and I want to retry to learn CRAN R. I know I need to formulate more "intelligent" questions but I will expose and if someone can help me I would be very gratefull I promise to try to learn again The question I have a data file like this: Date, Time, Tip 13/11/2008,23:16:00,432 13/01/2009,23:17:00,633 13/11/2009,23:16:00,134 13/12/2009,23:17:00,234 13/01/2010,23:16:00,111 I want to make an statistic (the sum of tip) but to extract one sum by each different minute in Time, so you see, in this easy example I will have a final table with two items: Item Sum 16 (432+134+111) 17 (633+234) Of course in my file (is bigger) I have minutes from 0 to 59. Would it be too much difficult if I want this analysis but on table for each day (indentified in the column Date) of the week. So you see on 13/11/2008 was thursday so you go each day and sum if this day is thrusday from 0 to 59 minutes... MAny thanks for all, each tip you give me I will send thousands of thanks¡ [[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] Loops on data˜1
Hi all, I have a time series a column vector with the ordered data so that the first column is the first observation and so on. The fact is that I want to run a multiple regression with only intercept. My first task is to run the regression on the first observation (1 from 276) and at the same time the same type of regressión on the 275 data. Then, is to run a regression on 2 of the data (the first and the second observation) and other with the 274 rest of observations ... The final tram of the loop would the to run 1 regression with the 275 first observations and one with the last observation. I want to save each pair of regression made in each loop. I have seen that the regression I want is data˜1 But how Shoud I use mapply or sapply? To run avoind using loops? Thanks in advance¡¡¡ Hope someone can send me examples similar o documents to try to make by my own. I attach the data. 0,044018608 -0,110930705 -0,004672806 0,036287839 0,076363838 0,184673507 0,054624796 0,004673399 -0,350369342 -0,018010741 0,04551358 0,103917907 0,003625427 0,053179293 -0,033782013 0,045388376 0,046058974 -0,026597853 -0,043024922 0,000107398 0,023316523 -0,025215586 -0,022010788 0,032180548 -0,046694162 0,04754586 0,04477713 0,050400827 -0,006016904 -0,009683332 0,060819249 0,02778801 -0,066637611 -0,015145689 -0,024107075 -0,054245015 -0,028267407 -0,106028435 0,058280299 0,048688903 0,03650455 -0,011679631 -0,118281484 -0,20053834 0,111253729 -0,006097049 -0,017805671 0,03705825 0,116787459 0,061440659 -0,012156779 0,038099168 -0,039006922 -0,016260521 0,021109252 0,022975469 -0,023373208 -0,05750481 -0,002784887 0,040829062 0,052226191 -0,038081497 -0,025343725 0,048157965 -0,09697759 -0,109103964 -0,057933746 -0,061468063 0,037968306 0,104264106 0,0007851 0,075840568 0,018310751 0,031504956 0,010294806 0,046695997 0,014182633 0,043380758 0,119688009 -0,055959275 0,082225757 -0,050393069 0,097278802 0,096262265 -0,06241493 -0,069361955 0,009030263 -0,002314697 -0,092980997 0,049805643 -0,008103107 -0,04925431 0,005615955 0,028565833 -0,062582675 -0,015542748 -0,005118238 -0,031176554 0,053190392 0,042622007 -0,002308574 0,046831888 0,017443516 -0,016442058 -0,029890565 0,068621158 0,033791768 0,02816927 0,04733688 -0,015027352 0,056886729 0,00701932 0,036404299 -0,069112649 0,011523185 0,046143139 0,021396424 0,080506631 0,099234631 0,032944569 -0,004136244 0,022154347 0,085647286 0,064147326 0,088601439 -0,010758421 -0,041759107 0,106954082 -0,130488552 0,082933574 0,045583222 0,092556088 0,111759282 0,137223967 -0,01813 -0,001992872 0,013962033 0,033656114 -0,238781644 -0,073829719 0,136588007 0,091739764 0,019618638 0,004280924 0,01192401 -0,026002073 0,023809079 0,00966702 0,014420507 -0,084361973 0,043157025 -0,029042726 0,022433195 0,117683799 0,060488801 -0,071776846 0,14977833 -0,053093935 -0,039923432 -0,070383431 -0,010080105 -0,004708031 0,032977872 0,005981323 -0,055088036 -0,11747309 -0,011427573 0,104767572 -0,057430588 -0,025781265 0,047488379 -0,027029374 -0,06774412 -0,045910911 -0,018915992 -0,129004138 0,061033102 0,073197048 0,003925481 -0,042224171 0,010515422 0,013939634 -0,011619177 -0,025398309 -0,139755653 -0,100934239 0,029391158 -0,169608455 0,122474857 0,085228942 -0,102065325 -0,014886045 0,008654874 -0,021719655 0,100245677 0,002923529 0,05288993 0,028686871 0,006999252 -0,059040373 0,06159641 0,017105131 0,064693628 0,02460056 0,039500045 -0,028438984 0,011334728 -0,018695158 0,014840398 -0,019878636 -0,00630829 0,020090369 0,047323011 0,032110196 0,04364419 0,015635647 0,017953842 -0,014177333 -0,028172111 0,046186181 0,037078109 0,033412158 -0,01060409 0,077357646 -0,030047737 0,006080317 0,016542034 0,033925463 0,055729017 0,009629233 0,003217278 -0,04752756 0,018140532 0,023102872 0,027269068 0,063020762 0,06134336 0,006977708 0,021232554 0,028343657 -0,021166281 0,027229002 -0,018410862 0,064309793 -0,028948397 -0,006034826 -0,022034755 0,006656068 0,086310803 -0,008252707 -0,037338464 -0,137718886 -0,004439502 0,0074586 0,039114909 -0,014409429 -0,12138671 -0,013783522 -0,014753157 -0,063454316 -0,186727152 -0,022789532 0,031505279 -0,084533081 -0,103319305 0,025150491 0,145392947 0,041853549 0,037845252 0,103498303 0,045912241 0,033824999 -0,029461496 0,019940382 0,025042967 -0,097638684 __ 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] Loops on data˜1
Hi Michael, First of all thanks for your response. I do know that if I make my stimation on a single data the regression has no sense but it will be getting sense in the growing next estimations. I change my asking doubt. I want to use this regressions as a first filter. Only this. Can anyone send information or webpages related with the use of mapply, sapply (so that one can avoid loops) Receive my apologuises if again my questions are too simple. 2011/9/12 R. Michael Weylandt > I may be totally off base with this, but I'm wondering what exactly this > would suggest or why you want to do it. Specifically "multiple regression > with only intercept" -- how is it multiple if you don't have any regressors? > Furthermore, you want to run a "regression" on a single data point -- > really? > > Best I can figure, an "intercept-only" regression is basically just the > mean of the data (if you have no variates, your best estimate as to the mean > of what you'll see is, well, just the mean [plus or minus some stuff about > the median we'll ignore here]) If I'm right about this, use of the lm() > function is far more powerful than you actually need and a simple cumulative > rolling mean, in conjunction with the rev() function, will suffice. > > Maybe you could say more about this odd request and we could provide a > little more guidance, > > Michael Weylandt > > On Mon, Sep 12, 2011 at 10:20 AM, Trying To learn again < > tryingtolearnag...@gmail.com> wrote: > >> Hi all, >> >> I have a time series a column vector with the ordered data so that the >> first >> column is the first observation and so on. >> >> The fact is that I want to run a multiple regression with only intercept. >> >> My first task is to run the regression on the first observation (1 from >> 276) >> and at the same time the same type of regressión on the 275 data. >> >> Then, is to run a regression on 2 of the data (the first and the second >> observation) and other with the 274 rest of observations >> >> ... >> >> The final tram of the loop would the to run 1 regression with the 275 >> first >> observations and one with the last observation. >> >> I want to save each pair of regression made in each loop. >> >> I have seen that the regression I want is >> >> data1 >> >> But how Shoud I use mapply or sapply? To run avoind using loops? >> >> Thanks in advance¡¡¡ >> >> Hope someone can send me examples similar o documents to try to make by my >> own. >> >> I attach the data. >> >> __ >> 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. >> >> > [[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] Inf and NA
Hi all, I have a csv matrix "KT.csv" and it has Inf and NA I want to calculate the mean of each row so I use rowMeans(KT,na.rm = TRUE) but with this Inf cannot be omminted. I´m trying to use before running rowMeans(KT,na.rm = TRUE) KT<-range(KT,finite=TRUE) but it doesn´t works... Do you know a simple way to ommit Inf en the calculations? Many thanks. I have tried also to replace Inf by NA bt also I dind´n t get it I feellike a mule... __ 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] Order all the columns ascending elements on a matrix or a data frame
Imagine I have a csv KT.csv I want to create a new dataframe o convert KT in a matrix and create a new matrix with each column of KT ordered by ascending order. I have tried to make this b<-read.csv("KT.csv") for(i in 1:ncol(b)){ b[,i]<-sort(b[,i]) } But it puts a message that the number of rows doesn´t correspond. Can someone give me a clue on how to order. Many Thaks. __ 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] Order all the columns ascending elements on a matrix or a data frame
Many ThanKs to all. 2012/6/10 Bert Gunter > On Sun, Jun 10, 2012 at 2:22 PM, arun wrote: > > Hi Bert, > > > > I tried the code. > > > > dat2<-data.frame(dat1) > >> do.call(order,dat2) > > [1] 3 6 1 10 2 5 7 9 8 4 > > > > > > Here, I get the order of 1st column as a list. Is there anything I am > missing here? > No you don't. You get a vector of row indices, but ... > > My oversight. Subscript the rows of dat2 by this: > > dat2[do.call(order,dat2) , ] > > -- Bert > > > > Thanks, > > A.K. > > > > > > > > > > - Original Message - > > From: Bert Gunter > > To: arun > > Cc: Trying To learn again ; R help < > r-help@r-project.org> > > Sent: Sunday, June 10, 2012 4:47 PM > > Subject: Re: [R] Order all the columns ascending elements on a matrix or > a data frame > > > > Inline ... > > > > -- Bert > > > > On Sun, Jun 10, 2012 at 10:46 AM, arun wrote: > >> Hi, > >> > >> If your intention is to order the first column by ascending, then by > 2nd and so on.. > >> Try this. > >> > >> set.seed(1) > >> dat1<-cbind(x=rnorm(10,5,0.5),y=runif(10,0.4),z=rnorm(10,15,0.2)) > >> dat1 > >> x yz > >> [1,] 4.686773 0.9608231 14.99101 > >> [2,] 5.091822 0.5272855 14.99676 > >> [3,] 4.582186 0.7910043 15.18877 > >> [4,] 5.797640 0.4753331 15.16424 > >> [5,] 5.164754 0.5603324 15.11878 > >> [6,] 4.589766 0.6316685 15.18380 > >> [7,] 5.243715 0.4080342 15.15643 > >> [8,] 5.369162 0.6294328 15.01491 > >> [9,] 5.287891 0.9218145 14.60213 > >> [10,] 4.847306 0.6042094 15.12397 > >> > >> dat1[order(dat1[,1],dat1[,2],dat1[,3]),] > > > > ## if dat1 is a data frame, e.g. > > > > dat1 <- data.frame(dat1) > > > > ## This can be shortened to: > > > > do.call(order,dat1) > > > > ?do.call > > > > -- Bert > > > >> x yz > >> [1,] 4.582186 0.7910043 15.18877 > >> [2,] 4.589766 0.6316685 15.18380 > >> [3,] 4.686773 0.9608231 14.99101 > >> [4,] 4.847306 0.6042094 15.12397 > >> [5,] 5.091822 0.5272855 14.99676 > >> [6,] 5.164754 0.5603324 15.11878 > >> [7,] 5.243715 0.4080342 15.15643 > >> [8,] 5.287891 0.9218145 14.60213 > >> [9,] 5.369162 0.6294328 15.01491 > >> [10,] 5.797640 0.4753331 15.16424 > >> > >> > >> > >> But, if it is like to order all the columns at once, > >> > >> apply(dat1,2,sort) > >> > >> x y z > >> [1,] 4.582186 0.4080342 14.60213 > >> [2,] 4.589766 0.4753331 14.99101 > >> [3,] 4.686773 0.5272855 14.99676 > >> [4,] 4.847306 0.5603324 15.01491 > >> [5,] 5.091822 0.6042094 15.11878 > >> [6,] 5.164754 0.6294328 15.12397 > >> [7,] 5.243715 0.6316685 15.15643 > >> [8,] 5.287891 0.7910043 15.16424 > >> [9,] 5.369162 0.9218145 15.18380 > >> [10,] 5.797640 0.9608231 15.18877 > >> > >> Here, the all columns are sorted to ascending, but only problem is that > the corresponding elements in each of the rows in the original dataset has > also changed. > >> > >> > >> A.K. > >> > >> > >> > >> > >> - Original Message - > >> From: Trying To learn again > >> To: r-help@r-project.org > >> Cc: > >> Sent: Sunday, June 10, 2012 2:36 AM > >> Subject: [R] Order all the columns ascending elements on a matrix or a > data frame > >> > >> Imagine I have a csv KT.csv > >> > >> I want to create a new dataframe o convert KT in a matrix and create a > new > >> matrix with each column of KT ordered by ascending order. > >> > >> I have tried to make this > >> > >> b<-read.csv("KT.csv") > >> > >> > >> for(i in 1:ncol(b)){ > >> > >> b[,i]<-sort(b[,i]) > >> > >> } > >> > >> But it puts a message that the number of rows doesn´t correspond. > >> > >> Can someone give me a clue on how to order. > >> > >> Many Thaks. > >> > >> __ > >> R-help@r-project.org mailing list > >> https://stat.ethz.ch/mailman/listinfo/r-help > >> PLEAS
[R] eclipse cran r
hi i see you can create latex pdf files using eclipse and that cran r code can be put on it direcctly. I have tried but it seems very difficult there is an easy way step by step manual and explaining all programs and folders needed? [[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] eclipse cran r
Hi JEssica I have tried but for the moment I´m getting crazyso I let for the future to understand for instance why the viewer doesn´t goes, and so on. Actually I´m using "Tex Maker" and I attach code using funtion \begin{lstlisting} so on The only "inconvenience" in Latex is always is to put plots where you want. I use this figute code location but it makes wat it wants. \begin{figure}[!h] \centering \includegraphics[scale=0.2]{vata.eps}\\ \end{figure} I know this is a R forum (sorry for my unformal way of typing yesterday Michael I wrotte from my phone and I was very tired, is not a justification I know anyway) but I´m sure that if someone has treat LAtex with eps or png images sure has the same problem. I read that using eclipse and sweave this thinks improveat least I have tried¡¡¡ Many thanks to all. 2012/6/12 Jessica Streicher > http://www.walware.de/goto/statet > eclipse plugin > > Having tried both sweave and knitr: > Knitr is easier to set up by far, but i don't like its documentation, so i > stayed with Sweave. > I needed a few days to get it running properly though, and it needed > workarounds. > > Am 12.06.2012 um 00:32 schrieb Trying To learn again: > > > hi i see you can create latex pdf files using eclipse and that cran r > code > > can be put on it direcctly. I have tried but it seems very difficult > there > > is an easy way step by step manual and explaining all programs and > folders > > needed? > > > > [[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. > > [[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] order or sort doesn´t work properly
Hi all, I want to order a series that is included on the second column in MCT.csv. I do but R doesn´t order, could be because is a csv? I have prove MCT<-read.csv("MCT.csv") a<-order(MCTor[,2],2,decreasing = FALSE) a<-order(MCTor[,2],1,decreasing = FALSE) or the same with sort but didn´t worked. It is suposed that a will have the ordered on ascending or descending direction, doesn´it? __ 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] Required libraries
Hi all, I´m trying to "recuperate" old files I wrotte and I´m trying to execute on R version 2.13.0 (2011-04-13), the thing is I execute my old file and nothing happens...I suposse I need to install some library but there no appears no message, no text telling "required grafics library" or something like that. How can I see wich libraries need to execute a file? Many thanks in advance Do you recommend to work with the last avaliable CRAN R version? [[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] Item analysis
Hi I have tried the first version, it works. BUT I have an additional problem. I expose; The first I solved, I tried to execute on xx data.frame but I used a matrix wich columns I put name you see col.names=c("Date","Time","Tip") the thing was that I didn´t erase the name on the txt so the program bloked. Now I have solve and it works. I My question, I want to sum first only on Time but on minutes. Will I make this using Time ~ variable as you suggested? You see from 00 to 59 first without having the posibility of hours. The result will be something like a matrix with [2,60] columns. Second is to aggregate from 00 to 23 hours and for each time see the sum from 00 to 59 minutes. the new matrix will have 24 rows (hours),60 columns (minutes) size. It is not necessary to you to tell the solution only I need to know if applying reshape is easy or I will have to use loops... I saw that date function has the posibility to identify for instance minutes...but not in 2 colum date as I have only it will work if it is preceed by the Date a global. t <- as.Date(g$Time, format="%H:%M:%S") I hope I have explained... Sorry for the inconveniences to all and many thanks. 2011/6/10 John Kane > Here are two different ways with your data as the data.frame xx > > # Basic R > aggregate(xx$Tip, list(xx$Time), sum) > > # Using the rshape package > library(reshape2) > yy <- melt(xx, id=c("Time"), measure.vars=c("Tip")) > dcast(yy , Time ~ variable , sum) > > > --- On Thu, 6/9/11, Trying To learn again > wrote: > > > From: Trying To learn again > > Subject: [R] Item analysis > > To: r-help@r-project.org > > Received: Thursday, June 9, 2011, 4:41 PM > > Hi all, > > > > For several reasons I have no used CARN R in monthsI > > have an idea and I > > want to retry to learn CRAN R. > > > > I know I need to formulate more "intelligent" questions but > > I will expose > > and if someone can help me I would be very gratefull I > > promise to try to > > learn again > > > > The question I have a data file like this: > > > > Date, Time, Tip > > 13/11/2008,23:16:00,432 > > 13/01/2009,23:17:00,633 > > 13/11/2009,23:16:00,134 > > 13/12/2009,23:17:00,234 > > 13/01/2010,23:16:00,111 > > > > I want to make an statistic (the sum of tip) but to extract > > one sum by each > > different minute in Time, so you see, in this easy example > > I will have a > > final table with two items: > > > > Item Sum > > 16 (432+134+111) > > 17 (633+234) > > > > Of course in my file (is bigger) I have minutes from 0 to > > 59. > > > > Would it be too much difficult if I want this analysis but > > on table for each > > day (indentified in the column Date) of the week. So you > > see on > > 13/11/2008 was thursday so you go each day and sum if > > this day is thrusday > > from 0 to 59 minutes... > > > > MAny thanks for all, each tip you give me I will send > > thousands of > > thanks¡ > > > > [[alternative HTML version deleted]] > > > > > > -Inline Attachment Follows- > > > > __ > > 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<http://www.r-project.org/posting-guide.html> > > and provide commented, minimal, self-contained, > > reproducible code. > > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Executing the same function on consecutive files
Hi all, I have the next problem: I have a matrix with size 8,000,000x18. My personal computer...blocks...so I have cut my original file into 100 different file. I have written a function that should be run on each of this file. So imagine I need to read data from q1 to q100 file data<-read.table("q1.txt",sep="") and each time I read 1 file execute my personal function (I get some stats) and my last target is to add each partial stats... My question is: Is posible to say something similar to this? for (i in 1:100){ data[i]<-read.table("q[i].txt", sep="") execute . } Many thanks in advance [[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] Separator of data
Hi all, I have a matrix like this: 188556644 225588666 55555 I try to read the table using read table but if I put sep="" I have seen it expects a white space, is there a "sep" option to read this matrix so each single number is a position of the matrix You see this matrix would be an 3x9 matrix I tried other option but also didn´t worked. If sep = "" (the default for read.table) the separator is white space, that is one or more spaces, tabs, newlines or carriage returns. [[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] Separator of data
MAny Thanks¡¡¡ 2011/6/28 jim holtman > try this: > > > x <- read.fwf(textConnection("188556644 > + 225588666 > + 55555"), width = rep(1,9)) > > > > x > V1 V2 V3 V4 V5 V6 V7 V8 V9 > 1 1 8 8 5 5 6 6 4 4 > 2 2 2 5 5 8 8 6 6 6 > 3 5 5 8 8 8 8 5 5 5 > > > > > On Tue, Jun 28, 2011 at 3:47 PM, Trying To learn again > wrote: > > Hi all, > > > > I have a matrix like this: > > > > 188556644 > > 225588666 > > 55555 > > > > I try to read the table using read table but if I put sep="" I have seen > it > > expects a white space, is there a "sep" option to read this matrix so > > each single number is a position of the matrix > > > > You see this matrix would be an 3x9 matrix > > > > I tried other option but also didn´t worked. > > > > If sep = "" (the default for read.table) the separator is white space, > > that is one or more spaces, tabs, newlines or carriage returns. > > > >[[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<http://www.r-project.org/posting-guide.html> > > and provide commented, minimal, self-contained, reproducible code. > > > > > > > > -- > Jim Holtman > Data Munger Guru > > What is the problem that you are trying to solve? > [[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] Executing a script "hand-made" and time
Hi all, I have a function written by me that read a matrix (data frame) from a txt with 4 million of rows and 13 columns. The think is my function works with an input matrix of 100x13 and now I tried to execute my function with the big "input file" and it is running form the moment two hours... There is a way to know (how much time could it cost?) The second question is... I want to buy a new computer...to threat files like this (and make on the ifforloops and so on)... I need a computer with high RAM or to "speed" this executing time I need other "technical hardware items" I´m sure my programmation can be simplied but anyway I hope someone can give me his/her opinion. Many Thaks in advance. [[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] Executing a script "hand-made" and time
Hi all, My file that worked with a thin matrix (with few rows and colums) finally made an error but I can´t comprehed why? valor ausente donde TRUE/FALSE es necesario (absent value TRUE/FALSE is necessary?) Error en if (data[i, j] - last1[1, j] != 0) data2[i, j] = 0 else { : You recommed to part the file of 4 Million rows x 13 colums? 2011/6/29 Trying To learn again > Hi all, > > I have a function written by me that read a matrix (data frame) from a txt > with 4 million of rows and 13 columns. > > The think is my function works with an input matrix of 100x13 and now I > tried to execute my function with the big "input file" and it is running > form the moment two hours... > > There is a way to know (how much time could it cost?) > > The second question is... > > I want to buy a new computer...to threat files like this (and make on the > ifforloops and so on)... I need a computer with high RAM or to > "speed" this executing time I need other "technical hardware items" > > I´m sure my programmation can be simplied but anyway I hope someone can > give me his/her opinion. > > Many Thaks in advance. > [[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] Eliminating a row if something happens
Hi all, I want to create a new matrix based on a previous matrix. You see, If my "data" matrix accomplises this: if(rowSums(data[i,])>16|rowSums(data[i,])<28) data[i,]= data[i,] # if sum of rows is more than 16 and less 28 I conservate the row #but How I say if else "remove" the line (I tried this) but doesn´t works...I´m really a asn else if(data[i,]=data[-i,]) } You see imagine my data matrix is 10x4 and only 3 rows passes the condition...the resulting matrix will be 3x4 I tried also to save the new matrix as csv like this write.csv(data, file = "input1.csv") How should I proceed to save as a txt? Many thanks I really like this problems but I feel my mind is restricted to more easy things¡¡¡jajaj [[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] Eliminating a row if something happens
Hi I know that putting write(f,file="bar.txt") it should work but the txt cannot be openned well I don ´t know exactly why. My mai doubt is how to make this I want to create a new matrix based on a previous matrix. You see, If my "data" matrix accomplises this: if(rowSums(data[i,])>16|rowSums(data[i,])<28) data[i,]= data[i,] # if sum of rows is more than 16 and less 28 I conservate the row #but How I say if else "remove" the line (I tried this) but doesn´t works...I´m really a asn else if(data[i,]=data[-i,]) } You see imagine my data matrix is 10x4 and only 3 rows passes the condition...the resulting matrix will be 3x4 2011/7/1 Trying To learn again > Hi all, > > I want to create a new matrix based on a previous matrix. > > You see, If my "data" matrix accomplises this: > > if(rowSums(data[i,])>16|rowSums(data[i,])<28) > data[i,]= data[i,] > > # if sum of rows is more than 16 and less 28 I conservate the row > #but How I say if else "remove" the line (I tried this) but doesn´t > works...I´m really a asn > > else if(data[i,]=data[-i,]) > } > > You see imagine my data matrix is 10x4 and only 3 rows passes the > condition...the resulting matrix will be 3x4 > > I tried also to save the new matrix as csv like this > > write.csv(data, file = "input1.csv") > > How should I proceed to save as a txt? > > Many thanks I really like this problems but I feel my mind is restricted to > more easy things¡¡¡jajaj > > [[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] How many times occurs
Hi all, I have a data matrix likein "input.txt" 8 9 2 5 4 5 8 5 6 6 8 9 2 8 9 2 8 9 2 1 8 9 2 5 4 5 8 5 6 4 8 9 2 5 4 5 8 5 6 6 8 9 2 8 9 2 8 9 2 1 8 9 2 5 4 5 8 9 2 2 In this example will be an 6x10 matrix (or data frame) I want to detect how many times in a row appears this combination 8 follewd by 9 followed by 2, and create a new matrix with only this number of occurs then if this number is less than "n" I keep the row. For example in the last row the number n will be 2 because "series" 8 9 2 appears 2 times in the same row. I tried this, but doesn´t worksalso tried other thinks but also the same results: *dat<-read.table('input1.txt')* ** ** *dat1 <- dat[ dat[,1]=8 & dat[,2]=9 & dat[,3]=2 ,]=1* *dat2<-dat[(dat[,2]= 8 & dat[,3]=9 & dat[,4]=2),]=1* *dat3<-dat[(dat[,5]=8 & dat[,4]=9 & dat[,5]=2),]=1* *dat4<-dat[(dat[,4]=8 & dat[,5]=9 & dat[,6]=2),]=1* *dat5<-dat[(dat[,5]=8 & dat[,6]=9 & dat[,7]=2),]=1* *dat6<-dat[(dat[,6]=8 & dat[,7]=9 & dat[,8]=2),6]=1* *dat7<-dat[(dat[,7]=8 &dat[,8]=9 & dat[,9]=2),7]=1* *dat8<-dat[(dat[,8]=8 &dat[,9]=9 & dat[,10]=2),8]=1* ** datfinal<-dat1+da2+dat3+dat4+dat5+dat6+dat7+dat8 final2 <- dat[ rowSums(datfinal) < 2 , ] So my last matrix "final2" will be "dat" without the rows that doesn´t pass the conditions. [[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 many times occurs
I suppose the easiest way to make this is to use loops and construct a zero matrix to be completed each time the sequence accompleixes, don´t you? I will try this evening¡¡¡ 2011/7/2 Trying To learn again > Hi all, > > I have a data matrix likein "input.txt" > > 8 9 2 5 4 5 8 5 6 6 > 8 9 2 8 9 2 8 9 2 1 > 8 9 2 5 4 5 8 5 6 4 > 8 9 2 5 4 5 8 5 6 6 > 8 9 2 8 9 2 8 9 2 1 > 8 9 2 5 4 5 8 9 2 2 > > > In this example will be an 6x10 matrix (or data frame) > > I want to detect how many times in a row appears this combination 8 > follewd by 9 followed by 2, and create a new matrix with only this number of > occurs then if this number is less than "n" I keep the row. For example in > the last row the number n will be 2 because "series" 8 9 2 appears 2 times > in the same row. > > I tried this, but doesn´t worksalso tried other thinks but also the > same results: > > *dat<-read.table('input1.txt')* > ** > ** > *dat1 <- dat[ dat[,1]=8 & dat[,2]=9 & dat[,3]=2 ,]=1* > *dat2<-dat[(dat[,2]= 8 & dat[,3]=9 & dat[,4]=2),]=1* > *dat3<-dat[(dat[,5]=8 & dat[,4]=9 & dat[,5]=2),]=1* > *dat4<-dat[(dat[,4]=8 & dat[,5]=9 & dat[,6]=2),]=1* > *dat5<-dat[(dat[,5]=8 & dat[,6]=9 & dat[,7]=2),]=1* > *dat6<-dat[(dat[,6]=8 & dat[,7]=9 & dat[,8]=2),6]=1* > *dat7<-dat[(dat[,7]=8 &dat[,8]=9 & dat[,9]=2),7]=1* > *dat8<-dat[(dat[,8]=8 &dat[,9]=9 & dat[,10]=2),8]=1* > ** > datfinal<-dat1+da2+dat3+dat4+dat5+dat6+dat7+dat8 > > final2 <- dat[ rowSums(datfinal) < 2 , ] > > So my last matrix "final2" will be "dat" without the rows that doesn´t pass > the conditions. > > > [[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] Executing a function several time, how to save the output
Hi all, I try to exceute a function "myfun" that should use as input "input1.csv" and "input2.csv" . Then I try to save the output dat33 on a csv file (on per each time I execute input1..input 2 and so on). So my problem is how to finally obtain several csv file with "ggt1.csv", "ggt2.csv". The program creates ggt1.csv but BUT when runs "myfun" by second time (It is supossed with input2.csv" it appears: Warning messages: 1: In if (file == "") file <- stdout() else if (is.character(file)) { : the condition has length > 1 and only the first element will be used 2: In file(file, ifelse(append, "a", "w")) : only first element of 'description' argument used 3: In if (file == "") file <- stdout() else if (is.character(file)) { : the condition has length > 1 and only the first element will be used 4: In file(file, ifelse(append, "a", "w")) : only first element of 'description' argument used Do you understand what the message says? files <- paste('input', 1:2, '.csv', sep = '') myfun <- function(d) { dat <- read.csv(d, header = TRUE) dat33<-dat+4 n<-ncol(dat33) m<-nrow(dat33) write.csv(dat33, file =write.csv(dat33, file =paste('ggt', 1:2, '.csv', sep = ' ')) } lout<- lapply(files, myfun) [[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] Executing a function several time, how to save the output
Hi, I find the solution¡¡¡ It was the 1:2 so if I put a loop for iand replace it works¡¡¡ So Many Thanks¡¡¡ Forget My doubt¡¡ 2011/7/5 Trying To learn again > Hi all, > > I try to exceute a function "myfun" that should use as input "input1.csv" > and "input2.csv" . > > Then I try to save the output dat33 on a csv file (on per each time I > execute input1..input 2 and so on). So my problem is how to finally obtain > several csv file with "ggt1.csv", "ggt2.csv". > > The program creates ggt1.csv but > > BUT when runs "myfun" by second time (It is supossed with input2.csv" it > appears: > > > Warning messages: > 1: In if (file == "") file <- stdout() else if (is.character(file)) { : > the condition has length > 1 and only the first element will be used > 2: In file(file, ifelse(append, "a", "w")) : > only first element of 'description' argument used > 3: In if (file == "") file <- stdout() else if (is.character(file)) { : > the condition has length > 1 and only the first element will be used > 4: In file(file, ifelse(append, "a", "w")) : > only first element of 'description' argument used > Do you understand what the message says? > > > > files <- paste('input', 1:2, '.csv', sep = '') > myfun <- function(d) { >dat <- read.csv(d, header = TRUE) > > dat33<-dat+4 > n<-ncol(dat33) > m<-nrow(dat33) > write.csv(dat33, file =write.csv(dat33, file =paste('ggt', 1:2, '.csv', sep > = ' ')) > } > > lout<- lapply(files, myfun) > [[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] Creating a zero matrix when a condition doesn´t get it
Hi all, I first create a matrix/data frame called "d2" if another matrix accomplishes some restrictions "dacc2" da2<-da1[colSums(dacc2)>9,] da2<-da2[(da2[,13]=24),] write.csv(da2, file =paste('hggi', i,'.csv',sep = '')) The thing is if finally da2 cannot get/passs the filters, it cannot writte a csv because there is no any true condition. How can I create anyway a csv with zeros of one row and "n" columns (being n the number of columns of da2? I need a loop? [[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] Creating a zero matrix when a condition doesn´t get it
Many Thanks¡¡¡ I will try this night, I have read this I think could help me. I´m conscient the question was badly formulated now, I will try to explain better next time¡¡¡ On a side note: apply always accesses the function you use at least once. If the input is a dataframe without any rows but with defined variables, it sends "FALSE" as an argument to the function. If the dataframe is completely empty, it sends a logical(0) to the function. > x <- data.frame(a=numeric(0)) > str(x) 'data.frame': 0 obs. of 1 variable: $ a: num > y <- apply(x,MARGIN=1,FUN=function(x){print(x)}) [1] FALSE > x <- data.frame() > str(x) 'data.frame': 0 obs. of 0 variables > y <- apply(x,MARGIN=1,FUN=function(x){print(x)}) logical(0) 2011/7/12 Sarah Goslee > Hi, > > You don't provide us with a reproducible example, so I can't provide you > with > actual code. But two approaches come to mind: > 1. Create da2 with one row and n columns, then change the appropriate > elements, > if any, based on your conditions. > 2. Do the conditional parts, then check to see whether da2 is empty. > If it is, then > replace the empty data frame with a data frame of one row and n columns. > > Sarah > > On Tue, Jul 12, 2011 at 3:51 AM, Trying To learn again > wrote: > > Hi all, > > > > I first create a matrix/data frame called "d2" if another matrix > > accomplishes some restrictions "dacc2" > > > > da2<-da1[colSums(dacc2)>9,] > > da2<-da2[(da2[,13]=24),] > > write.csv(da2, file =paste('hggi', i,'.csv',sep = '')) > > > > The thing is if finally da2 cannot get/passs the filters, it cannot > writte a > > csv because there is no any true condition. > > > > How can I create anyway a csv with zeros of one row and "n" columns > (being n > > the number of columns of da2? > > > > I need a loop? > > Rarely. > > > -- > Sarah Goslee > http://www.functionaldiversity.org > [[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] Avoiding loops to detect number of coincidences
Hi all, I have this information on a file ht.txt, imagine it is a data frame without labels: 1 1 1 8 1 1 6 4 1 3 1 3 3 And on other table called "pru.txt" I have sequences similar this 4 1 1 8 1 1 6 4 1 3 1 3 3 1 6 1 8 1 1 6 4 1 3 1 3 3 1 1 1 8 1 1 6 4 1 3 1 3 3 6 6 6 8 1 1 6 4 1 3 1 3 3 I want to now how many positions are identical between each row in pru compared with ht. n and m are the col and row of pru (m is the same number in pru and ht) I tried this with loops n<-nrow(pru) m<-ncol(pru) dacc2<-mat.or.vec(n, m) for (g in 1:n){ for (j in 1:m){ if(pru[g,j]-ht[1,j]!=0) dacc2[g,j]=0 else {dacc2[g,j]=1} } } So when I have dacc2 I can filter this: dar2<-pru[colSums(dacc2)>2 & colSums(dacc2)<10,] There is some way to avoid loops? [[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] DAtes
Hi all, I´m trying to convert as a data frame (with format "date") this copied excel column of dates (exposed below), I have tried to save them in a txt file tfr<-read.table("tfra.txt") tfr<-data.frame(tfr) I have tried several things, as date, so on, but always error. And it makes Error en as.Date.default(tfr, "%m/%d/%y") : do not know how to convert 'a' to class "Date" Can anyone give me a clue or a gide to achieve this final result. 14/12/2000 15/12/2000 18/12/2000 19/12/2000 20/12/2000 21/12/2000 22/12/2000 25/12/2000 26/12/2000 27/12/2000 28/12/2000 29/12/2000 01/01/2001 02/01/2001 03/01/2001 04/01/2001 05/01/2001 08/01/2001 09/01/2001 10/01/2001 11/01/2001 12/01/2001 15/01/2001 16/01/2001 17/01/2001 18/01/2001 19/01/2001 22/01/2001 23/01/2001 24/01/2001 25/01/2001 26/01/2001 29/01/2001 30/01/2001 31/01/2001 01/02/2001 02/02/2001 05/02/2001 06/02/2001 07/02/2001 08/02/2001 09/02/2001 12/02/2001 13/02/2001 14/02/2001 15/02/2001 16/02/2001 19/02/2001 20/02/2001 21/02/2001 [[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] Hi
Hi all, I have solved my question Output<- matrix(0, length(x), 1) for (i in 1:length(x)){ files <- paste('KT', i, '.csv', sep = '') da1 <- read.csv(files) Output[i,1]<-da1[1,2] } 2011/12/14 Trying To learn again > Hi all, > > I have 100 csv files always with this information (I Attach two example > excels) > > KT80.csv contains: > ,"x" > 1,127.188271604938 > > KT80.csv contains > > ,"x" > 1,1.06329287351545 > > > I have three questions: > > First > > When I created this input files I used write.csv and it authomaticaly > creates the structure of the file as you can see. > > Second. If I try to read csv it appears: > > read.csv(KT2.csv,header=T, sep='.') > Error en read.table(file = file, header = header, sep = sep, quote = > quote, : > objeto 'KT2.csv' no encontrado > > But the file is in the right directy > > Third (supossing I can solve the format files) > > My main question is: > > I want to create a matrix (or data frame) for instance from file KT80.csv > to KT81.csv so that the rows are without header and position. > > > > 127.18 > 1.06 > > > Wich function would help me? > > I think I should use something like > > > > ffor (i in 80:81){ > > files <- paste('KT', i, '.csv', sep = '') > > myfun <- function(d) { > > da1 <- read.csv(d) > > Output[i,1]=da1[1,2] > > > > } > > lout<- lapply(files, myfun) > > } > > But results that says Output doesn´t exists? > > I must create before? How? > > Many Thans¡¡¡ > [[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] Hi
First PRoblem solved > read.csv("KT80.csv") X x 1 1 0.01331361 > I ommitt "" in calling the file name... 2011/12/14 Trying To learn again > Hi all, > > I have 100 csv files always with this information (I Attach two example > excels) > > KT80.csv contains: > ,"x" > 1,127.188271604938 > > KT80.csv contains > > ,"x" > 1,1.06329287351545 > > > I have three questions: > > First > > When I created this input files I used write.csv and it authomaticaly > creates the structure of the file as you can see. > > Second. If I try to read csv it appears: > > read.csv(KT2.csv,header=T, sep='.') > Error en read.table(file = file, header = header, sep = sep, quote = > quote, : > objeto 'KT2.csv' no encontrado > > But the file is in the right directy > > Third (supossing I can solve the format files) > > My main question is: > > I want to create a matrix (or data frame) for instance from file KT80.csv > to KT81.csv so that the rows are without header and position. > > > > 127.18 > 1.06 > > > Wich function would help me? > > I think I should use something like > > > > ffor (i in 80:81){ > > files <- paste('KT', i, '.csv', sep = '') > > myfun <- function(d) { > > da1 <- read.csv(d) > > Output[i,1]=da1[1,2] > > > > } > > lout<- lapply(files, myfun) > > } > > But results that says Output doesn´t exists? > > I must create before? How? > > Many Thans¡¡¡ > [[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] Omit Inf
Hi all > a<-c(2,Inf) > max(a) [1] Inf > How can I say...omit Inf? I cannot find anything... [[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] MAximum location
Hi all, I have a matrix a<-c(2,3,4,Inf) > b<-as.matrix(a) [,1] [1,]2 [2,]3 [3,]4 [4,] Inf > range(b, finite=TRUE)[2] (this is the maximum) [1] 4 There is a pre-def function to extract the location (in terms of rows) of the value in the matrix. In my example would be 3 (max is in the third row) The maximum is in the position (row) 3. [[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] Database
Hi all, I´m new using Access. I see that many things that you can do on Access you can do on CRAN R but not on contrary. My question is: Is there any manual with examples comparing how to do data base analysis on access and making the same on CRAN R? Imagine I want to compare two columns "Name" of two different data bases. I want to see if there are "identical" names on both files. It is better to use Access? Or it is better to use cran r (importing data and work on CRAN R)? This is only an example. I know CRAN R is more specialized on statistics and data analysis but I ´m trying not to learn Access and SQL so on. I cannot explain better I hope you comprehed me. [[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] No error message no display output
Hi all, I´m re-starting (as my name indicates) my little knowlegde of CRAN R. I made this function time before but I don´t know where is the error because nothing appears as an error but the histogram plot doesn´t appear. Should I install some special library to run sapply? pru<-function(){ randz<-matrix(rnorm(20),100,2000) H<-matrix(0,100,2000) for (j in 2:2000){ for (i in 2:100){ H[1,]<-randz[1,] H[i,j]<-H[i-1,j]+randz[i,j] }} hy<-nrow(H)-1 estima<-H[2:nrow(H),] estima2<-H[1:hy,] a<-estima b<-estima2 mycoef <- function(x, y) coefficients( lm(y ~ x-1) ) rest <- sapply(2:2000, function(i){ y <- a[,i] x <- b[,i] mycoef(x,y) } ) print(summary(rest)) hist(rest,col="blue",breaks=seq(0.6,1.05,0.01),prob=TRUE) lines(density(rest,bw=0.03)) rug(rest) } Many Thanks¡¡¡ [[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] No error message no display output
I´m using this version of R R version 2.13.2 (2011-09-30) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i386-pc-mingw32/i386 (32-bit) 2012/5/5 Trying To learn again > Hi all, > > I´m re-starting (as my name indicates) my little knowlegde of CRAN R. > > I made this function time before but I don´t know where is the error > because nothing appears as an error but the histogram plot doesn´t appear. > Should I install some special library to run sapply? > > > pru<-function(){ > > randz<-matrix(rnorm(20),100,2000) > > H<-matrix(0,100,2000) > > > for (j in 2:2000){ > for (i in 2:100){ > H[1,]<-randz[1,] > H[i,j]<-H[i-1,j]+randz[i,j] > > > }} > > hy<-nrow(H)-1 > > estima<-H[2:nrow(H),] > > estima2<-H[1:hy,] > > > a<-estima > b<-estima2 > > > mycoef <- function(x, y) coefficients( lm(y ~ x-1) ) > > rest <- sapply(2:2000, function(i){ >y <- a[,i] >x <- b[,i] > mycoef(x,y) >} > ) > > > > print(summary(rest)) > > hist(rest,col="blue",breaks=seq(0.6,1.05,0.01),prob=TRUE) > lines(density(rest,bw=0.03)) > rug(rest) > > > > } > > Many Thanks¡¡¡ > > [[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] Editor to program with CRAN R
Hi all, I´m using the windows writting pad (not Notepad the simplest version). I think there should be greater and helping note pads to help programming. Can you suggest one? Many thanks [[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] PLot a matrix
Hi, I want to plot this matrix (I attach the data), it is suposed that each column is a different time series. If I do g<-read.table("dataADF.txt", header=F) and plot(g[,1],type="l") it plots the first column plot if I want in a unique graph each colums of dataA, all in one. How should I proceed?There is a direct pre-defined code? And If I wanted a plot by each column? 0.2511961 0.1048791 0.765 -0.5028332 -0.701 -1.123753 -1.700311 -2.526869 -1.423521 -1.465493 0.8252483 -0.6009678 -0.3566733 0.6114906 0.2656402 1.484138 2.461375 2.330355 2.316502 3.064682 0.4611107 -0.4868384 -0.7425801 -1.013957 0.5306794 1.062024 -0.1228905 -0.6351344 -2.337925 -1.641356 0.807893 -0.4622856 -0.3603809 -0.09382346 0.8860349 1.559422 2.468511 2.243987 1.234574 1.071196 -1.278776 -0.3438066 -0.6652522 0.06149792 -0.4490245 -1.460568 -1.962731 -2.070915 -2.865564 -1.374446 0.7438826 0.2349084 0.4044747 1.316407 0.2948463 0.7690822 -0.401027 0.2678625 -0.3589178 -1.286359 1.371723 1.139646 1.151194 1.30271 0.5325713 1.626423 4.161854 2.820054 1.407645 2.667657 -1.347965 -1.405399 -0.2255252 -0.4259673 -0.0107949 0.5113069 -0.6986957 -2.576082 -1.346436 -2.810367 0.8487415 0.9173517 -0.3868673 0.8938204 1.069388 0.2426122 0.3073049 -0.5796228 -0.613714 -1.295075 1.668746 2.007692 2.566654 0.347605 -1.316739 -1.690626 -1.34602 0.6525972 1.774055 2.422681 -0.2921904 -0.4572776 -0.0831 1.607965 2.697473 1.939636 3.634388 1.866071 0.7101437 -0.006232612 -0.5779149 -2.395087 -2.908561 -0.6105899 -0.8946739 -1.559014 -0.8202216 -0.378958 -1.631353 -0.8313268 -0.07078964 0.2010555 0.4663083 -1.437317 -2.610306 -3.460783 -3.83733 -3.895193 -3.174727 -2.667111 -2.285285 -1.127765 0.2660168 1.057333 -1.030778 -0.2747985 -1.291233 -0.8445686 -0.8744957 -1.280194 2.184299 -0.07775514 1.662162 0.5338424 -0.1041343 -0.05387169 1.154848 2.091877 2.732227 3.03888 -0.66068 0.8348062 1.089835 -1.08487 -0.1976554 -1.295102 -1.885944 -1.980454 -0.5368697 0.598854 -0.7463209 -0.6438774 -1.153221 0.07912086 1.496398 2.282352 1.574552 1.672754 0.9082801 2.105731 -0.2762997 -0.5857024 1.860109 0.9031891 -0.7805179 0.7164917 0.01293016 0.5195865 1.970231 2.468315 -0.3157311 -0.5701688 -0.1400543 0.2648969 0.9611559 0.6384742 0.08256517 1.125626 0.9181709 0.598844 1.014989 1.05152 -0.1168147 -0.0490423 0.9219626 1.861006 2.117454 1.766117 1.504658 0.1686698 -0.8992469 -0.135503 -0.8978528 0.6448676 0.9275989 0.80251 -0.08876881 -1.916651 -2.928887 -1.365382 2.043848 0.1651317 1.290125 2.229226 -0.0944308 0.2114113 0.3230081 -0.4566316 -1.847595 -1.074677 -1.018266 -0.06229867 -2.705829 -1.88546 0.8305156 -0.8986512 -0.3576629 -1.215976 -1.64835 -0.3357197 -2.428899 -2.461352 -1.052128 -0.797792 -0.02897585 0.2429339 -0.8937704 -1.597596 -1.264315 -0.1774461 0.9512131 1.489619 0.1525331 1.867675 0.6770682 1.455974 0.6509501 0.9685468 -0.3988205 1.129755 -1.496245 -0.5946097 0.05279458 -0.328852 -0.05792646 1.034132 0.6637048 1.129939 0.06336816 1.967753 -0.4406342 -0.4599942 1.287785 0.02805429 0.6106788 0.8343703 2.190842 0.9320417 1.486103 1.067876 0.4226051 0.1187309 -0.9908855 -0.4140583 0.03438669 0.2648257 -0.7758414 -1.938909 -1.428154 -1.042515 -0.3868041 -0.4329471 -1.63597 0.2448105 -0.2206876 -0.1556046 0.9957222 -0.1023034 0.814409 0.3461726 -1.301615 -2.610443 -2.237365 0.1296341 -0.1264283 -0.2330937 -0.6713151 -0.9043897 -2.636979 -3.697701 -0.3045346 0.1719403 -0.3931392 1.404483 -0.5422808 -0.4640257 -0.197192 -0.7009865 -2.75533 -3.337157 -2.525135 -2.584804 -2.949444 -1.205625 0.3389667 0.8986387 3.395926 1.818016 1.809293 1.631724 0.3919598 -0.900386 -0.3002419 0.04291678 0.7548589 -0.1586918 0.06735728 1.094125 2.123835 0.9874293 -0.7251489 -0.728092 -0.5626847 -0.7873589 0.0276604 0.9796381 2.571208 3.410983 2.600696 2.817994 -0.8901359 -1.825336 0.6855008 0.02204143 0.8999701 -0.6549752 -1.376338 -1.616452 -2.705169 -3.073808 0.8321419 -1.203327 -1.89387 -1.81901 0.1073112 -0.1083719 2.900365 3.273763 2.528639 5.058792 0.2519627 0.3563369 0.1663799 1.204814 1.250117 2.07772 2.14 1.46357 3.229399 3.594515 -0.3436965 0.4533092 -0.4032535 2.512352 1.762501 1.542535 0.38002 0.0950009 -1.067111 0.8056887 -1.014454 0.3004921 0.2424574 0.6182488 0.5867852 1.325407 0.8636 -1.321926 -0.8127554 0.05006794 -0.7442625 -1.370238 -1.749684 -0.9233801 0.7940143 0.939864 0.2998892 1.850689 1.619476 1.321874 0.3796972 0.309221 1.002049 1.452987 -0.6044611 0.7374052 1.008338 0.2325502 -1.730755 -1.972615 -1.032366 -0.05345409 -0.7619548 -0.5983643 0.1822438 -0.3535287 0.3084443 -0.2422834 -0.9808616 -2.558784 0.1795273 0.8485714 1.982958 0.3688042 2.305633 2.236836 0.8664433 -1.09051 -1.191064 -1.952406 0.1006642 -0.5067429 -1.01859 -0.8602427 -0.07249596 1.771547 1.657481 0.1603193 1.337994 1.823145 -0.8189969 -1.040135 -0.3819819 1.363684 -0.54537 -1.017352 -1.432199 1.141051 0.02111763 -0.4318049 -1.26329 -0.4038025 -0.2005296 -0.8978298 -0.1379912 0.2989914 -0.7765947 -0.4860602 -1.270427 0.1009455 -1.226049 -0.7934141 -2.
[R] Saving a variable
Hi all, I´m trying to use write function to save the output of a program (my constructed "H" matrix) randz<-matrix(rnorm(100),500,2000) H<-matrix(0,500,2000) H[1,]<-randz[1,] for (j in 1:2000){ for (i in 2:500){ if(i<251) H[i,j]<-0.6*H[i-1,j]+randz[i,j] else H[i,j]<-H[i-1,j]+randz[i,j] }} write(H, file = "datad.txt",2000) If I ommit the 2000 on write function it only puts 5 columns. The problem is that if I use this it seems it is not saving the same data I have simulatedor this seems to me. You see if I type H[,1] it is not the same that includen on the firs column on datad.txt? I feel very slow witted Many thanks in advance for all [[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] Error t value matrix
Hi all, I want to make the following: I want to run a linear regression on each column of a matrix "estima" on the correspondent column on the matrix "estima2". You see I want to regress estima[,1] on estima2[,1] this way to all columns At the same time I want to make a regression adding each time a new observation. You see, the first regression will regress only one observation with one observation (I now this has no sense in this only one observation step) the second turn of observation will make estima[1:2,n] on estima2[1:2,n] for all "n". Third stimation will make estima[1:3,n] on estima2[1:3,n] for all "n". And so on. Make this, I want to make an output matrix on each "t-value" associated with the "regressor". Conclusion my final matrix called "t value" should include al the t values on the regression each of them incorporating a new observation, with the same rows and colums than "estima". I have tried several thing but I cannot achive. I writte to see if you can guide me¡¡¡ I swear I´m trying. randz<-matrix(rnorm(5000),50,100) H<-matrix(0,50,100) H[1,]<-randz[1,] for (i in 2:50){ if(i < 26) { H[i, ] <- 0.6 * H[i-1, ] + randz[i, ] } else { H[i, ] <- H[i-1, ] + randz[i, ] } } write.table(H, file = "datad.txt") g<-read.table("datad.txt") hy<-nrow(g)-1 estima<-H[2:nrow(g), ] estima2<-H[ 1:hy, ] mycoef <- function (x,y) a<-estima b<-estima2 f<-summary(lm(a~b)) ff<-coef(f) ff[2,"t value"] tvalue <- sapply (2:ncol(b) , function (i){ y<-a[,i] x<-b[,i] mycoef(x,y) } ) print (summary(tvalue)) [[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] Error t value matrix
Hi all, I have I got it. I see the way on my mind. I will try this week end and if I get it I will send. Thanks. 2012/5/10 Trying To learn again > Hi all, > > I want to make the following: > > I want to run a linear regression on each column of a matrix "estima" on > the correspondent column on the matrix "estima2". > > You see I want to regress estima[,1] on estima2[,1] this way to all > columns > > At the same time I want to make a regression adding each time a new > observation. > > You see, the first regression will regress only one observation with one > observation (I now this has no sense in this only one observation step) > > the second turn of observation will make > > estima[1:2,n] on estima2[1:2,n] for all "n". > > Third stimation will make > > estima[1:3,n] on estima2[1:3,n] for all "n". > > And so on. > > Make this, I want to make an output matrix on each "t-value" associated > with the "regressor". > > Conclusion my final matrix called "t value" should include al the t values > on the regression each of them incorporating a new observation, with the > same rows and colums than "estima". > > I have tried several thing but I cannot achive. > > I writte to see if you can guide me¡¡¡ > > I swear I´m trying. > > > > randz<-matrix(rnorm(5000),50,100) > > H<-matrix(0,50,100) > > H[1,]<-randz[1,] > for (i in 2:50){ > if(i < 26) { >H[i, ] <- 0.6 * H[i-1, ] + randz[i, ] > } else { >H[i, ] <- H[i-1, ] + randz[i, ] > } > } > > > write.table(H, file = "datad.txt") > g<-read.table("datad.txt") > > hy<-nrow(g)-1 > estima<-H[2:nrow(g), ] > estima2<-H[ 1:hy, ] > > mycoef <- function (x,y) > a<-estima > b<-estima2 > f<-summary(lm(a~b)) > ff<-coef(f) > ff[2,"t value"] > tvalue <- sapply (2:ncol(b) , function (i){ > y<-a[,i] > x<-b[,i] > mycoef(x,y) > > } > ) > print (summary(tvalue)) > > > [[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] Error t value matrix
I have it, I have used a simply programmation using loops I have to run the multiple lm with at least 3 variables (because it needs at least 2 degrees of freedom). Many Thanks 2012/5/11 Trying To learn again > Hi all, > > I have I got it. I see the way on my mind. I will try this week end and if > I get it I will send. > > Thanks. > > > 2012/5/10 Trying To learn again > >> Hi all, >> >> I want to make the following: >> >> I want to run a linear regression on each column of a matrix "estima" on >> the correspondent column on the matrix "estima2". >> >> You see I want to regress estima[,1] on estima2[,1] this way to all >> columns >> >> At the same time I want to make a regression adding each time a new >> observation. >> >> You see, the first regression will regress only one observation with >> one observation (I now this has no sense in this only one observation step) >> >> the second turn of observation will make >> >> estima[1:2,n] on estima2[1:2,n] for all "n". >> >> Third stimation will make >> >> estima[1:3,n] on estima2[1:3,n] for all "n". >> >> And so on. >> >> Make this, I want to make an output matrix on each "t-value" associated >> with the "regressor". >> >> Conclusion my final matrix called "t value" should include al the t >> values on the regression each of them incorporating a new observation, with >> the same rows and colums than "estima". >> >> I have tried several thing but I cannot achive. >> >> I writte to see if you can guide me¡¡¡ >> >> I swear I´m trying. >> >> >> >> randz<-matrix(rnorm(5000),50,100) >> >> H<-matrix(0,50,100) >> >> H[1,]<-randz[1,] >> for (i in 2:50){ >> if(i < 26) { >>H[i, ] <- 0.6 * H[i-1, ] + randz[i, ] >> } else { >>H[i, ] <- H[i-1, ] + randz[i, ] >> } >> } >> >> >> write.table(H, file = "datad.txt") >> g<-read.table("datad.txt") >> >> hy<-nrow(g)-1 >> estima<-H[2:nrow(g), ] >> estima2<-H[ 1:hy, ] >> >> mycoef <- function (x,y) >> a<-estima >> b<-estima2 >> f<-summary(lm(a~b)) >> ff<-coef(f) >> ff[2,"t value"] >> tvalue <- sapply (2:ncol(b) , function (i){ >> y<-a[,i] >> x<-b[,i] >> mycoef(x,y) >> >> } >> ) >> print (summary(tvalue)) >> >> >> > [[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] Matrix invert
I all, I have a matrix like this a= 1 4 2 7 3 6 I want to create a new matrix b= 3 6 2 7 1 4 Anyone knows if there is a "reverse" function? I can do it with loops if no exits. [[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] Plot txt
Hi all Sorry in advance I have this txt with data and I want to plot the data with a line between dots. The thing is that if I run this g<-read.table("ip.txt") plot(g,type="l") I have prove to attach(g) but doesn´ t work. I know is a begginer question and sure is of the type of data or the file but I can´t find where is the solution. It appears: Error in plot.default(xlim, ylim, type = "n", ann = FALSE, axes = FALSE, : "type" in associated with multiple argumetns specified Can anyone give me a clue...I will send a Parma ham ¡¡¡Many thaks¡¡¡ I promise not to ask again but I would said I was sure that that sentences worked. 14830 15078 15252 15104 15000 15036 14882 14785 14848 14755 14682 14820 14892 14805 14869 14990 14907 15058 14975 14824 14766 14942 15024 15110 15154 15059 15207 14930 15057 14913 14938 14540 14588 14508 14802 14596 14679 14534 14432 14653 15004 14838 14454 14732 14553 14521 13980 14238 14269 14240 14359 14293 14334 14306 14125 14184 14313 14480 14547 14590 14240 14198 13873 13726 13966 13980 14078 13861 13697 14042 14495 14427 14451 14495 14312 14514 14582 14577 14603 14790 14784 14718 14892 14809 14863 14864 15100 15261 15188 15280 15431 15507 15530 15328 15430 15231 15386 15604 15738 15783 15891 15760 15824 15826 15895 15842 15946 15731 15775 15815 15809 15726 15769 15539 15700 15365 15317 15392 15330 15316 15567 15657 15760 15735 15708 15802 15696 15820 15833 15891 15860 15499 15576 15319 15282 15177 15140 15289 15256 15182 15003 14857 14602 14667 14671 14604 14524 14458 14432 13945 13817 13776 13655 12626 12840 12255 13107 13141 13027 13247 13217 13229 13495 13516 12815 13037 12890 12935 12819 13255 13267 13313 13074 13270 13080 13173 13018 13157 13437 13454 13272 13170 12863 12630 12948 12803 12691 12655 13056 13131 13073 13021 12656 13031 12965 12964 13434 13403 13538 13442 13269 13699 13839 13739 13846 13920 13759 13599 13508 13278 13160 13409 13638 13569 13925 13729 13593 13663 13669 13773 13878 13707 13798 14060 14074 14006 14027 14074 13945 14054 14016 14187 14186 14125 14248 13992 13857 13852 13578 13584 13451 13499 13540 13601 13300 13432 13341 13239 12910 12824 12755 12584 12853 12999 12827 12885 12632 12585 12413 12403 12206 12446 12078 12090 12046 11771 11857 11980 11766 11982 11795 12000 11740 11384 11443 11152 11288 11642 11895 11785 11610 11935 11675 11590 11485 11684 11818 11881 11570 11448 11751 11774 11718 11800 12048 11996 11695 11607 11686 11678 11335 11380 11217 11497 11327 11420 11480 11663 11707 11694 11904 11849 11480 11140 11554 11350 11181 11137 11412 10899 10912 10661 10632 11558 11329 11177 3 11439 11388 10946 10988 11183 11002 11419 10726 10862 10298 9903 8998 9956 10225 9707 9308 9655 9944 9795 8995 8811 8353 8010 7905 8650 8823 9116 9232 9727 9745 9134 9344 9294 8912 8647 8741 8832 8499 8531 8212 7988 7974 8623 8697 8654 8849 8911 8511 8835 8880 8836 8491 9037 9063 9152 9183 8976 9024 9168 9197 9258 9268 9099 9069 9018 9196 9486 9644 9724 9570 9470 9379 9200 9057 8693 8611 8620 8495 8277 8231 8159 8173 8375 8350 8702 8477 8450 8233 8362 8495 8440 8545 8585 8397 8356 8201 8266 8075 7843 7861 7876 7604 7540 7483 7512 7812 7621 7271 7219 7358 7026 6937 6817 7153 7205 7341 7428 7637 7645 7662 7702 7710 7952 7990 8072 8076 7928 7601 7815 7961 8335 8320 8321 8346 8405 8705 8835 8712 8875 9031 8718 8616 8834 8769 8777 8656 8891 9038 9075 9137 9229 9229 9408 9317 9269 9001 8984 8979 9159 9342 9389 9225 9309 9347 9406 9511 9436 9424 9631 9665 9465 9455 9519 9396 9498 9628 9708 9714 9519 9498 9283 9384 9581 9339 9349 9618 9667 9687 9846 9788 9904 9644 9708 9569 9520 9361 9443 9345 9567 9634 9905 9998 10042 10143 10122 10153 10370 10439 10592 10664 10662 10874 10855 10901 10877 10704 10776 10948 10923 10832 10934 11047 10902 10599 10708 10696 10893 11161 11304 11428 11376 11357 11443 11365 11173 11000 11018 11223 11389 11367 11462 11341 11453 11493 11593 11747 11771 11777 11727 11817 11853 11696 11644 11891 11854 11756 11518 11327 11557 11817 11721 11814 11743 11749 11608 11871 11850 11676 11885 11790 11875 11829 11740 11623 11634 11430 11683 11415 11466 11242 11388 11549 11581 11817 11814 11801 11835 11867 11987 11959 12034 11846 11719 11941 11905 11966 11658 11777 11645 11862 11869 11905 12032 12012 11809 11541 11595 11616 11706 11736 11863 11697 11645 11831 11891 11968 12023 12035 11940 12145 12204 12223 12166 12163 12075 11966 11958 12000 11845 11871 12023 11709 11444 11373 11249 11347 11042 10829 10948 10995 11141 10888 10242 10103 10206 10275 10455 10282 10225 10294 10394 10499 10574 10677 10571 10313 10254 10126 10334 10435 10522 10665 10745 11020 11078 11003 11121 11045 11077 10958 11059 11167 11074 10991 10862 10996 10866 11091 11071 11091 10981 10871 11068 11161 11191 11076 11394 11461 11461 11504 11524 11260 11200 11306 11065 10822 10918 10939 10481 10167 10441 10492 10423 9859 9635 9353 9046 10352 10009 10090 9978 9315 9286 9628 9377 9271 9407 9288 9004 9043 9335 9426 9359 9300 9268 9276 8923 8795 8670 8869 9198 9562 9584 9742 96