[R] How to search in each excel in my working dir and extract part information of one product in each country?
Hello, I have created many excel files in my working dir. each excel file contain one country's data. In the excel, I have dataframe in sheet1, where each product and its relative information is in each row as following: ProductPERetail_price_Band Country Model_Fit A -2.5 0-50 CN 84% B -2.1 51-100 CN90% . not every product presents in each country, in other words, they may have common products or not. How do I create program in R to search each excel file in my working dir in order to make the list of the such product for each country based on my input(for example, I want to have all information related to product B in each country) the result what I want: ProductPERetail_price_Band Country Model_Fit B -2.4 51-100IN 80% B -2.1 51-100 CN90% How do I achieve this? thanks. Kind regards, Lingyi [[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 to list the all products' information of the latest month?
Hi, I have data frame like this: Product PriceYear_Month PE A 100201012 -2 A 98 201101-3 A 97 201102-2.5 B 110 201101-1 B 100 201102-2 B 90 201103-4 How can I achieve the following result using R: Product PriceYear_Month PE A 97 201102-2.5 B 90 201103-4 in other words, list the all products' information of the latest month? Thanks for your help. Kind regards, Lingyi [[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 to make the labels of pie chart are not overlapping?
I have the following dataframe: Productpredicted_MarketShare Predicted_MS_Percentage A2.827450e-02 2.8 B4.716403e-06 0.0 C1.741686e-01 17.4 D 1.716303e-04 0.0 ... Because there are so many products, and most of predicted Market share is around 0%. When I make pie chart, the labels of those product with 0% market share are overlapping. How do I make the labels are not overlapping? Kind regards. Tammy [[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 to change `Year_Month)201103` into Year_Month)201103 using R?
HI, I have the pattern like `Year_Month)201103` I want to delete single quotes within double quetes. I want to change it into Year_Month)201103 , how to do it in r? Thanks a lot. Tammy [[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 to achieve big vector times big dataframe in R?
HI, I have the following question: Vector a with lenght 150 A B C D. dataframe b with dim 908X150 1 1 1 1. 2 2 2 2 3 3 3 3 4 4 4 4 final result I want is the vector with length 908: A*1+B*1+C*1+D*1+. A*2+B*2+C*2+D*2+. A*3+B*3+C*3+D*3+. A*4+B*4+C*4+D*4+. because of too large dimension, how can I achieve this in R? Thanks. Kind Regards, Tammy [[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] Excel User interface for R
HI, Assume I have the data frame generated from R as the following: Product Price market_share A 10010% B 1109% C 12020% D 90 61% What I want to do is to have this kind of excel user interface by changing price of certain products, to get the impact of market share generated from R: if I change A price from 100 to 90, and change B price from 110 to 100, based on the calculation in R, I want to get the result from excel, for example, Product Price market_share A 9020% B 100 12% C 120 10% D 90 58% I want to have the excel interface which make me be able to change the value in excel cell, then based on the calculation in R, then exported market share impact in excel. DO you have recommendation for such user interface or sth which make me achieve this task? Thanks. Kind regards, Lingyi [[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 to name the elements of list
HI, I have the array list: X-vector(list, 2) X[[1]] : data frame 1 X[[2]]: dataframe2 now i want to change index 1 and 2 into: 0-10 , 11-20 ,. finally I want to have X[[0-10]]:dataframe1 X[[11-20]]:dataframe2 how do I get them? Thanks a lot. Kind regards, Tammy [[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 name the elements of list
Hello,Thanks a lot for your help. each index represents the different price band. I more prefer to use price band info as 0-10 instead of 1... I just can not find the way to do it. Kind regards, Tammy Date: Fri, 25 Jan 2013 10:46:45 +0100 From: ivan.calan...@u-bourgogne.fr To: r-help@r-project.org Subject: Re: [R] How to name the elements of list Hi Tammy, Are you just looking for names()? Not sure, but it can be troublesome to have - in a name. HTH, Ivan -- Ivan CALANDRA Université de Bourgogne UMR CNRS/uB 6282 Biogéosciences 6 Boulevard Gabriel 21000 Dijon, FRANCE +33(0)3.80.39.63.06 ivan.calan...@u-bourgogne.fr http://biogeosciences.u-bourgogne.fr/calandra Le 25/01/13 10:39, Tammy Ma a écrit : HI, I have the array list: X-vector(list, 2) X[[1]] : data frame 1 X[[2]]: dataframe2 now i want to change index 1 and 2 into: 0-10 , 11-20 ,. finally I want to have X[[0-10]]:dataframe1 X[[11-20]]:dataframe2 how do I get them? Thanks a lot. Kind regards, Tammy [[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. [[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 to load data from .accdb into R?
HI, All, I have three dabases: analysis_tool.accdb is linked into sellout.mdb and audit.accdb. whenever I use this database, I need to firstly open analysis_tool, then press External data-Linked Table Manager to link the other two databases. Now I want to load the data from those database into R, I know I can use the following queries to load data from Analysis_tool .accdb into R: library(RODBC) testdb - file.path(C:/Users/ty/Documents/Analysis_tool.accdb) channel - odbcConnectAccess2007(testdb) Data - sqlFetch(channel,Table1) how do I load data from all those linked databases but not only Analysis_tool.accdb? Kind regards, Tammy [[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 to delete the null elements in list
HI, I have the list: suu [[1]] NULL [[2]] NULL [[3]] item_id prod 1 2 [[4]] item_id prod 1 2 2 4 how to delete all NULL elements from suu to get only suu [[3]] item_id prod 1 2 [[4]] item_id prod 1 2 2 4 ?? Kind regards, Tammy [[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 to combine unequal rows and columns in R
HI, I have the following list: crosspries $crosspries[[1]] Product Year_Month prod1 A 2012081 B 2012082 C 2012081 $crosspries[[2]] Product Year_Monthprod1 prod2 A 201209 1 1 B 201209 2 2 D 201209 1 1 F 201209 2 1 I want to get the following dataframe: Product Year_Month prod1prod2 A 201208 1 NA B 201208 2 NA C 201208 1 NA D 201208 NA NA F201208 NA NA A 201209 1 1 B 201209 2 2 C201209 NA NA D201209 1 1 F201209 2 1 How can I get it in r? Thanks. Kind regards, Tammy [[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 should I make the optional arguments in r?
HI, I guess I did sth wrong with the optional argument in the program. but I don't know how should I make it. in my main program: source(getelasticity_overPB.r) crossprice-getelasticity(mydata,mydatao,nest)$cross_p is same with crossprice-getelasticity(mydata,mydatao)$cross_p I don't know why In getelasticity_overPB.r: I have the function: getelasticity=function(mydata,mydatao,method=NULL){ . source(runmodel.r) rr-getrange(dataw,mydatao,method=NULL) #I have tested that rr-getrange(dataw,mydatao) is different with rr-getrange(dataw,mydatao,nest): which is what I want. rr } how should I make it work??? Thanks for your help. Kind regards, Tammy [[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 to align group based on the common values of two columns in r
HI, I met this problem: I have the feature data frame: Feature OS 4 2 4 1 4 3 1 2 4 1 what I want to do is to autimatically create one more column called group: Feature OS Group 4 2 1 4 1 2 4 3 3 1 2 4 4 1 2 I don't want Ifelse, because I have so many combination of feature and OS, I even can not account. I just want to have sth to autimatically create group indicator based on the difference combination of feature and OS. Thanks for your help. Kind regards, Tammy [[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 import the large dataset into R
does anybody can help me on this? From: metal_lical...@live.com To: r-help@r-project.org Subject: How to import the large dataset into R Date: Fri, 14 Dec 2012 11:01:03 +0300 HI, R Users, I met the following problem: I was trying to import data of one table in .accdb database into my ODBC database for being imported into R. The table contains 1021965 records. I always got the following error msg even I change the drive: The query can not be completed. Either the size of the query result is larger than the maximum size of a database(2GB), or there is not enough storage space on the disk to store the query result. Have you got some hints why it happened like this? Is it possible that I get all data in that table in another way to be imported into R? Thanks a lot. Kind regards.Tammy [[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 to import the large dataset into R
HI, R Users, I met the following problem: I was trying to import data of one table in .accdb database into my ODBC database for being imported into R. The table contains 1021965 records. I always got the following error msg even I change the drive: The query can not be completed. Either the size of the query result is larger than the maximum size of a database(2GB), or there is not enough storage space on the disk to store the query result. Have you got some hints why it happened like this? Is it possible that I get all data in that table in another way to be imported into R? Thanks a lot. Kind regards.Tammy [[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 to aggregate the data ?
HI, now I have dataset: Product Price_LC.1 Price_LC.2 Price_elasticity.1 Price_elasticity.2 Mean_Price Mean_Price_elasticity Trade_Price_Band Country 1 100 357580.1 527483.6 -4.1498383 -2.8459564 473934.0-3.6935476 0-542811 VN 51208 436931.9 536143.9 -3.9432305 -3.4570170 469330.2-3.6595372 0-542811 VN 61280 419666.6 520936.3 -1.7357983 -0.7689443 461367.0-1.2848528 0-542811 VN 2 101 629371.0 735167.2 -5.2289933 -3.0364372 676059.9-3.8059064542812-904779 VN 71616 576816.1 663369.6 -4.5528840 -3.9523261 614864.5-4.3181914542812-904779 VN 81661 583587.9 689853.0 -5.0948101 -4.3427497 650680.0-4.8109781542812-904779 VN I want to get the following dataset: Product VN Price_band 100 -3.69354760-542811 [357580.1, 527483.6 ] [-2.8459564, 473934.0] 1208-3.6595372 0-542811 [436931.9, 536143.9] [-3.9432305, -3.4570170] how do I get this in r?? Thanks. Kind regards, Lingyi [[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 to aggregate the dataset?
HI, I want to transform the following dataset Product Price_LC.1 Price_LC.2 Price_elasticity.1 Price_elasticity.2 Mean_Price Mean_Price_elasticity Trade_Price_Band Country 100 35 52 -4.14 -2.84 47 -3.69 0-542811 VN 1208 43 53 -3.94 -3.45 47 -3.65 0-542811 VN into: Product VN Price_Band 100 -3.69 0-542811 [35,52] [43,53] 1208 -3.65 0-542811 [43,53] [-3.94,-3.45] How do I get it in R? I have large dataset like this, I need to create mechanism to tranform those. Thanks. Kind regards, Lingyi [[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 to aggregate the dataset
HI, Sorry for messing up.. I want to transform the following dataset: product min_price max_price mean_price country price_band 11 34 50 40 VN 0-300 22 10 30 15 VN 0-300 Into: product VN price_band 11400-300 [34,50] 22150-300 [10,30] How can I do this in r? I have large dataset like this. I want to transform all into that one. Thanks a lot. Kind regards, Tammy [[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 aggregate the dataset
Really sorry for messing up. I want to transform: product min_price max_price mean_price country price_band 11 34 50 40 VN 0-300 2210 30 15 VN 0-300 into Into: product VN price_band 11 40 0-300 [34,50] 22 15 0-300 [10,30] How Can I do this in r? Kind regards, Tammy From: metal_lical...@live.com To: metal_lical...@live.com Subject: RE: [R] how to aggregate the dataset Date: Thu, 13 Dec 2012 14:22:54 +0300 HI, I want it looks like this: Into: product VN price_band 11 40 0-300 [34,50] 22 15 0-300 [10,30] From: metal_lical...@live.com To: r-help@r-project.org Date: Thu, 13 Dec 2012 13:42:35 +0300 Subject: [R] how to aggregate the dataset HI, Sorry for messing up.. I want to transform the following dataset: product min_price max_price mean_price country price_band 11 34 50 40 VN 0-300 22 10 30 15 VN 0-300 Into: product VN price_band 11 40 0-300 [34,50] 22 15 0-300 [10,30] How can I do this in r? I have large dataset like this. I want to transform all into that one. Thanks a lot. Kind regards, Tammy [[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] How to create multiple country's data into multiple sheets of one excel
HI, I have large dataset of many countries. I have written the program to run through each country to generate one output for each country. I want to put the output like this: one sheet has output for one country. How do I achieve it by r. I have tried this: library(xlsx) write.xlsx(nnn, vn.xlsx, sheetName=Sheet1) [1] but when I change sheetName=Sheet2 to add up another country into one sheet. it autimatically deleted which I have down on [1]. index-unique(dataset$country) for (i in 1:length(index)){ data-dataset[dataset$country==index[i],] (...) output-dd #then how do I create each country's output into one sheet of one excel??? } Kind regards, Tammy [[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 to grep in r
Hi, I met this problem. Trade_Price_Band x 1 0-30 0.6237240 2 101-150 0.6743857 3 151-200 0.6778513 4 201-300 0.6640293 5 301-400 0.6630991 6 31-50 0.6314547 7 401-500 0.6776249 8 500+ 0.6557705 9 51-75 0.6621073 10 76-100 0.6623469 I want to get the following matrix Trade_Price_Band x 1 300.6237240 2 150 0.6743857 3 200 0.6778513 4 300 0.6640293 how can I get this in r? Thanks. Tammy [[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 to assign factor level into each value
HI, All I met the following problem. I dont know how to handle it. Country Price 1 CN 44.25 2 CN 21.07 3 CN 92.70 4 CN 47.41 5 CN111.67 6 CN 50.57 I want to create the 3rd colume with different factor levels: [1] 0-3051-75 31-50 76-100 101-150 151-200 201-300 500+ [9] 301-400 401-500 then the final result which I want is: Country Pricelevels 1 CN 44.25 31-50 2 CN 21.07 0-30 3 CN 92.70 76-100 4 CN 47.41 31-50 5 CN111.67101-150 6 CN 50.57 51-75 How can I do this? Thanks. Tammy [[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] map two names into one
Thanks. Yes. Your approach can identify: Glaxy ace S 5830 and S 5830 Glaxy ace But you can not identify using same program: Iphone 4S 16 G Iphone 4S 16G How should I solve both in same time. Kind regards,Tammy [[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 to read all table in r using dbreadTable, autimatically read in whenever I save new table in SQLite db
HI, I got the problem. I use the following query to read table individually, how can I read all tables autimatically rather than typing week42 week33 in dbReadTable? library(RSQLite) library(sqldf) drv - dbDriver(SQLite) con-dbConnect(drv, sqlite.db) dbListTables(con) #dbRemoveTable(con, week39) dbDisconnect(con) week42- dbReadTable(con, week_42) week33- dbReadTable(con, week33) week30- dbReadTable(con, week30) Another one is if I save new table in sqlite db, I hope R programs can autimatically read in the new table, how can I achieve it? Thanks. Tammy [[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 Can make function for selecting the products
HI. I make this code: getdata-function('a','b','c' ,'d','e','f'){ drv - dbDriver(SQLite) con-dbConnect(drv, sqlite.db) lt-dbListTables(con) myf-data.frame(NULL) for (i in 1:length(lt)) { myfile-dbReadTable(con,lt[i]) myfile1-myfile[-c(14:44)] myfile1$MODEL-gsub( , , myfile1$MODEL) library(RSQLite) library(sqldf) my_file-sqldf(SELECT * FROM myfile1 where MODEL in ('a','b','c' ,'d','e','f')) my.file.spes-conv(my_file) myf-rbind(myf,my.file.spes) } wd-myf[order(myf$Product, myf$Time),] wd1-wd[!duplicated(wd),] wd2-as.data.frame(as.matrix(wd1),stringsAsFactors = FALSE) wd3-transform(wd2, Price = as.numeric(Price), Volume = as.numeric(Volume)) dbDisconnect(con) return(wd3) } I want this program also work when I use wd3-getdata(a,b,c,d,e,f,g,h...) for any length of my selection. How should I do this then? Thanks- Tammy [[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] can not read table in dbReadTable
tbs-dbListTables(con) tbs [1] lowend time week30 week33 week39 week42 my.data.copy - dbReadTable(tbs, week42) Error in function (classes, fdef, mtable) : unable to find an inherited method for function dbReadTable, for signature character, character I have created tables in db. but there is this error show up when I try to read the table in my db.. whats wrong with it?? Thanks a lot. Tammy [[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] Which test should I use for comparing the change of two samples
Dear All, I have two samples as the following: conjps-c(9.41,10.45,10.78,10.73,11.11,11.12,11.59,11.04,11.63) ms-c(4.11,5.10,5.70,6.46,6.04,6.16, 6.24,6.32,7.33) I want to test the change of sample is same to the another one. conjps_ch-c(1.04,0.33.) ms-c(0.99,0.60,0.76) which test I should use, which conclusion can we drive based on the test? I used the following test: Test Equality of Two Variances F test to compare two variances data: conjps and ms F = 0.5419, num df = 8, denom df = 8, p-value = 0.4045 alternative hypothesis: true ratio of variances is not equal to 1 95 percent confidence interval: 0.1222368 2.4024170 sample estimates: ratio of variances 0.5419076 is it correct? which conclusion can I get based on this? Thanks for help. Kind regards, Tammy [[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 to replace the row number for each product by real product name in as.dendrogram in cluster analysis..HELP!
data1-data.matrix(newdata) # transforming the factor into different values data.use-data1[,-c(1,2,3)] # leaving the value matrix data.dist = dist(data.use) data.hclust = hclust(data.dist) #complete linkage is used #if I plot the following one, I have too large data set(rows`=9980), can not see clearly all the product names in graph plot(data.hclust,hang=-1,labels=newdata$Product,main='Default from hclust') #so I decide to see the part of dendrogram using hcd = as.dendrogram(data.hclust) plot(cut(hcd, h=5)$lower[[46]]) By this way I could be able to see the 46th branch of the dendrogram. but then I met the problem. In the selected branch, all product are expressed by the row numbers. How can I transform the row numbers into the names of products as newdata$Product. I have been struggling for long time. I can not find the better solution.Thanks a lot. Tammy [[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] Instrumental variables for the competitive price
Dear R user, I have been setting up the models for predicting the volume based on the price information of own product and competitive products. one option is to use instrumental variable to break price into two parts: one part that might be correlated with error term, and the another part that is not. But now I met the problem of choosing instumental variables. I have searched many papers. it has been mentioned that cost can be used as one instrumental variable for the price. yes. I can use cost for own price. but how about the competitive price's instrumental variables? I don't know their cost information at all except their price information and market share. I will be really appreciated if someone can suggest me the possible choices of instrumental variables for the competitive price? Thanks in advance. Kind regards, Tammy [[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] Testing the equality of two variances
Dear R-User, I met the problem to test equality of variance. Two sample units: conjps-c(9.41,10.45,10.78,10.73,11.11,11.12,11.59,11.04,11.63) ms-c(4.11,5.10,5.70,6.46,6.04,6.16, 6.24,6.32,7.33) Then I use the F test to test: Test Equality of Two Variances F test to compare two variances data: conjps and ms F = 0.5419, num df = 8, denom df = 8, p-value = 0.4045 alternative hypothesis: true ratio of variances is not equal to 1 95 percent confidence interval: 0.1222368 2.4024170 sample estimates: ratio of variances 0.5419076 but If conjps is replaced by conjps1: shifting the first value and the last value position conjps1-c(11.36,10.45,10.78,10.73,11.11,11.12,11.59,11.04,9.41) I do believe we get the same result when testing the equity of variance. but how do I distringuish this two cases by testing? Kind regards,Tammy [[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] map two names into one
Dear R user: I have got the following problem: I have imported two data sets into R: one set includes price information, another one includes volume information. but I noticed the wrong data order problem in the product name, for instance, in one data set, GALAXY ACE S 5830 in another one, it is S 5830 GALAXY ACE both represent same product. how do i map two name into one in R? there are so many product name having this problem. i hope there is some mechanism which can autimatically map those. thanks for your help.. Kind regards, Tammy [[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] missing price datas before launched
HI, I have the price and volume data from own product and competitor's product: Year_Month Volume own product's price Volume competitor's price 1 201011 17583469.03 NA NA 2 201012 33899489.25 NA NA 3 201101 31306488.42 NA NA 4 201102 21272479.07 173 550 5 201103 24145462.99 2684 548 6 201104 20763433.87 4787 475 7 201105 25337410.22 9805 430 8 201106 21793422.5214096 388 9 201107 26081417.7617452 383 10 201108 21933420.8622432 373 11 201109 21560396.5317678 353 12 201110 28538360.4917864 349 13 20 20995346.4711857 340 14 201112 42961353.4935938 332 15 201201 26378341.4920544 330 16 201202 21531350.8216259 339 17 201203 19386365.9514361 348 18 201204 20441347.0612255 357 because competitor's product was launched at 201102. so I am having missing data before that time for competitor's product and volume after I merge all data together. my aim to set up the model based on the data. because I have so less data points. I don't want to delete those rows with NA records. but How should I handle this case? I am thinking to use mean imputation. but is it suitable for this case? Thank you so much for your reply. Kind regards, Tammy [[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] Day or Month difference between dates???
HI, R-Users: I got a questions. have been struggling so long time I have this data: m1$Year_Month 201009 201010 201011 201101 201102 min(m1$Year_Month) 201009 I want to calculate the following two answers, how do I program it? difference in Month? [1] 0 1 2 4 5 difference in Days? 0 31 61 Thank you in advance!!! Tammy [[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 to import .accda database into R
Dear R user: How to import .accda database into R? I have tried many ways, still doesn't work. Thanks in advance. Kind regards, Tammy [[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] Please Help me!
Hi, R-users, I have a problem: Because there are few files which can't be readed into R completely, so on the following subsequence programme, I use write.table, which creates the NA files for those incomplete files autimatically. I don't want those NA files. My programes formats looks like: name_c-Sys.glob(C:/Documents and Settings/lma/My Documents/habitdata/*/calllog/*) for (i in 1:length(name_c)){ log1-readLines(name_c[i]) write.table(Temps, file=paste(C:/Documents and Settings/lma/My Documents/habitdata1,pname,lname,basename(name_c[i]),sep=/)) } Error Information: Error in file(file, ifelse(append, a, w)) : cannot open the connection In file(file, ifelse(append, a, w)) : cannot open file 'C:/Documents and Settings/lma/My Documents/habitdata1/NA/NA/NA': Permission denied I have checked why the error appears, because when I use readLines to read data, but when processing the large data set, there are few files which can not be readed in completely: 48: In readLines(name_c[i]) ... : incomplete final line found on 'C:/Documents and Settings/lma/My Documents/habitdata/244052900243997/calllog/calllog_log-20050505T121611.txt' ... So it create the NA file when implementing the subsequence procedure by write.table.How can I do: whenever readLines can't completely read one file, then autimatically doesn't implement the subsequence programmes? Thanks. Tammy _ More than messagescheck out the rest of the Windows Live. http://www.microsoft.com/windows/windowslive/ [[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] The problem of readLines
Dear R-users, I use readLines to read data, but when processing the large data set, there are few files which can not be readed in: 48: In readLines(name_c[i]) ... : incomplete final line found on 'C:/Documents and Settings/lma/My Documents/habitdata/244052900243997/calllog/calllog_log-20050505T121611.txt' ... Whats the problem about this? Regards, Tammy _ More than messagescheck out the rest of the Windows Live. http://www.microsoft.com/windows/windowslive/ [[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] Debug
From: metal_lical...@live.com To: r-help@r-project.org Subject: Debug Date: Thu, 1 Oct 2009 15:21:42 +0300 Hi, R-Users,' I have written a programe to process the bunch of files in one folder. But there is a error came out; How can I know which file returns error when being processed? I have tested the first 1-10th files, no any problem. But the problems is I have more than 500 files. How can I know which file has the problem? Thanks Tammy Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! Try it! _ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=createwx_url=/friends.aspxmkt=en-us [[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] The problem of readLines
I have a more problem: Because there are few files which can't be read into R completely, so on the following subsequence programme, I use write.table, which creates the NA files for those incomplete files autimatically. I don't want those NA files. How can I do the following: whenever readLines can't completely read one file, then autimatically remove it from my dataset? Thanks. Tammy From: www...@gmail.com Date: Thu, 1 Oct 2009 11:06:35 -0300 Subject: Re: [R] The problem of readLines To: metal_lical...@live.com CC: r-help@r-project.org From the help page for readLines: If the final line is incomplete (no final EOL marker) the behaviour depends on whether the connection is blocking or not. For a non-blocking text-mode connection the incomplete line is pushed back, silently. For all other connections the line will be accepted, with a warning. You can disable the warning with; readLines('your_file', warn = FALSE) On Thu, Oct 1, 2009 at 9:39 AM, Tammy Ma metal_lical...@live.com wrote: Dear R-users, I use readLines to read data, but when processing the large data set, there are few files which can not be readed in: 48: In readLines(name_c[i]) ... : incomplete final line found on 'C:/Documents and Settings/lma/My Documents/habitdata/244052900243997/calllog/calllog_log-20050505T121611.txt' ... Whats the problem about this? Regards, Tammy _ More than messagescheck out the rest of the Windows Live. http://www.microsoft.com/windows/windowslive/ [[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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O _ Drag n dropGet easy photo sharing with Windows Live Photos. http://www.microsoft.com/windows/windowslive/products/photos.aspx [[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] Change directory to implement same programes
HI, R-Users, I have one problem: I have written the the programs which process all file in one directory: for example: setwd(C:/Documents and Settings/lma/My Documents/Vappu-saved/Log) as the start. .. But I have many folders like Vappu-saved and there are a lot of files in each directory. What I want is using the same program what I write for the above directory to autimatically change directory address to implement the above programs what I wrote. How do I realize it? Thanks a lot. Regards, Lingyi _ Windows Live: Keep your life in sync. Check it out! http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t1_allup_explore_012009 [[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] Change directory to implement same programes
How do I source a bunch of files in different directories in R? From: metal_lical...@live.com To: r-help@r-project.org Date: Wed, 30 Sep 2009 13:45:34 +0300 Subject: [R] Change directory to implement same programes HI, R-Users, I have one problem: I have written the the programs which process all file in one directory: for example: setwd(C:/Documents and Settings/lma/My Documents/Vappu-saved/Log) as the start. .. But I have many folders like Vappu-saved and there are a lot of files in each directory. What I want is using the same program what I write for the above directory to autimatically change directory address to implement the above programs what I wrote. How do I realize it? Thanks a lot. Regards, Lingyi _ Windows Live: Keep your life in sync. Check it out! http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t1_allup_explore_012009 [[alternative HTML version deleted]] _ Show them the way! Add maps and directions to your party invites. http://www.microsoft.com/windows/windowslive/products/events.aspx [[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 to parsing data like this in R
Hi, R-users, I met a problem: Items:[Anna 'moi =) akku loppu joskus 4ltä. Kestää kauan nää..'\tAmer, Tuusula (0:20)\t20\t12\t16\t00\t00\t11]/Anne 'Ei jakoa,uus päivä muistio et 4n niin peruin. Hups'\t (0:16)\t0\t12\t18\t00\t00\t11/Elina 'Konsertissa. En tod. vastaa teille'\tEtu-Töölö, Helsinki (2:40)\t24\t12\t18\t00\t00\t11 I want to parsing the above data into the below according to each /: [Anna 'moi =) akku loppu joskus 4ltä. Kestää kauan nää..'\tAmer, Tuusula (0:20)\t20\t12\t16\t00\t00\t11] Anne 'Ei jakoa,uus päivä muistio et 4n niin peruin. Hups'\t (0:16)\t0\t12\t18\t00\t00\t11 Elina 'Konsertissa. En tod. vastaa teille'\tEtu-Töölö, Helsinki (2:40)\t24\t12\t18\t00\t00\t11 My problem is / may also appear in either of above 3 strings so I can't use strsplit. But I having trying to use regular expression. But I still can't figure out how can I implement it into what I want? Any suggestion? Kind regards, Tammy _ Windows Live: Keep your life in sync. Check it out! http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t1_allup_explore_012009 [[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] Manipulate directory-help
Dear R-users, I have a problem: I have many files in the directory:C:/Documents and Settings/lma/Desktop/FamilyAEntrepreneurs/Entrepreneurs/Juha I want to copy those files into the new directory: C:/Documents and Settings/lma/My Documents/Juha/book (-use paste), I first create the directory using dir.create, but it looks doesnt work. How do I implement this copy operations in R? Thanks for help Tammy _ Show them the way! Add maps and directions to your party invites. http://www.microsoft.com/windows/windowslive/products/events.aspx [[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] Create directory and copy files in R
HI, All R users, My problem is: fn [1] C:/Documents and Settings/lma/Desktop/FamilyAEntrepreneurs/Entrepreneurs/Juha/book_log-20041210T095019.txt dpath [1] C:/Documents and Settings/lma/My Documents/Juha/book I want to make a function cyfun to copy all files in dir to deskdir but I always got the following problem: Error in file.exists(to) : invalid 'file' argument. Whats the problem?? cyfun-function(fn,dpath){ dir-dirname(fn) fn-basename(fn) deskdir-dir.create(dpath) file.copy(fn, deskfile) } Thanks! Tammy _ Drag n dropGet easy photo sharing with Windows Live Photos. http://www.microsoft.com/windows/windowslive/products/photos.aspx [[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] power analysis for 2-way anova
Dear R-help list, Does anyone have a function that I could use to determine power for 2 way Anova?? an A x B repeated measures study,power is 0.95, I'd like to draw separate lines for three different combinations of A and B: (2,2), (2,5), (2,8). Thanks a lot. Tammy _ Show them the way! Add maps and directions to your party invites. http://www.microsoft.com/windows/windowslive/products/events.aspx [[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] data frame
HI, R user, I generate the vectors with the same length. I want to put each vector into each column of data frame. Why it doesnt work`? rm-data.frame() for(a in 1:6){ rm[,a]-getmeasure(p1,a,speech) } thanks a lot Tammy _ Share your memories online with anyone you want. http://www.microsoft.com/middleeast/windows/windowslive/products/photos-share.aspx?tab=1 [[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] Generate random sample interval
Hi, R users, I have a problem about how to generate random sample interval from a duration. For example, during a time duration 0-70s, I want to generate a sample which last 10s. the sample could be 0-10 or 30-40s or 25-35s etc How could I do it in R`?? Thanks a lot. Tammy _ Share your memories online with anyone you want. http://www.microsoft.com/middleeast/windows/windowslive/products/photos-share.aspx?tab=1 [[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] Generate random sample interval
I need a simple algorithm to generate random ranges. From: metal_lical...@live.com To: r-help@r-project.org Date: Mon, 24 Aug 2009 09:55:35 +0300 Subject: [R] Generate random sample interval Hi, R users, I have a problem about how to generate random sample interval from a duration. For example, during a time duration 0-70s, I want to generate a sample which last 10s. the sample could be 0-10 or 30-40s or 25-35s etc How could I do it in R`?? Thanks a lot. Tammy _ Share your memories online with anyone you want. http://www.microsoft.com/middleeast/windows/windowslive/products/photos-share.aspx?tab=1 [[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. _ Show them the way! Add maps and directions to your party invites. http://www.microsoft.com/windows/windowslive/products/events.aspx [[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 manipulation
From: metal_lical...@live.com To: r-help@r-project.org Subject: About Matrix Date: Tue, 28 Apr 2009 11:28:43 +0300 Hi, Dear R users, I have a question: I have A matrix which is 11519X14 and B matrix which is 1764X14, How do I get C matrix which is The remaining matrix after removing B from A? Thanks a lot. Kind regards, Tammy check out the rest of the Windows Live. More than mailWindows Live goes way beyond your inbox. More than messages _ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=createwx_url=/friends.aspxmkt=en-us [[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] About Matrix
Hi, Dear R users, I have a question: I have A matrix which is 11519X14 and B matrix which is 1764X14, How do I get C matrix which is The remaining matrix after removing B from A? Thanks a lot. Kind regards, Tammy _ More than messagescheck out the rest of the Windows Live. http://www.microsoft.com/windows/windowslive/ [[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] About the proportion of data
Hi, All. I have scatterplot in 2-D I'd like to see which proportion of data goes into a range. How shall I figure it out? Perhaps some accumulative graph or something? Kind regards, Tammy _ Drag n dropGet easy photo sharing with Windows Live Photos. http://www.microsoft.com/windows/windowslive/products/photos.aspx [[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] Merging.
Hi, All. I have a data frame with the part as : . 1422006-02-22 16:28:18 useractivity_act 8 0 1432006-02-22 16:28:26 42 0 1442006-02-22 16:28:28 33 0 1452006-02-22 16:28:31 44 1 1462006-02-22 16:28:35 3 1590 1472006-02-22 16:31:14 useractivity_idle0 0 1421 2006-02-22 16:28:18 useractivity_act 8 0 1431 2006-02-22 16:28:26 42 0 1441 2006-02-22 16:28:28 33 0 1451 2006-02-22 16:28:31 44 0 1461 2006-02-22 16:28:35 3 15925 1471 2006-02-22 16:31:14 useractivity_idle0 0 I want to merge the above as 1422006-02-22 16:28:18 useractivity_act 8 0 1432006-02-22 16:28:26 42 0 1442006-02-22 16:28:28 33 0 1452006-02-22 16:28:31 44 1 1462006-02-22 16:28:35 3 159 25 1472006-02-22 16:31:14 useractivity_idle0 0 How should I do`?? Thanks. Tammy _ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=createwx_url=/friends.aspxmkt=en-us [[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] Merging
Hi, All. I have a data frame with the part as : . 1422006-02-22 16:28:18 useractivity_act 8 0 1432006-02-22 16:28:26 42 0 1442006-02-22 16:28:28 33 0 1452006-02-22 16:28:31 44 1 1462006-02-22 16:28:35 3 1590 1472006-02-22 16:31:14 useractivity_idle0 0 1421 2006-02-22 16:28:18 useractivity_act 8 0 1431 2006-02-22 16:28:26 42 0 1441 2006-02-22 16:28:28 33 0 1451 2006-02-22 16:28:31 44 0 1461 2006-02-22 16:28:35 3 15925 1471 2006-02-22 16:31:14 useractivity_idle0 0 I want to merge the above as 1422006-02-22 16:28:18 useractivity_act 8 0 1432006-02-22 16:28:26 42 0 1442006-02-22 16:28:28 33 0 1452006-02-22 16:28:31 44 1 1462006-02-22 16:28:35 3 159 25 1472006-02-22 16:31:14 useractivity_idle0 0 How should I do`?? Thanks. Tammy _ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=createwx_url=/friends.aspxmkt=en-us [[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] Merging
Thanks for your reply, I couldn't use the method what the example gives. Because Data frame is quite big, and it has so many rows which are repeated. I am not pretty sure about the range of 1000. It turns out I should merge those row which repeated. Tammy From: simon.pick...@bto.org To: metal_lical...@live.com; r-help@r-project.org Subject: Re: [R] Merging Date: Tue, 17 Mar 2009 10:02:51 + Hi, I'm pretty sure you dont mean merge since merge() creates a new big data frame from two small ones. It appears that you want to omit some rows. As I said before, get used to selecting rows like this data.frame-data.frame[data.frame$conditional.rows1000,] (for example) Although I dont have a clue what criteria you are using to select the rows you want... Simon. Hi, All. I have a data frame with the part as : . 1422006-02-22 16:28:18 useractivity_act 8 0 1432006-02-22 16:28:26 42 0 1442006-02-22 16:28:28 33 0 1452006-02-22 16:28:31 44 1 1462006-02-22 16:28:35 3 1590 1472006-02-22 16:31:14 useractivity_idle0 0 1421 2006-02-22 16:28:18 useractivity_act 8 0 1431 2006-02-22 16:28:26 42 0 1441 2006-02-22 16:28:28 33 0 1451 2006-02-22 16:28:31 44 0 1461 2006-02-22 16:28:35 3 15925 1471 2006-02-22 16:31:14 useractivity_idle0 0 I want to merge the above as 1422006-02-22 16:28:18 useractivity_act 8 0 1432006-02-22 16:28:26 42 0 1442006-02-22 16:28:28 33 0 1452006-02-22 16:28:31 44 1 1462006-02-22 16:28:35 3 159 25 1472006-02-22 16:31:14 useractivity_idle0 0 How should I do`?? Thanks. Tammy _ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=createwx_url=/friends.aspxmkt=en-us [[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. _ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=createwx_url=/friends.aspxmkt=en-us [[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] Merging
Sorry, I didn't sent it twice, but there is some problem on my emailSorry for this. Tammy From: metal_lical...@live.com To: r-help@r-project.org Date: Tue, 17 Mar 2009 11:49:10 +0200 Subject: [R] Merging Hi, All. I have a data frame with the part as : . 1422006-02-22 16:28:18 useractivity_act 8 0 1432006-02-22 16:28:26 42 0 1442006-02-22 16:28:28 33 0 1452006-02-22 16:28:31 44 1 1462006-02-22 16:28:35 3 1590 1472006-02-22 16:31:14 useractivity_idle0 0 1421 2006-02-22 16:28:18 useractivity_act 8 0 1431 2006-02-22 16:28:26 42 0 1441 2006-02-22 16:28:28 33 0 1451 2006-02-22 16:28:31 44 0 1461 2006-02-22 16:28:35 3 15925 1471 2006-02-22 16:31:14 useractivity_idle0 0 I want to merge the above as 1422006-02-22 16:28:18 useractivity_act 8 0 1432006-02-22 16:28:26 42 0 1442006-02-22 16:28:28 33 0 1452006-02-22 16:28:31 44 1 1462006-02-22 16:28:35 3 159 25 1472006-02-22 16:31:14 useractivity_idle0 0 How should I do`?? Thanks. Tammy _ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=createwx_url=/friends.aspxmkt=en-us [[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. _ Show them the way! Add maps and directions to your party invites. http://www.microsoft.com/windows/windowslive/products/events.aspx [[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] Merging
My aim is not only relect unduplicated column, I also want merge the last column beside selection Thanks. Tammy Date: Tue, 17 Mar 2009 06:59:20 -0400 From: pcho...@ncsu.edu To: metal_lical...@live.com CC: r-help@r-project.org Subject: Re: [R] Merging Is this what you want it to do ('n' is the original data frame)? n v V1 V2 V3 V4 1 k a 2 1 2 2 l b 1 2 1 3 m c 2 1 2 4 n d 1 2 1 5 o e 2 1 2 n1 - n[,3:5] n2 - duplicated(n1) n3 - n[!n2,] n3 v V1 V2 V3 V4 1 k a 2 1 2 2 l b 1 2 1 Pankaj Tammy Ma wrote: Thanks for your reply, I couldn't use the method what the example gives. Because Data frame is quite big, and it has so many rows which are repeated. I am not pretty sure about the range of 1000. It turns out I should merge those row which repeated. Tammy From: simon.pick...@bto.org To: metal_lical...@live.com; r-help@r-project.org Subject: Re: [R] Merging Date: Tue, 17 Mar 2009 10:02:51 + Hi, I'm pretty sure you dont mean merge since merge() creates a new big data frame from two small ones. It appears that you want to omit some rows. As I said before, get used to selecting rows like this data.frame-data.frame[data.frame$conditional.rows1000,] (for example) Although I dont have a clue what criteria you are using to select the rows you want... Simon. Hi, All. I have a data frame with the part as : . 1422006-02-22 16:28:18 useractivity_act 8 0 1432006-02-22 16:28:26 42 0 1442006-02-22 16:28:28 33 0 1452006-02-22 16:28:31 44 1 1462006-02-22 16:28:35 3 1590 1472006-02-22 16:31:14 useractivity_idle0 0 1421 2006-02-22 16:28:18 useractivity_act 8 0 1431 2006-02-22 16:28:26 42 0 1441 2006-02-22 16:28:28 33 0 1451 2006-02-22 16:28:31 44 0 1461 2006-02-22 16:28:35 3 15925 1471 2006-02-22 16:31:14 useractivity_idle0 0 I want to merge the above as 1422006-02-22 16:28:18 useractivity_act 8 0 1432006-02-22 16:28:26 42 0 1442006-02-22 16:28:28 33 0 1452006-02-22 16:28:31 44 1 1462006-02-22 16:28:35 3 159 25 1472006-02-22 16:31:14 useractivity_idle0 0 How should I do`?? Thanks. Tammy _ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=createwx_url=/friends.aspxmkt=en-us [[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. _ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=createwx_url=/friends.aspxmkt=en-us [[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. _ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=createwx_url=/friends.aspxmkt=en-us [[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] Merging
Does anyone know the solution`? Thanks, Tammy From: metal_lical...@live.com To: r-help@r-project.org Date: Tue, 17 Mar 2009 11:49:10 +0200 Subject: [R] Merging Hi, All. I have a data frame with the part as : . 1422006-02-22 16:28:18 useractivity_act 8 0 1432006-02-22 16:28:26 42 0 1442006-02-22 16:28:28 33 0 1452006-02-22 16:28:31 44 1 1462006-02-22 16:28:35 3 1590 1472006-02-22 16:31:14 useractivity_idle0 0 1421 2006-02-22 16:28:18 useractivity_act 8 0 1431 2006-02-22 16:28:26 42 0 1441 2006-02-22 16:28:28 33 0 1451 2006-02-22 16:28:31 44 0 1461 2006-02-22 16:28:35 3 15925 1471 2006-02-22 16:31:14 useractivity_idle0 0 I want to merge the above as 1422006-02-22 16:28:18 useractivity_act 8 0 1432006-02-22 16:28:26 42 0 1442006-02-22 16:28:28 33 0 1452006-02-22 16:28:31 44 1 1462006-02-22 16:28:35 3 159 25 1472006-02-22 16:31:14 useractivity_idle0 0 How should I do`?? Thanks. Tammy _ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=createwx_url=/friends.aspxmkt=en-us [[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. _ More than messagescheck out the rest of the Windows Live. http://www.microsoft.com/windows/windowslive/ [[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] Merging
I still couldn't solve itany help would be preciated! Tammy From: metal_lical...@live.com To: r-help@r-project.org Date: Tue, 17 Mar 2009 11:49:10 +0200 Subject: [R] Merging Hi, All. I have a data frame with the part as : . 1422006-02-22 16:28:18 useractivity_act 8 0 1432006-02-22 16:28:26 42 0 1442006-02-22 16:28:28 33 0 1452006-02-22 16:28:31 44 1 1462006-02-22 16:28:35 3 1590 1472006-02-22 16:31:14 useractivity_idle0 0 1421 2006-02-22 16:28:18 useractivity_act 8 0 1431 2006-02-22 16:28:26 42 0 1441 2006-02-22 16:28:28 33 0 1451 2006-02-22 16:28:31 44 0 1461 2006-02-22 16:28:35 3 15925 1471 2006-02-22 16:31:14 useractivity_idle0 0 I want to merge the above as 1422006-02-22 16:28:18 useractivity_act 8 0 1432006-02-22 16:28:26 42 0 1442006-02-22 16:28:28 33 0 1452006-02-22 16:28:31 44 1 1462006-02-22 16:28:35 3 159 25 1472006-02-22 16:31:14 useractivity_idle0 0 How should I do`?? Thanks. Tammy _ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=createwx_url=/friends.aspxmkt=en-us [[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. _ Show them the way! Add maps and directions to your party invites. http://www.microsoft.com/windows/windowslive/products/events.aspx [[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] Merging
Thanks. Actually, I have been trying many time using method from KJ, There is always the following information coming up or Rgui exit without reason.. I have no idea about this? gh-with(act_data12, aggregate(V4, by=list(V1,V2,V3), sum)) Error in unlist(y, recursive = FALSE) : promise already under evaluation: recursive default argument reference or earlier problems? Tammy Date: Tue, 17 Mar 2009 15:23:44 +0200 From: annette.heissw...@utu.fi Subject: Re: [R] Merging To: metal_lical...@live.com; r-help@r-project.org Tammy, You won't get more help if you post this again every half an hour... I don't quite understand what you exactly want to do, but it seemed at least to me that Keith's suggestion (see again below) pretty much does what you want. If not, could you please specify *EXACTLY* what you want to do. Thanks! Annette From: Keith Jewell k.jewell_at_campden.co.uk Date: Tue, 17 Mar 2009 12:23:34 + Is this what you want it to do? (aDF is the original data frame) aDF V1V2 V3 V4 1 2006-02-22 16:28:18 useractivity_act 8 0 2 2006-02-22 16:28:26 4 2 0 3 2006-02-22 16:28:28 3 3 0 4 2006-02-22 16:28:31 4 4 1 5 2006-02-22 16:28:35 3 159 0 6 2006-02-22 16:31:14 useractivity_idle 0 0 7 2006-02-22 16:28:18 useractivity_act 8 0 8 2006-02-22 16:28:26 4 2 0 9 2006-02-22 16:28:28 3 3 0 10 2006-02-22 16:28:31 4 4 0 11 2006-02-22 16:28:35 3 159 25 12 2006-02-22 16:31:14 useractivity_idle 0 0 with(aDF, aggregate(V4, by=list(V1, V2, V3), sum)) Group.1 Group.2 Group.3 x 1 2006-02-22 16:31:14 useractivity_idle 0 0 2 2006-02-22 16:28:26 4 2 0 3 2006-02-22 16:28:28 3 3 0 4 2006-02-22 16:28:31 4 4 1 5 2006-02-22 16:28:18 useractivity_act 8 0 6 2006-02-22 16:28:35 3 159 25 hth Keith J Tammy Ma schrieb: I still couldn't solve itany help would be preciated! Tammy From: metal_lical...@live.com To: r-help@r-project.org Date: Tue, 17 Mar 2009 11:49:10 +0200 Subject: [R] Merging Hi, All. I have a data frame with the part as : . 1422006-02-22 16:28:18 useractivity_act 8 0 1432006-02-22 16:28:26 42 0 1442006-02-22 16:28:28 33 0 1452006-02-22 16:28:31 44 1 1462006-02-22 16:28:35 3 1590 1472006-02-22 16:31:14 useractivity_idle0 0 1421 2006-02-22 16:28:18 useractivity_act 8 0 1431 2006-02-22 16:28:26 42 0 1441 2006-02-22 16:28:28 33 0 1451 2006-02-22 16:28:31 44 0 1461 2006-02-22 16:28:35 3 15925 1471 2006-02-22 16:31:14 useractivity_idle0 0 I want to merge the above as 1422006-02-22 16:28:18 useractivity_act 8 0 1432006-02-22 16:28:26 42 0 1442006-02-22 16:28:28 33 0 1452006-02-22 16:28:31 44 1 1462006-02-22 16:28:35 3 159 25 1472006-02-22 16:31:14 useractivity_idle0 0 How should I do`?? Thanks. Tammy -- Annette Heisswolf Section of Ecology Department of Biology University of Turku 20014 Turku, Finland _ Drag n dropGet easy photo sharing with Windows Live Photos. http://www.microsoft.com/windows/windowslive/products/photos.aspx [[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] Merging
My data frame is: str(act_data12) 'data.frame': 1687 obs. of 5 variables: $ Date: chr 2006-02-22 2006-02-22 2006-02-22 2006-02-22 ... $ Dtime : chr 14:36:10 14:36:11 14:36:12 14:37:38 ... $ FocusApp_seq: chr useractivity_act 4 3 0 ... $ App_duration: int 1 1 86 58 1 1 9 3 1 41 ... $ Frequency : int 0 0 22 0 1 0 0 0 0 0 ... I used: gh-with(act_data12, aggregate(Frequency, by=list(Date, Dtime, FocusApp_seq, App_duration), sum)) Error info: Error in unlist(y, recursive = FALSE) : promise already under evaluation: recursive default argument reference or earlier problems? or R exited when running.. Thanks for your concentration. Tammy To: r-h...@stat.math.ethz.ch From: k.jew...@campden.co.uk Date: Tue, 17 Mar 2009 12:23:34 + Subject: Re: [R] Merging Is this what you want it to do? (aDF is the original data frame) aDF V1V2 V3 V4 1 2006-02-22 16:28:18 useractivity_act 8 0 2 2006-02-22 16:28:26 4 2 0 3 2006-02-22 16:28:28 3 3 0 4 2006-02-22 16:28:31 4 4 1 5 2006-02-22 16:28:35 3 159 0 6 2006-02-22 16:31:14 useractivity_idle 0 0 7 2006-02-22 16:28:18 useractivity_act 8 0 8 2006-02-22 16:28:26 4 2 0 9 2006-02-22 16:28:28 3 3 0 10 2006-02-22 16:28:31 4 4 0 11 2006-02-22 16:28:35 3 159 25 12 2006-02-22 16:31:14 useractivity_idle 0 0 with(aDF, aggregate(V4, by=list(V1, V2, V3), sum)) Group.1 Group.2 Group.3 x 1 2006-02-22 16:31:14 useractivity_idle 0 0 2 2006-02-22 16:28:26 4 2 0 3 2006-02-22 16:28:28 3 3 0 4 2006-02-22 16:28:31 4 4 1 5 2006-02-22 16:28:18 useractivity_act 8 0 6 2006-02-22 16:28:35 3 159 25 hth Keith J Tammy Ma metal_lical...@live.com wrote in message news:bay0-dp3-858363e64f6ed84f9f6f486...@phx.gbl... My aim is not only relect unduplicated column, I also want merge the last column beside selection Thanks. Tammy Date: Tue, 17 Mar 2009 06:59:20 -0400 From: pcho...@ncsu.edu To: metal_lical...@live.com CC: r-help@r-project.org Subject: Re: [R] Merging Is this what you want it to do ('n' is the original data frame)? n v V1 V2 V3 V4 1 k a 2 1 2 2 l b 1 2 1 3 m c 2 1 2 4 n d 1 2 1 5 o e 2 1 2 n1 - n[,3:5] n2 - duplicated(n1) n3 - n[!n2,] n3 v V1 V2 V3 V4 1 k a 2 1 2 2 l b 1 2 1 Pankaj Tammy Ma wrote: Thanks for your reply, I couldn't use the method what the example gives. Because Data frame is quite big, and it has so many rows which are repeated. I am not pretty sure about the range of 1000. It turns out I should merge those row which repeated. Tammy From: simon.pick...@bto.org To: metal_lical...@live.com; r-help@r-project.org Subject: Re: [R] Merging Date: Tue, 17 Mar 2009 10:02:51 + Hi, I'm pretty sure you dont mean merge since merge() creates a new big data frame from two small ones. It appears that you want to omit some rows. As I said before, get used to selecting rows like this data.frame-data.frame[data.frame$conditional.rows1000,] (for example) Although I dont have a clue what criteria you are using to select the rows you want... Simon. Hi, All. I have a data frame with the part as : . 1422006-02-22 16:28:18 useractivity_act 8 0 1432006-02-22 16:28:26 42 0 1442006-02-22 16:28:28 33 0 1452006-02-22 16:28:31 44 1 1462006-02-22 16:28:35 3 1590 1472006-02-22 16:31:14 useractivity_idle0 0 1421 2006-02-22 16:28:18 useractivity_act 8 0 1431 2006-02-22 16:28:26 42 0 1441 2006-02-22 16:28:28 33 0 1451 2006-02-22 16:28:31 44 0 1461 2006-02-22 16:28:35 3 15925 1471 2006-02-22 16:31:14 useractivity_idle0 0 I want to merge the above as 1422006-02-22 16:28:18 useractivity_act 8 0 1432006-02-22 16:28:26 42 0 1442006-02-22 16:28:28 33 0 1452006-02-22 16:28:31 44 1 1462006-02-22 16:28:35 3 159 25 1472006-02-22 16:31:14 useractivity_idle0 0 How should I do`?? Thanks. Tammy
[R] Removing
Hi All, act_2 DateDtime Hour Min Second Rep 51 2006-02-22 14:52:18 14 52 18 useractivity_act 52 2006-02-22 14:52:18 14 52 18 4 55 2006-02-22 14:52:49 14 52 49 4 57 2006-02-22 14:52:51 14 52 51 4 58 2006-02-22 14:52:52 14 52 52 3 60 2006-02-22 14:54:42 14 54 42 useractivity_idle I want to change act_2 to DateDtime Hour Min Second Rep 51 2006-02-22 14:52:18 14 52 18 useractivity_act 52 2006-02-22 14:52:18 14 52 18 4 58 2006-02-22 14:52:52 14 52 52 3 60 2006-02-22 14:54:42 14 54 42 useractivity_idle in other word, I want to keep 1st if there are many repeated value, I made the program as: rm_r-function(act_2){ dm-dim(act_2)[1]-1 for(i in 2:dm){ if(act_2$Rep[j]==act_2$Rep[i]){ act_2-act_2[-j,] }else{ act_2-act_2 } } return(act_2) } But it only remove one row..whats the problem? How should i modify it? Thanks alot. Tammy _ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=createwx_url=/friends.aspxmkt=en-us [[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] Removing rows
Hi All, act_2 DateDtime Hour Min Second Rep 51 2006-02-22 14:52:18 14 52 18 useractivity_act 52 2006-02-22 14:52:18 14 52 18 4 55 2006-02-22 14:52:49 14 52 49 4 57 2006-02-22 14:52:51 14 52 51 4 58 2006-02-22 14:52:52 14 52 52 3 60 2006-02-22 14:54:42 14 54 42 useractivity_idle I want to change act_2 to DateDtime Hour Min Second Rep 51 2006-02-22 14:52:18 14 52 18 useractivity_act 52 2006-02-22 14:52:18 14 52 18 4 58 2006-02-22 14:52:52 14 52 52 3 60 2006-02-22 14:54:42 14 54 42 useractivity_idle in other word, I want to keep 1st if there are many repeated value, I made the program as: rm_r-function(act_2){ dm-dim(act_2)[1]-1 for(i in 2:dm){ if(act_2$Rep[i+1]==act_2$Rep[i]){ act_2-act_2[-(i+1),] }else{ act_2-act_2 } } return(act_2) } when it moved one row on 1st loop, i should still start 2 but it become 3 at 2nd loop, if I add i-i-1, then i go to 1 seems not reasonbale. How should I modify it`? Tammy _ News, entertainment and everything you care about at Live.com. Get it now! http://www.live.com/getstarted.aspx [[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] who can give me some hint?
Hi All, act_2 DateDtime Hour Min Second Rep 51 2006-02-22 14:52:18 14 52 18 useractivity_act 52 2006-02-22 14:52:18 14 52 18 4 55 2006-02-22 14:52:49 14 52 49 4 57 2006-02-22 14:52:51 14 52 51 4 58 2006-02-22 14:52:52 14 52 52 3 60 2006-02-22 14:54:42 14 54 42 useractivity_idle I want to change act_2 to DateDtime Hour Min Second Rep 51 2006-02-22 14:52:18 14 52 18 useractivity_act 52 2006-02-22 14:52:18 14 52 18 4 58 2006-02-22 14:52:52 14 52 52 3 60 2006-02-22 14:54:42 14 54 42 useractivity_idle in other word, I want to keep 1st if there are many repeated value, I made the program as: rm_r-function(act_2){ dm-dim(act_2)[1]-1 for(i in 2:dm){ if(act_2$Rep[i+1]==act_2$Rep[i]){ act_2-act_2[-(i+1),] }else{ act_2-act_2 } } return(act_2) } when it moved one row on 1st loop, i should still start 2 but it become 3 at 2nd loop, if I add i-i-1, then i go to 1 seems not reasonbale. How should I modify it`? Tammy _ Drag n dropGet easy photo sharing with Windows Live Photos. http://www.microsoft.com/windows/windowslive/products/photos.aspx [[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] who can give me some hint?
Thanks a lot for your reply. I expect a more flexible solution. Because I couldn't check that column one by one. If another Rep colum is: useractivity_act 2 2 3 3 3 4 5 5 6 useractivity_idle i should be able to write a program to make it as: useractivity_act 2 3 4 5 6 useractivity_idle Only keep 1st value of repeated values. I have been working no it for a whileStill didnt get solution. Thanks for your concentration. Tammy Date: Thu, 12 Mar 2009 08:03:11 -0400 Subject: Re: [R] who can give me some hint? From: ggrothendi...@gmail.com To: metal_lical...@live.com CC: r-help@r-project.org I assume the problem is to only keep those rows whose Rep value is not equal to the Rep value in the prior row. In that case just compare c(, Rep[-nr]) to Rep and use the resulting vector, ix, to select out rows. Rep - as.character(act_2$Rep) could be simplified to Rep - act_2$Rep if Rep is already known to be character. Lines - DateDtime Hour Min Second Rep 51 2006-02-22 14:52:18 14 52 18 useractivity_act 52 2006-02-22 14:52:18 14 52 18 4 55 2006-02-22 14:52:49 14 52 49 4 57 2006-02-22 14:52:51 14 52 51 4 58 2006-02-22 14:52:52 14 52 52 3 60 2006-02-22 14:54:42 14 54 42 useractivity_idle act_2 - read.table(textConnection(Lines), header = TRUE, as.is = TRUE) nr - nrow(act_2) Rep - as.character(act_2$Rep) ix - Rep != c(, Rep[-nr]) act_2[ix] On Thu, Mar 12, 2009 at 6:25 AM, Tammy Ma metal_lical...@live.com wrote: Hi All, act_2 DateDtime Hour Min Second Rep 51 2006-02-22 14:52:18 14 52 18 useractivity_act 52 2006-02-22 14:52:18 14 52 18 4 55 2006-02-22 14:52:49 14 52 49 4 57 2006-02-22 14:52:51 14 52 51 4 58 2006-02-22 14:52:52 14 52 52 3 60 2006-02-22 14:54:42 14 54 42 useractivity_idle I want to change act_2 to DateDtime Hour Min Second Rep 51 2006-02-22 14:52:18 14 52 18 useractivity_act 52 2006-02-22 14:52:18 14 52 18 4 58 2006-02-22 14:52:52 14 52 52 3 60 2006-02-22 14:54:42 14 54 42 useractivity_idle in other word, I want to keep 1st if there are many repeated value, I made the program as: rm_r-function(act_2){ dm-dim(act_2)[1]-1 for(i in 2:dm){ if(act_2$Rep[i+1]==act_2$Rep[i]){ act_2-act_2[-(i+1),] }else{ act_2-act_2 } } return(act_2) } when it moved one row on 1st loop, i should still start 2 but it become 3 at 2nd loop, if I add i-i-1, then i go to 1 seems not reasonbale. How should I modify it`? Tammy _ Drag n dropGet easy photo sharing with Windows Live Photos. http://www.microsoft.com/windows/windowslive/products/photos.aspx [[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. _ News, entertainment and everything you care about at Live.com. Get it now! http://www.live.com/getstarted.aspx [[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] debug
Hi, All I have so many files in my directory. I got the following error. At this time, I couldn't use debug() to check error one by one because so many files getting invloved. How can I get some idea about my error?? . Skipping book_log-20060222T143612.txt Skipping book_log-20060222T162828.txt Skipping book_log-20060222T162833.txt Skipping book_log-20060222T183742.txt Skipping book_log-20060222T201442.txt Skipping book_log-20060224T153841.txt Skipping book_log-20060224T184225.txt Skipping book_log-20060224T193621.txt Skipping book_log-20060224T193957.txt Skipping book_log-20060225T110011.txt Skipping book_log-20060225T125836.txt Skipping book_log-20060225T131002.txt Processing book_log-20060225T165935.txt Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format Thanks a lot. Tammy _ More than messagescheck out the rest of the Windows Live. http://www.microsoft.com/windows/windowslive/ [[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] Repeated values
Hi,All. How to make a program to delete repeated value? a example c [1] 4 3 0 3 4 1 0 1 4 4 3 4 3 4 I want to get : 4 3 0 3 4 1 0 1 4 3 4 3 4 two 4 is being represented by one 4. Thanks. Tammy _ More than messagescheck out the rest of the Windows Live. http://www.microsoft.com/windows/windowslive/ [[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] Date frame
Hi, All, How to make a data frame, each row of data frame store the different length of vector? Thanks. Tammy _ Show them the way! Add maps and directions to your party invites. http://www.microsoft.com/windows/windowslive/products/events.aspx [[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] Date frame
I have produced the data frame(1) as: starting_timeEnding_time session_1: 14:36:1014:40:44 session_2: 14:40:47 14:41:47 for each session, I produced different sequences as: seq_1-c(4 ,3, 0 ,3 ,4 ,1, 0 ,1 ,4 ,3 ,4 ,3 ,4) seq_2-c(3,4,1,2) seq_3-Null I want to put those to the 3rd column of data frame (1) corresponding the individual session. How could I do so? Originally, I want to create a data frame with each row contains different sequence and then put to 3rd column, which seems couldn't be done. thanks. Tammy Date: Wed, 11 Mar 2009 07:50:37 -0400 Subject: Re: [R] Date frame From: jholt...@gmail.com To: metal_lical...@live.com CC: r-help@r-project.org It is called a list. On Wed, Mar 11, 2009 at 6:32 AM, Tammy Ma metal_lical...@live.com wrote: Hi, All, How to make a data frame, each row of data frame store the different length of vector? Thanks. Tammy _ Show them the way! Add maps and directions to your party invites. http://www.microsoft.com/windows/windowslive/products/events.aspx [[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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? _ Show them the way! Add maps and directions to your party invites. http://www.microsoft.com/windows/windowslive/products/events.aspx [[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 monthly,daily,yearly average
Check as.Date Date: Wed, 11 Mar 2009 06:25:44 -0700 From: qflic...@yahoo.com To: r-help@r-project.org Subject: [R] How to monthly,daily,yearly average Sorry, this is my first time to post. I have a big data set: first colume is date (ex: 2008-2-150, the second is time (10:30:00), and the following columes are variaty measurement data. Every 30 min, I have one data. I want to find an effecient way to calculate the hourly, daily, monthly and yearly average, and plot them, and eventually use these average data to do further analysis. Thanks! Jeff [[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. _ News, entertainment and everything you care about at Live.com. Get it now! http://www.live.com/getstarted.aspx [[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] About the merge
hi, All. DateDtime Hour Min Second Rep App_dur 9 2006-02-22 14:36:11 14 36 11 4 1 10 2006-02-22 14:36:12 14 36 12 3 86 11 2006-02-22 14:37:38 14 37 38 0 58 14 2006-02-22 14:38:36 14 38 36 3 1 15 2006-02-22 14:38:37 14 38 37 4 1 16 2006-02-22 14:38:38 14 38 38 1 9 18 2006-02-22 14:38:47 14 38 47 0 3 20 2006-02-22 14:38:50 14 38 50 1 1 21 2006-02-22 14:38:51 14 38 51 4 2 *** 23 2006-02-22 14:38:53 14 38 53 4 39 *** 25 2006-02-22 14:39:32 14 39 32 3 1 26 2006-02-22 14:39:33 14 39 33 4 1 27 2006-02-22 14:39:34 14 39 34 3 8 28 2006-02-22 14:39:42 14 39 42 4 62 How to write a program to merge Rep with consecutive equal numbers to one of that number and sum up App_dur?? on the above data frame, i want to merge 21 2006-02-22 14:38:51 14 38 51 4 2 *** 23 2006-02-22 14:38:53 14 38 53 4 39 *** to 2006-02-22 14:38:51 14 38 51 4 41 and represent original two *** by the new one like: 9 2006-02-22 14:36:11 14 36 11 4 1 10 2006-02-22 14:36:12 14 36 12 3 86 11 2006-02-22 14:37:38 14 37 38 0 58 14 2006-02-22 14:38:36 14 38 36 3 1 15 2006-02-22 14:38:37 14 38 37 4 1 16 2006-02-22 14:38:38 14 38 38 1 9 18 2006-02-22 14:38:47 14 38 47 0 3 20 2006-02-22 14:38:50 14 38 50 1 1 2006-02-22 14:38:51 14 38 51 4 41 *** 25 2006-02-22 14:39:32 14 39 32 3 1 26 2006-02-22 14:39:33 14 39 33 4 1 27 2006-02-22 14:39:34 14 39 34 3 8 28 2006-02-22 14:39:42 14 39 42 4 62 ?? Thanks. Tammy _ Drag n dropGet easy photo sharing with Windows Live Photos. http://www.microsoft.com/windows/windowslive/products/photos.aspx [[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.