Hello everyone, Thanks to all who offered suggestions after my initial query to the list. I've been busy trying to absorb the docs as fast as possible, but this little thing has me stumped for the moment. I'm creating a random sample of 100 item and saving it to a vector named 'iq'. I'd like to create a second vector (iq_prime, say) by adding 20 to each element of the 'iq' vector. Here's what I've tried.> iq <- rnorm(100, 80, 15) > t(dstats(iq)) # Thanks Brett Magillmean sd variance min max unique n miss skewness kurtosis [1,] 78.628 14.223 202.302 49.079 121.294 100 100 0 0.3 0.191> iq_prime <- sapply(iq, function(x)x+20) > iq_prime > t(dstats(iq))mean sd variance min max unique n miss skewness kurtosis [1,] 98.628 14.223 202.302 69.079 141.294 100 100 0 0.3 0.191 Nothing is being done with 'iq_prime' apparently, but 'iq' gets changed. Any suggestions? I guess I understand that the function is being run on 'iq', but why doesn't the vector get saved as 'iq_prime'? And how would I do this without modifying 'iq'? -Tim -- Tim Wilson | Visit Sibley online: | Check out: Henry Sibley HS | http://www.isd197.org | http://www.zope.com W. St. Paul, MN | | http://slashdot.org wilson at visi.com | <dtml-var pithy_quote> | http://linux.com -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>>>>> "tim" == Tim Wilson <wilson at visi.com> writes:tim> Hello everyone, Thanks to all who offered suggestions after tim> my initial query to the list. I've been busy trying to tim> absorb the docs as fast as possible, but this little thing tim> has me stumped for the moment. tim> I'm creating a random sample of 100 item and saving it to a tim> vector named 'iq'. I'd like to create a second vector tim> (iq_prime, say) by adding 20 to each element of the 'iq' tim> vector. Here's what I've tried. Note that "_" is assignment in S (and hence R, sigh...). >> iq <- rnorm(100, 80, 15) >> t(dstats(iq)) # Thanks Brett Magill tim> mean sd variance min max unique n miss skewness tim> kurtosis tim> [1,] 78.628 14.223 202.302 49.079 121.294 100 100 0 tim> 0.3 0.191 >> iq_prime <- sapply(iq, function(x)x+20) iq.prime <- iq + 20 # "." is a separation character, as well as having other overloaded # meanings. >> iq_prime >> t(dstats(iq)) tim> mean sd variance min max unique n miss tim> skewness kurtosis tim> [1,] 98.628 14.223 202.302 69.079 141.294 100 100 0 tim> 0.3 0.191 best, -tony -- A.J. Rossini Rsrch. Asst. Prof. of Biostatistics U. of Washington Biostatistics rossini at u.washington.edu FHCRC/SCHARP/HIV Vaccine Trials Net rossini at scharp.org -------------- http://software.biostat.washington.edu/ ---------------- FHCRC: M: 206-667-7025 (fax=4812)|Voicemail is pretty sketchy/use Email UW: Th: 206-543-1044 (fax=3286)|Change last 4 digits of phone to FAX (my tuesday/wednesday/friday locations are completely unpredictable.) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Peter Dalgaard notes:> > Note that "_" is assignment in S (and hence R, sigh...). > > Soon to be deprecated, though... (but it will probably take a while > before we can reintroduce it as part of variable names). >[WNV] Indeed it may, so much so that I am surprised such a change is even on the agenda. We may agree that using "_" a the assignment operator can make code difficult to read, but many people do use it, and often with some enthusiasm. It looks a bit to me like unscrambling the egg. Let me be clear about this: I really do dislike the thing and I'm not about to argue that it should be left untouched. I'm just very surprised there isn't an enormous howl of protest already... Are we also about to allow spaces in names and the "=" sign as yet another alternative form of the left assignment operator, as in S4? Should be even more interesting. Bill Venables. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Dear Bill, On Sun, 30 Jun 2002 Bill.Venables at cmis.csiro.au wrote:> Are we also about to allow spaces in names and the "=" sign as yet > another alternative form of the left assignment operator, as in S4? Should > be even more interesting. >The equal sign has already been provided as an alternative assignment operator in R. John -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>>>>> "john" == John Fox <jfox at mcmail.cis.mcmaster.ca> writes:john> The equal sign has already been provided as an alternative assignment john> operator in R. And I feel the same way about "=" as I do about "_". Yech. best, -tony -- A.J. Rossini Rsrch. Asst. Prof. of Biostatistics U. of Washington Biostatistics rossini at u.washington.edu FHCRC/SCHARP/HIV Vaccine Trials Net rossini at scharp.org -------------- http://software.biostat.washington.edu/ ---------------- FHCRC: M: 206-667-7025 (fax=4812)|Voicemail is pretty sketchy/use Email UW: Th: 206-543-1044 (fax=3286)|Change last 4 digits of phone to FAX (my tuesday/wednesday/friday locations are completely unpredictable.) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._