[R] Reading a large directory of compressed zips into a data frame
Hello R Programmers! I was wondering if y'all could help me. I'm trying to read data from a directory containing 332 compressed zips all with about 1000 lines (or more) of data into a data frame. I have it so that the directory is set to the file with the zips in it. I figured this way when I tried using the dir() function, I could do something like d1 <- read.csv(dir()[1:332]) to read all the data and then find the mean of say "columnA" in that data table by using something like mean(d1$columnA). Though, so far this has not worked. Any ideas? Sincerely, Giles [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Difficulty subsetting data frames using logical operators
So, I uploaded a data set via my directory using the command data <- data.frame(read.csv("hw1_data.csv")) and then tried to subset that data using logical operators. Specifically, I was trying to make it so that I got all the rows in which the values for "Ozone" (a column in the data set) were greater than 31 (I was trying to get the mean of all said values). Then, I tried using the command data[ , "Ozone">31]. Additionally, I had trouble getting it so that I had all the rows where all the values in "Ozone">31 & "Temp">90 simultaneously. There were some NA values in both of those columns, so that might be it. If someone could help me to figure out how to remove those values, that'd be great as well. I'm using a Mac (OS X) with the latest version of R (3.1.2. I think??). Here is some of the code I used: >data <- data.frame(read.csv("hw1_data.csv")) > data Ozone Solar.R Wind Temp Month Day 1 41 190 7.4 67 5 1 2 36 118 8.0 72 5 2 3 12 149 12.6 74 5 3 4 18 313 11.5 62 5 4 5 NA NA 14.3 56 5 5 6 28 NA 14.9 66 5 6 7 23 299 8.6 65 5 7 8 19 99 13.8 59 5 8 9 8 19 20.1 61 5 9 10 NA 194 8.6 69 5 10 11 7 NA 6.9 74 5 11 12 16 256 9.7 69 5 12 13 11 290 9.2 66 5 13 14 14 274 10.9 68 5 14 15 18 65 13.2 58 5 15 16 14 334 11.5 64 5 16 17 34 307 12.0 66 5 17 18 6 78 18.4 57 5 18 19 30 322 11.5 68 5 19 20 11 44 9.7 62 5 20 21 1 8 9.7 59 5 21 22 11 320 16.6 73 5 22 23 4 25 9.7 61 5 23 24 32 92 12.0 61 5 24 25 NA 66 16.6 57 5 25 26 NA 266 14.9 58 5 26 27 NA NA 8.0 57 5 27 28 23 13 12.0 67 5 28 29 45 252 14.9 81 5 29 30115 223 5.7 79 5 30 31 37 279 7.4 76 5 31 32 NA 286 8.6 78 6 1 33 NA 287 9.7 74 6 2 34 NA 242 16.1 67 6 3 35 NA 186 9.2 84 6 4 36 NA 220 8.6 85 6 5 37 NA 264 14.3 79 6 6 38 29 127 9.7 82 6 7 39 NA 273 6.9 87 6 8 40 71 291 13.8 90 6 9 41 39 323 11.5 87 6 10 42 NA 259 10.9 93 6 11 43 NA 250 9.2 92 6 12 44 23 148 8.0 82 6 13 45 NA 332 13.8 80 6 14 46 NA 322 11.5 79 6 15 47 21 191 14.9 77 6 16 48 37 284 20.7 72 6 17 49 20 37 9.2 65 6 18 50 12 120 11.5 73 6 19 51 13 137 10.3 76 6 20 52 NA 150 6.3 77 6 21 53 NA 59 1.7 76 6 22 54 NA 91 4.6 76 6 23 55 NA 250 6.3 76 6 24 56 NA 135 8.0 75 6 25 57 NA 127 8.0 78 6 26 58 NA 47 10.3 73 6 27 59 NA 98 11.5 80 6 28 60 NA 31 14.9 77 6 29 61 NA 138 8.0 83 6 30 62135 269 4.1 84 7 1 63 49 248 9.2 85 7 2 64 32 236 9.2 81 7 3 65 NA 101 10.9 84 7 4 66 64 175 4.6 83 7 5 67 40 314 10.9 83 7 6 68 77 276 5.1 88 7 7 69 97 267 6.3 92 7 8 70 97 272 5.7 92 7 9 71 85 175 7.4 89 7 10 72 NA 139 8.6 82 7 11 73 10 264 14.3 73 7 12 74 27 175 14.9 81 7 13 75 NA 291 14.9 91 7 14 76 7 48 14.3 80 7 15 77 48 260 6.9 81 7 16 78 35 274 10.3 82 7 17 79 61 285 6.3 84 7 18 80 79 187 5.1 87 7 19 81 63 220 11.5 85 7 20 82 16 7 6.9 74 7 21 83 NA 258 9.7 81 7 22 84 NA 295 11.5 82 7 23 85 80 294 8.6 86 7 24 86108 223 8.0 85 7 25 87 20 81 8.6 82 7 26 88 52 82 12.0 86 7 27 89 82 213 7.4 88 7 28 90 50 275 7.4 86 7 29 91 64 253 7.4 83 7 30 92 59 254 9.2 81 7 31 93 39 83 6.9 81 8 1 94 9 24 13.8 81 8 2 95 16 77 7.4 82 8 3 96 78 NA 6.9 86 8 4 97 35 NA 7.4 85 8 5 98 66 NA 4.6 87 8 6 99122 255 4.0 89 8 7 10089 229 10.3 90 8 8 101 110 207 8.0 90 8 9 102NA 222 8.6 92 8 10 103NA 137 11.5 86 8 11 10444 192 11.5 86 8 12 10528 273 11.5 82 8 13 10665 157 9.7 80 8 14 107NA 64 11.5 79 8 15 10822 71 10.3
[R] Problem with download.file ?
# download.file() Seems to put the xlsx file onto hard drive. download.file(http://www.udel.edu/johnmack/data_library/zipcode_centroids.xlsx;, zipcode_centroids.xlsx) trying URL 'http://www.udel.edu/johnmack/data_library/zipcode_centroids.xlsx' Content type 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' length 2785832 bytes (2.7 Mb) opened URL downloaded 2.7 Mb # Trouble reading file with xlsx. library(xlsx) Loading required package: rJava Loading required package: xlsxjars Warning messages: 1: package ‘xlsx’ was built under R version 3.1.3 2: package ‘rJava’ was built under R version 3.1.3 df - read.xlsx2(zipcode_centroids.xlsx, sheetIndex=1) Error in .jcall(RJavaTools, Ljava/lang/Object;, invokeMethod, cl, : java.util.zip.ZipException: invalid entry size (expected 1168 but got 1173 bytes) # I downloaded the file manually (same name) from the web page and tried again. # Then I read the file into R with xlsx successfully. df - read.xlsx2(/zipdist/zipcode_centroids.xlsx, sheetIndex=1) str(df) 'data.frame': 42961 obs. of 8 variables: $ ZIPCODE : Factor w/ 42961 levels 01001,01002,..: 1 2 3 4 5 6 7 8 9 10 ... $ TOWN.: Factor w/ 18955 levels Aaronsburg,Abbeville,..: 85 333 333 333 898 1089 1459 1620 1899 2929 ... $ STATE: Factor w/ 52 levels AK,AL,AR,..: 21 21 21 21 21 21 21 21 21 21 ... $ LATITUDE : Factor w/ 37352 levels -7.209975,19.101978,..: 28020 28948 28916 28971 29047 28624 28326 28418 28197 28603 ... $ LONGITUDE: Factor w/ 37241 levels -100.00991,-100.02632,..: 8799 8706 8811 8715 8470 8639 9019 8608 8531 9065 ... $ STFIPS : Factor w/ 51 levels 01,02,04,..: 22 22 22 22 22 22 22 22 22 22 ... $ CD : Factor w/ 55 levels 00,01,02,..: 3 2 2 2 2 2 2 3 3 2 ... $ CONG_DIST: Factor w/ 436 levels 01_01,01_02,..: 191 190 190 190 190 190 190 191 191 190 ... # Is there a problem with download.file() when file is an Excel file or this particular Excel file? -- Giles L Crane, MPH, ASA, NJPHA Statistical Consultant and R Instructor 621 Lake Drive Princeton, NJ 08540 Phone: 609 924-0971 Email: gilescr...@verizon.net [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] max_prepared_stmt_count exceeded using RODBC + 64-bit win7
Hi I am running R2.15.2 64-bit on Windows 7, using RODBC 1.3-6, MySQL5.5.20, MySQL Connector 5.5.2 - these are the latest 64-bit versions AFAIK. sqlQuery and sqlSave work fin as expected, but in a long session with a few sqlSave() calls, I get an error, for example: Error in sqlSave(channel = channel, dat = USArrests[, 1, drop = FALSE], : HY000 1461 [MySQL][ODBC 5.2(w) Driver][mysqld-5.5.20]Can't create more than max_prepared_stmt_count statements (current value: 16384) [RODBC] ERROR: Could not SQLPrepare 'INSERT INTO `usarrests` ( `murder` ) VALUES ( ? )' In my setup the MySQL global variable max_prepared_stmt_count has the default setting of 16K. If I reset the variable higher, I can run a while longer, but this is not a permanent solution. Digging around for a solution, I see that the following may cast some light: show global status like 'com_stmt%'; +-+---+ | Variable_name | Value | +-+---+ | Com_stmt_close | 0 | | Com_stmt_execute| 49931 | | Com_stmt_fetch | 0 | | Com_stmt_prepare| 36| | Com_stmt_reprepare | 0 | | Com_stmt_reset | 36| | Com_stmt_send_long_data | 0 | +-+---+ If I understand right, the number of Com_stmt_close should be 'close to or equal to' Com_stmt_execute, but is not. Rolling back to all 32-bit R2.13.2 etc does work, all entries in the table above remaining at zero, The number Com_stmt_execute increases with each row written using sqlSave(), but does not increase if I use sqlQuery() #This causes Com_stmt_execute to increase 50: sqlQuery(channel=channel,query=DROP TABLE IF EXISTS USArrests) sqlSave(channel=channel, dat=USArrests[,1,drop=FALSE],rownames=FALSE) #This causes no change in Com_stmt_execute : sqlQuery(channel=channel,query=INSERT INTO USArrests (murder) values (1)) This behaviour did not occur with R2.13.2 RODBC 1.3-3 32-bit. I could just revert one thing at a time to narrow it down but if anyone can offer a shortcut I'd be delighted. Thanks Giles Heywood [[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] xts indexed with Date class
Hi I see a changed behaviour in xts indexed on class Date in the latest versions, versus 2. It seems to be related to changes to/from daylight savings time, happens those weekends. Is it not intended that class Date be used like this, or is this new behaviour incorrect? Giles Example: a-as.Date(15423:15426) x-xts(seq_along(a),a) print(x) [,1] 2012-03-241 2012-03-252 2012-03-253 2012-03-264 print(index(x)) [1] 2012-03-24 2012-03-25 2012-03-25 2012-03-26 print(as.numeric(index(x))) [1] 15423 15424 15424 15425 #for reference, zoo behaves as expected: z-zoo(seq_along(a),a) print(index(z)) [1] 2012-03-24 2012-03-25 2012-03-26 2012-03-27 print(as.numeric(index(z))) [1] 15423 15424 15425 15426 Package: xts Type: Package Title: eXtensible Time Series Version: 0.8-8 Date: 2012-10-05 Windows 7 64-bit R version 2.15.2 64-bit all packages up-to-date #--previously, R 2.13.2 and xts 0.8-2 , showing expected behaviour - a-as.Date(15423:15426) x-xts(seq_along(a),a) print(x) [,1] 2012-03-241 2012-03-252 2012-03-263 2012-03-274 print(index(x)) [1] 2012-03-24 2012-03-25 2012-03-26 2012-03-27 print(as.numeric(index(x))) [1] 15423 15424 15425 15426 z-zoo(seq_along(a),a) print(index(z)) [1] 2012-03-24 2012-03-25 2012-03-26 2012-03-27 print(as.numeric(index(z))) [1] 15423 15424 15425 15426 __ 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] rollmax.zoo : column names NULL
Hi I am comparing the output of rollmax in two versions of R. In the current version, the column names are 'lost' ie NULL in the output; in the earlier version they were retained. Function rollapply has the same behaviour as before. Is this change in rollmax behaviour deliberate? Thanks Giles R2.13.1 + zoo 1.7-4 on Windows 7 a - as.zoo(matrix(1:20,4,5,dimnames=list(LETTERS[1:4],letters[1:5]))) rollapply(data=a,FUN=mean,width=3) a b c d e 2 2 6 10 14 18 3 3 7 11 15 19 rollmax(x=a,k=3) a b c d e 2 3 7 11 15 19 3 4 8 12 16 20 str(colnames(rollmax(x=a,k=3))) chr [1:5] a b c d e R2.15.0 + zoo 1.7-7 a - as.zoo(matrix(1:20,4,5,dimnames=list(LETTERS[1:4],letters[1:5]))) rollapply(data=a,FUN=mean,width=3) a b c d e 2 2 6 10 14 18 3 3 7 11 15 19 rollmax(x=a,k=3) 2 3 7 11 15 19 3 4 8 12 16 20 str(colnames(rollmax(x=a,k=3))) NULL __ 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] rollapply.zoo() with na.rm=TRUE
Thanks for that Gabor, it works fine from the development version you've pointed to. There is in addition a performance issue: the following benchmark ran in under 0.2s in the previous version, now consistently shows elapsed time over 14s on a Xeon with Windows. It's unaffected if I use the development version. Giles Heywood #example system.time(rollmax(x= zoo(1:1,1:1),k=20,align=right)) R version 2.13.1 (2011-07-08) Platform: i386-pc-mingw32/i386 (32-bit) __ 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] rollapply.zoo() with na.rm=TRUE
Hi. I'm comparing output from rollapply.zoo, as produced by two versions of R and package zoo. I'm illustrating with an example from a R-help posting 'Zoo - bug ???' dated 2010-07-13. My question is not about the first version, or the questions raised in that posting, because the behaviour is as documented. I'm puzzled as to why na.rm no longer is passed to mean, i.e. why element 2 is NA and not 1.5 when na.rm=TRUE, as it was before. The first example, where na.rm is not specified, and which now behaves more as one might expect prior to carefully reading the documentation, is also different from before. This is not specific to mean(), similar behaviour is shown for e.g. sum(). Have I misunderstood the documentation? Is there a way to reproduce the old behaviour with na.rm=TRUE? Thanks. Giles Version 1 -- R version 2.12.0 (2010-10-15) Platform: i386-pc-mingw32/i386 (32-bit) [27] zoo_1.6-4 a - zoo(c(NA,1:9),1:10) rollapply(a,FUN=mean,width=3) 2 3 4 5 6 7 8 9 NA NA NA NA NA NA NA NA rollapply(a,FUN=mean,width=3, na.rm = FALSE) 2 3 4 5 6 7 8 9 NA 2 3 4 5 6 7 8 rollapply(a,FUN=mean,width=3, na.rm = TRUE) 2 3 4 5 6 7 8 9 1.5 2.0 3.0 4.0 5.0 6.0 7.0 8.0 Version 2 -- R version 2.13.1 (2011-07-08) Platform: i386-pc-mingw32/i386 (32-bit) [25] zoo_1.7-2 a - zoo(c(NA,1:9),1:10) rollapply(a,FUN=mean,width=3) 2 3 4 5 6 7 8 9 NA 2 3 4 5 6 7 8 rollapply(a,FUN=mean,width=3, na.rm = FALSE) 2 3 4 5 6 7 8 9 NA 2 3 4 5 6 7 8 rollapply(a,FUN=mean,width=3, na.rm = TRUE) 2 3 4 5 6 7 8 9 NA 2 3 4 5 6 7 8 __ 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] AOV() may misslabel random effects.
Greetings, The aov() function may mislabel the random effects as in the example below: Has anybody else noticed this? Cordially, Giles Crane, MPH, ASA, NJPHA gilescr...@verizon.net m2 Call: aov(formula = y ~ ap + pe + Error(ju), data = d) Grand Mean: 77.50667 Stratum 1: ju Terms: ap Sum of Squares 4322.538 Deg. of Freedom 12 13 out of 25 effects not estimable Estimated effects may be unbalanced Stratum 2: Within Terms: ap pe Residuals Sum of Squares 7047.885 255.034 2981.290 Deg. of Freedom 25235 Residual standard error: 9.229285 Estimated effects may be unbalanced __ 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] Behavior of assignment within system.time()
There are instances when assignment should be indicated by - rather than =. One example is the function Sys.time(). sytem.time( x=1:1) # x is interpreted as an argument and is an error here. system.time( x-1:1000) # times the creation of x with numbers 1 to 1 However, grouping the statement with curly brackets also gives the correct system time. system.time( { x=1:1} ) # times the statement correctly Having fun with R, Giles Crane __ 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] print() required sometimes in interactive use of console
Surprising behavior: Most R users are aware that print() must be used inside functions to gain output on the console. Apparently, print() is sometimes required when interactively using the console. For example, the followingmay be entered into the R console with different results. sample(1:8,8) #prints a permutation of 1 to 8 for(i in 1:5) #does not sample(1:8,8) Cordially, Giles Crane __ 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] Loading .Rdata within an R function
Thank you for your consideration of this question. I have tried both your suggestions. However, the data is not loaded within the function. When I specify load(mydata.Rdata,.globalEnv), the data is loaded into the top level environment, and the function does access the data in the top level environment. However, I would like to load the data into the function environment, so that the data goes away when the function terminates. Cordially, Giles Crane -- View this message in context: http://r.789695.n4.nabble.com/Loading-Rdata-within-an-R-function-tp2282751p2283051.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Loading .Rdata within an R function
Colleagues: I am having trouble loading data from within .Rdata file within the environment of a function. That is, the following always loads to the global environment: f1 - function(){ load(mydata.Rdata) # compute with objects from mydata.Rdata. } I wish to load mydata.Rdata only within the function f1. Perhaps I have misunderstood the capabilities of load(), or the environment concepts. Thank you for any help you may give. Cordially, Giles Crane -- View this message in context: http://r.789695.n4.nabble.com/Loading-Rdata-within-an-R-function-tp2282751p2282751.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Adjusted means and generalized chain block designs
To whom it may concern: I compared several R package results, and manual checked two generalized chain block design experiments. The correct adjusted treatment means can be computed by using the effects library as follows: library(effects) aov1 = aov(y~blocks+rows+trt) means.aov = as.vector( allEffects(aov1)$trt$fit ) As a further check, I programmed an R function to compute the adjusted treatment means via John Mandel's manual method in his paper, a somewhat lengthy and tricky task. Finally, I will present motivating examples on behalf of my colleagues Cynthia Collins and Karin Mille, an index of Generalized Block Designs, and GCB library in draft form, includingD-efficiency, at the NIST UseR 2010 Conference in July. These designs are interesting combinatorially, and quite applicable to physical measurements which are made with high precision. Best wishes, Giles -- View this message in context: http://r.789695.n4.nabble.com/Adjusted-means-and-generalized-chain-block-designs-tp1556545p2267205.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to insert gridlines in lattice density plot
Greetings. How can I insert gridlines in the following density plot call? Must one compose a panel function? 'data.frame': 46 obs. of 2 variables: $ fallrates: num 5.2 7.1 7.1 9.8 3.7 7.5 5 6.2 1.5 2.9 ... $ prepost : Factor w/ 2 levels post,pre: 2 2 2 2 2 2 2 2 2 2 ... library(lattice) densityplot(~fallrates, groups = prepost, kernal=triangular, lwd=2, plot.points = TRUE, ref = TRUE, auto.key = list(columns = 2), main=Estimated fall rate density, pre and post intevention) Thank you for your consideration and comments. Giles Crane __ 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 insert gridlines in lattice density plot
Thank you Burt Gunter and David Winsemius, I confirmed David's comment. One must use type=c(p,g) in order to get both the grid and points. So, to use densityplot well, we must be quite aware of the options for panel.xyplot! Cordially, Giles Crane __ 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] Adjusted means and generalized chain block designs
Dear Colleagues, John Mandel ( Chain block designs with two-way elimination of heterogeneity. Biometrics 10, 251-272 ,1954). extended the class of chain block designs (Youden Conner (1953) to elimination of both row and column (blocks) effects. These experimental designs can be useful in engineering and other fields. I am having difficulty obtaining his adjusted treatment means in his example, shown below, by the use of lm(), or glm(), or ols(). However, I can obtain Mandel's analysis of variance. # Mandel example, op. cit. page 263 # y are logs of treadwear, blocks are wheel positions, # and rows are runs. blocks = factor( rep(1:4, 4) )# blocks rows = factor(c( 1,1,1,1, 2,2,2,2, 3,3,3,3, 4,4,4,4) ) #pos trt = factor( c(1:8, 7,8,2,1,3,4,6,5) ) # tires y = c(1.802, 1.862, 1.173, 1.762, 1.935, 2.072, 1.703, 1.935, 1.610, 1.568, 1.267, 1.522, 1.816, 1.935, 1.418, 1.594) xtabs(y ~ rows + blocks)# tabulate by row and column # One of my attempts using lm() from the stats package: m1 = lm( y ~ trt + blocks + rows) Mandel obtrain the following adjusted means mandel = c(1.728, 1.817, 1,588, 1.785, 1.512, 1. 678, 1.720, 1.658) Can anyone shed light on how to obtain in R the correct treatment means, adjusted for both row and column effects (blocks) in these designs? Cordially, Giles Crane gilescr...@verizon.net __ 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] renaming objects
Thank you all for your enlightening replies. Hadley mentioned first that a mere assignment in R does not double storage. Hence once solution is: y - x rm(x) Gabor gave a deeper solution which permits assigning a second name: makeActive Binding(y,function() x, .GlobalEnv) The reason for my question was to form a function: --read, in chunks, a large file which does not fit in memory --abstract one variable, which does fit in memory. -- save that variable in .Rdata format under a chosen name. DIAG1 = getvar(bigfile.txt, startchar, endchar) save(DIAG1, file = DIAG1.Rdata) I am now testing this approach. Cordially, Giles Giles Crane, M.Phil., MPH Research Scientist Statistician Tel 609 292-8012, -5666 Fax 609 292-9288 [EMAIL PROTECTED] __ This does not really answer your question but the following lets you refer to an object by a second name although the object still has its original name as well. a - 3 makeActiveBinding(b, function() a, .GlobalEnv) NULL b [1] 3 a - 4 b [1] 4 On Mon, Mar 3, 2008 at 4:20 PM, [EMAIL PROTECTED] wrote: Is there a way to rename R objects? I am looking for a way to rename objects without making new objects. #For example: x = c(1:40) # I wish to use a function to rename x, already created, to y, perhaps by obj.rename(x,y) # or obj.rename(x,y) There are numerous examples of renaming variables (columns) in dataframes, but I have found no methods for renaming objects. The functionassign() does not do this. Thank you for any help you can give. Cordially Giles Crane, M.Phil., MPH Research Scientist Statistician New Jersey Department of Health Senior Services Tel 609 292-8012, -5666 Fax 609 292-9288 [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] renaming objects
Is there a way to rename R objects? I am looking for a way to rename objects without making new objects. #For example: x = c(1:40) # I wish to use a function to rename x, already created, to y, perhaps by obj.rename(x,y) # or obj.rename(x,y) There are numerous examples of renaming variables (columns) in dataframes, but I have found no methods for renaming objects. The functionassign() does not do this. Thank you for any help you can give. Cordially Giles Crane, M.Phil., MPH Research Scientist Statistician New Jersey Department of Health Senior Services Tel 609 292-8012, -5666 Fax 609 292-9288 [EMAIL PROTECTED] __ 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 form a simple R package
Is there a function to form in one step (configure files and install) a simple R package of consisting of one script file of R functions? For example in Windows: form.package(name=mypkg, rcodefile =c:\misc\mypkg.r ) Thank you for any comments. Giles Giles Crane, M.Phil., MPH Research Scientist Statistician Tel 609 292-8012, -5666 Fax 609 292-9288 [EMAIL PROTECTED] __ 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.