Re: [R] Vector memory exhausted (limit reached?)

2019-10-28 Thread David Winsemius
On 10/28/19 2:17 PM, varin sacha via R-help wrote: Dear R-experts, My reproducible example here below is not working because of an error message : Erreur : vecteurs de mémoire épuisés (limite atteinte ?) My code perfectly works when n=3000 or n=5000 but as soon as n=1 my code does not wo

Re: [R] Vector of symbols?

2015-10-31 Thread Boris Steipe
You are describing an awkward way of doing this (and your example is unreadable because you are not following posting instructions for the list) ... but the following contains the essence of what I think is needed: parse() and eval(). v <- character() v[1] <- sprintf("%d ^ %s", 2, "duck") v[2]

Re: [R] Vector of symbols?

2015-10-31 Thread Jeff Newmiller
I believe it is possible, but R is not really a full-fledged symbolic algebra system so it wouldn't be an intuitive tool to use and what would you do with it once you had it? It is much more useful in R to do something like f1 <- function( M, A, B, C ) { M %*% c( A, B, C ) } m <- matrix( c(

Re: [R] vector of constant values

2015-10-29 Thread Bert Gunter
Have you read any R tutorials?? This is about as basic as it gets. ?rep -- Bert P.S. Due to vectorized operations, there is probably no need to do this anyway! Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On T

Re: [R] vector of constant values

2015-10-29 Thread Gerrit Eichner
Hi, Thanoon! I want to simulate a vector of constants values with dimention = 200x2 and all values of this vector are 1. You mean "I want to _construct_ a _matrix_ of dimension 200 x 2 with all entries equal to 1", don't you? Homework? Take a look at ?matrix Hth -- Gerrit Any help

Re: [R] vector of constant values

2015-10-29 Thread Sarah Goslee
If you mean you need a matrix of that size, matrix(1, nrow=200, ncol=2) On Thu, Oct 29, 2015 at 1:07 PM, thanoon younis wrote: > Dear Members, > > I want to simulate a vector of constants values with dimention = 200x2 and > all values of this vector are 1. > > Any help please. > > > Regards > _

Re: [R] vector graphics

2015-10-07 Thread Ivan Calandra
For the record, it seems that devEMF::emf() works fine on the Windows Vista SP2 machine with R3.2.2 and Illustrator CS4: the text is recognized as text and every point/line can be dissociated. Ivan -- Ivan Calandra, PhD University of Reims Champagne-Ardenne GEGENAA - EA 3795 CREA - 2 esplanade

Re: [R] vector graphics

2015-10-07 Thread Ivan Calandra
Thanks Jean for the tip. I'll try postscript() and devEMF::emf() and see if it works. Still, it's very complicated to export vector graphics in R... Ivan -- Ivan Calandra, PhD University of Reims Champagne-Ardenne GEGENAA - EA 3795 CREA - 2 esplanade Roland Garros 51100 Reims, France +33(0)3 26

Re: [R] vector graphics

2015-10-06 Thread Adams, Jean
Perhaps the discussion at this link will be helpful ... http://stackoverflow.com/questions/9555889/producing-a-vector-graphics-image-i-e-metafile-in-r-suitable-for-printing-in Jean On Tue, Oct 6, 2015 at 9:42 AM, Ivan Calandra wrote: > Dear useRs, > > A colleague of mine is having a problem wit

Re: [R] vector manipulations -- differences

2015-09-22 Thread Frank Schwidom
And if we want to use the approach of William Dunlap for sequence.optimization , then we can write: rev( xr[ seq_len(sum(vec)) - rep.int(cumsum(c(0L, vec[-length(vec)])), vec)] - rep.int( xr[ -1], vec)) Regards. On 2015-09-22 23:43:10, Frank Schwidom wrote: > Hi, > > xr <- rev( x) > vec <- 1:

Re: [R] vector manipulations -- differences

2015-09-22 Thread Frank Schwidom
Hi, xr <- rev( x) vec <- 1:(length( x) - 1) rev( xr[ sequence( vec)] - rep.int( xr[ -1], vec)) On 2015-09-21 14:17:40, Dan D wrote: > I need an efficient way to build a new n x (n-1)/2 vector from an n-vector x > as: > > c(x[-1]-x[1], x[-(1:2)]-x[2], ... , x[-(1:(n-1)] - x[n-1]) > > x is incre

Re: [R] vector manipulations -- differences

2015-09-21 Thread Bert Gunter
Use ?mappy and ?rep.int > x[unlist(mapply(":",2:4,4))] - x[rep.int(1:3,3:1)] [1] 3 7 20 4 17 13 Cheers, Bert Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On Mon, Sep 21, 2015 at 2:17 PM, Dan D wrote: > I

Re: [R] Vector of Numbers Not Output to Screen

2014-07-20 Thread Duncan Murdoch
On 20/07/2014, 5:46 PM, David Winsemius wrote: > > On Jul 20, 2014, at 6:30 AM, Duncan Murdoch wrote: > >> On 17/07/2014, 10:00 PM, Dario Strbenac wrote: >>> The example in the question was not inside a user function. >> >> The explanations you were given were slightly inaccurate. The usual >> r

Re: [R] Vector of Numbers Not Output to Screen

2014-07-20 Thread David Winsemius
On Jul 20, 2014, at 6:30 AM, Duncan Murdoch wrote: > On 17/07/2014, 10:00 PM, Dario Strbenac wrote: >> The example in the question was not inside a user function. > > The explanations you were given were slightly inaccurate. The usual > rule is that results returned at the top level are printed

Re: [R] Vector of Numbers Not Output to Screen

2014-07-20 Thread Duncan Murdoch
On 17/07/2014, 10:00 PM, Dario Strbenac wrote: > The example in the question was not inside a user function. The explanations you were given were slightly inaccurate. The usual rule is that results returned at the top level are printed unless they are marked as invisible. (There are a few cases

Re: [R] Vector of Numbers Not Output to Screen

2014-07-20 Thread Dario Strbenac
It's a plausible use-case. For example, in the example section of a help file. if(require(aPackage)) { # Do computations. # Show beginning of first result vector. # Show beginning of second result vector. } __ R-help@r-project.org mailing list http

Re: [R] Vector of Numbers Not Output to Screen

2014-07-18 Thread Rolf Turner
On 18/07/14 15:00, Dario Strbenac wrote: The example in the question was not inside a user function. Don't be silly. cheers, Rolf Turner -- Rolf Turner Technical Editor ANZJS __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listin

Re: [R] Vector of Numbers Not Output to Screen

2014-07-17 Thread Dario Strbenac
The example in the question was not inside a user function. __ 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

Re: [R] Vector of Numbers Not Output to Screen

2014-07-17 Thread Bert Gunter
Rolf et.al I have not followed this thread closely and so have nothing to say about whose or what explanation is correct. However, the following statement is misleading, if not wrong: --- foo <- function(){ x <- 17 x y <- 42 y } If you type foo() you get [1] 42 which i

Re: [R] Vector of Numbers Not Output to Screen

2014-07-17 Thread Rolf Turner
On 18/07/14 11:32, David Winsemius wrote: On Jul 17, 2014, at 9:27 AM, Rui Barradas wrote: Hello, Also, unlike what the op says, if statements are functions, explaining the behavior he got. I'm not sure that is correct. The help page says if() is a control-construct. I think the function

Re: [R] Vector of Numbers Not Output to Screen

2014-07-17 Thread David Winsemius
On Jul 17, 2014, at 9:27 AM, Rui Barradas wrote: > Hello, > > Also, unlike what the op says, if statements are functions, explaining the > behavior he got. I'm not sure that is correct. The help page says if() is a control-construct. I think the function is actually "{" > {rnorm(10); rpois(1

Re: [R] Vector of Numbers Not Output to Screen

2014-07-17 Thread Jeff Newmiller
This question is related to FAQ 7.16, which you should look up. In general, whenever you just type a variable or function directly at the command line, R prints the result for you. Inside code blocks of any kind, it does not do that, so you need to use the print function yourself. On Thu, 17

Re: [R] Vector of Numbers Not Output to Screen

2014-07-17 Thread Rui Barradas
Hello, Also, unlike what the op says, if statements are functions, explaining the behavior he got. Hope this helps, Rui Barradas Em 17-07-2014 16:53, Sarah Goslee escreveu: Hi, You can get the behaviour you want using the print() command: if(1 < 2) { x<-rnorm(100) y <- rpois(10, 5)

Re: [R] Vector of Numbers Not Output to Screen

2014-07-17 Thread Sarah Goslee
Hi, You can get the behaviour you want using the print() command: if(1 < 2) { x<-rnorm(100) y <- rpois(10, 5) print(head(x)) print(head(y)) } Sarah On Thu, Jul 17, 2014 at 2:00 AM, Dario Strbenac wrote: > Hello, > > I have a block of code that has two head calls at the end, but only t

Re: [R] vector where elements are functions evaluated at integers, but length of vector varies

2013-10-10 Thread Carl Witthoft
Hi, I have two integers a and b (with a What did you try?Further, without knowing what your function f(x) is, we can't tell you whether it accepts vector inputs. -- View this message in context: http://r.789695.n4.nabble.com/vector-where-elements-are-functions-evaluated-at-integers-bu

Re: [R] Vector from csv file.

2013-10-02 Thread arun
Hi, It is not clear whether you read the file correctly or not.  Please check str(tbl_all) The code you showed should work if the file was read correctly. For example: set.seed(468) tbl_all<- as.data.frame(matrix(sample(1:10,10*22,replace=TRUE),ncol=22,dimnames=list(NULL,c("A","V",LETTERS[3

Re: [R] Vector of char generated by Sys.getenv function is not available when the package is loaded

2013-09-24 Thread Jose Claudio Faria
Hi, I prefer to build my packages on Linux! I changed the object trPaths as below, After R CMD build TinnRcom on Linux and did the installation on Windows from the source code: It worked very well! I thank all who contributed to the solution and apologize for my lack of knowledge in this area.

Re: [R] Vector of char generated by Sys.getenv function is not available when the package is loaded

2013-09-24 Thread Prof Brian Ripley
On 24/09/2013 03:51, Jose Claudio Faria wrote: I think I found the main problem! I am developing the package under Linux and after R CMD build, manually compressing the folder TinnRcom inside of the folder TinnRcom.RCheck and installing in Windows. And how on earth did you expect the helpers h

Re: [R] Vector of char generated by Sys.getenv function is not available when the package is loaded

2013-09-23 Thread Philippe Grosjean
Hi JCFaria, You package is supposed to be used only under Windows, right? Then, use: OS_type=windows in the DESCRIPTION file… and, of course, use R CMD check/R CMD build/ R CMD INSTALL under Windows only. Best, Philippe On 23 Sep 2013, at 20:55, Jose Claudio Faria wrote: > I have been deve

Re: [R] Vector of char generated by Sys.getenv function is not available when the package is loaded

2013-09-23 Thread Jose Claudio Faria
I think I found the main problem! I am developing the package under Linux and after R CMD build, manually compressing the folder TinnRcom inside of the folder TinnRcom.RCheck and installing in Windows. As the APPDATA environment variable does not exist in Linux, the function Sys.getenv ("APPDATA"

Re: [R] Vector of char generated by Sys.getenv function is not available when the package is loaded

2013-09-23 Thread Jose Claudio Faria
I appreciate your attention Gabor. However, the result was the same. :( Both only work when the trPath object is sent to a R session already running. When inside the package the result was the same. > remove.packages('TinnRcom') > Install.packages('TinnRcom_1.0-09.zip', repos=NULL) # New versio

Re: [R] Vector of char generated by Sys.getenv function is not available when the package is loaded

2013-09-23 Thread Gabor Grothendieck
On Mon, Sep 23, 2013 at 2:55 PM, Jose Claudio Faria wrote: > trPaths <- paste(paste(Sys.getenv('APPDATA'), >'\\Tinn-R\\tmp\\', >sep=''), > c('', >'search.txt', >'objects.txt', >

Re: [R] vector question

2013-06-17 Thread William Dunlap
to:r-help-boun...@r-project.org] On > Behalf > Of arun > Sent: Monday, June 17, 2013 11:58 AM > To: Andras Farkas > Cc: R help > Subject: Re: [R] vector question > > HI Andras, > Sorry, I misunderstood your question: > > Try this: >  sapply(sapply(b,function(x) d

Re: [R] vector question

2013-06-17 Thread arun
HI Andras, Sorry, I misunderstood your question: Try this:  sapply(sapply(b,function(x) d[x To: arun Cc: Sent: Monday, June 17, 2013 2:48 PM Subject: Re: [R] vector question Arun, thank you. Looking at it I am wondering if there is a way to get 36 in the result instead of the 24. The 2nd

Re: [R] vector question

2013-06-17 Thread arun
May be this helps: d[cumsum(sapply(d,function(x) any(x>b)))>=1] #[1] 12 24 36 A.K. - Original Message - From: Andras Farkas To: r-help@r-project.org Cc: Sent: Monday, June 17, 2013 2:29 PM Subject: [R] vector question Dear All, would you please help with the following: let us say I h

Re: [R] Vector allocation problem while trying to plot 6 MB data file

2013-05-08 Thread Uwe Ligges
On 08.05.2013 13:38, Ramon Hofer wrote: Thanks for your answer Uwe On Fri, 03 May 2013 23:36:24 +0200 Uwe Ligges wrote: On 02.05.2013 14:37, Ramon Hofer wrote: I'm trying to analyse the network speed and used iperf to create a csv file containing the link test data. It's only about 6 MB

Re: [R] Vector allocation problem while trying to plot 6 MB data file

2013-05-08 Thread Ramon Hofer
Thanks for your answer Uwe On Fri, 03 May 2013 23:36:24 +0200 Uwe Ligges wrote: > On 02.05.2013 14:37, Ramon Hofer wrote: > > > > I'm trying to analyse the network speed and used iperf to create a > > csv file containing the link test data. It's only about 6 MB big but > > contains about 40'00

Re: [R] Vector allocation problem while trying to plot 6 MB data file

2013-05-03 Thread Uwe Ligges
On 02.05.2013 14:37, Ramon Hofer wrote: Hi all I'm trying to analyse the network speed and used iperf to create a csv file containing the link test data. It's only about 6 MB big but contains about 40'000 samples. I can do boxplots (apart from printing the number of samples but I ask separate

Re: [R] Vector with zeros and ones

2013-04-22 Thread Marc Schwartz
On Apr 22, 2013, at 6:28 PM, Marc Schwartz wrote: > On Apr 22, 2013, at 6:21 PM, Ayyappa wrote: > >> Dear group, >> >> I want to generate a vector of 10 elements that always has 20% zeroes, but >> with a random ordering of zeroes and ones. Can you please suggest a function >> to do that in

Re: [R] Vector with zeros and ones

2013-04-22 Thread Marc Schwartz
On Apr 22, 2013, at 6:21 PM, Ayyappa wrote: > Dear group, > > I want to generate a vector of 10 elements that always has 20% zeroes, but > with a random ordering of zeroes and ones. Can you please suggest a function > to do that in R? I tried 'sample' function but the 20% zeros was not always

Re: [R] Vector with zeros and ones

2013-04-22 Thread R. Michael Weylandt
On Mon, Apr 22, 2013 at 7:21 PM, Ayyappa wrote: > Dear group, > > I want to generate a vector of 10 elements that always has 20% zeroes, but > with a random ordering of zeroes and ones. Can you please suggest a function > to do that in R? I tried 'sample' function but the 20% zeros was not alway

Re: [R] vector field from a 3D scalar field

2013-03-21 Thread David Winsemius
On Mar 21, 2013, at 4:40 PM, Waichler, Scott R wrote: > I have a 3D field of a scalar variable (x, y, z, value). Is there a way to > generate a vector field from this data--gradient at defined points? I found > the rasterVis package for 2D data, but as yet nothing for 3D data. Can't you just

Re: [R] vector indexing

2012-10-23 Thread Duncan Murdoch
On 12-10-23 5:39 AM, Rui Barradas wrote: Hello, Try the following. y=c(2,3,5,2,4,6,8,3,6,2,5) first <- function(x) min(which(x)) prefix <- function(x, v) x[seq_len(v)] suffix <- function(x, v) x[-seq_len(v)] first(y > 4) prefix(y, first(y > 4)) suffix(y, first(y > 4)) Be careful with this:

Re: [R] vector indexing

2012-10-23 Thread Rui Barradas
Hello, Try the following. y=c(2,3,5,2,4,6,8,3,6,2,5) first <- function(x) min(which(x)) prefix <- function(x, v) x[seq_len(v)] suffix <- function(x, v) x[-seq_len(v)] first(y > 4) prefix(y, first(y > 4)) suffix(y, first(y > 4)) Hope this helps, Rui Barradas Em 23-10-2012 10:21, Al Ehan escr

Re: [R] vector indexing

2012-10-23 Thread Ivan Calandra
Hi, Is it what you're looking for? which(y>4) ##all indexes for y>4 [1] 3 6 7 9 11 which(y>4)[1] ##the first index [1] 3 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-bourgogn

Re: [R] vector is not assigned correctly in for loop

2012-10-07 Thread 周果
Thank you all for helping me out. As Michael points out, I abused the rounding and formatting of print() while debugging. The default number of digits to print is 7 according to ?print.default, which makes floating point numbers to be somewhat plausible for index vector subsetting at first glance:

Re: [R] vector is not assigned correctly in for loop

2012-10-06 Thread R. Michael Weylandt
On Sat, Oct 6, 2012 at 3:23 PM, Bert Gunter wrote: > But the OP should not be doing this **at all.** He apparently has not > bothered to read the Intro to R tutorial as he appears not to know > about vectorized calculations. > > -- Bert > I don't really think that's relevant or constructive here.

Re: [R] vector is not assigned correctly in for loop

2012-10-06 Thread Bert Gunter
But the OP should not be doing this **at all.** He apparently has not bothered to read the Intro to R tutorial as he appears not to know about vectorized calculations. -- Bert On Sat, Oct 6, 2012 at 3:29 AM, R. Michael Weylandt wrote: > Forgot to cc the list. > > RMW > > On Sat, Oct 6, 2012 at 1

Re: [R] vector is not assigned correctly in for loop

2012-10-06 Thread Rui Barradas
Hello, This seems to be a case for FAQ 7.31 Why doesn't R think these numbers are equal? See this example: 3/5 - 1/5 - 2/5 # not zero 3/5 - (1/5 + 2/5) # not zero, different from above In your case, try for(idx in breaks){ print(idx / interval, digits = 16) # see problem indices

Re: [R] vector is not assigned correctly in for loop

2012-10-06 Thread R. Michael Weylandt
Forgot to cc the list. RMW On Sat, Oct 6, 2012 at 11:29 AM, R. Michael Weylandt wrote: > A case study of a good question! Would that all posters did such a good job. > > > > On Sat, Oct 6, 2012 at 7:14 AM, 周果 wrote: >> Hi there, >> Here is a minimum working example: >> -

Re: [R] vector is not assigned correctly in for loop

2012-10-06 Thread Berend Hasselman
On 06-10-2012, at 08:14, 周果 wrote: > Hi there, > Here is a minimum working example: > > lower = 0 > upper = 1 > n_bins = 50 > interval = (upper - lower) / n_bins > bins = vector(mode="numeric", length=n_bins) > breaks = seq(from=lo

Re: [R] Vector size limit for table() in R-2.15.1

2012-08-10 Thread peter dalgaard
On Aug 10, 2012, at 07:30 , Sean Ruddy wrote: > Thanks for the help all! Good to know that there's an answer. Unfortunately, > I don't have the rights to install programs so I wasn't able to try devel and > I've never heard of R patched but I'm guessing I can't install that either. > I'll see

Re: [R] Vector size limit for table() in R-2.15.1

2012-08-09 Thread Sean ruddy
Thanks for the help all! Good to know that there's an answer. Unfortunately, I don't have the rights to install programs so I wasn't able to try devel and I've never heard of R patched but I'm guessing I can't install that either. I'll see if I can get someone to do that. Much appreciated! Sea

Re: [R] Vector size limit for table() in R-2.15.1

2012-08-09 Thread Prof Brian Ripley
As the posting guide asked you to before posting, try R-patched. That has the NEWS items • duplicated(), unique() and similar now support vectors of lengths above 2^29 on 64-bit platforms. • unique() and similar would infinite-loop if called on a vector of length > 2^29 (bu

Re: [R] Vector size limit for table() in R-2.15.1

2012-08-09 Thread R. Michael Weylandt
On Aug 9, 2012, at 7:29 PM, Sean Ruddy wrote: > Hi, > > First, thanks in advance. Some useful info: > >> version > platform x86_64-unknown-linux-gnu > arch x86_64 > os linux-gnu > system x86_64, linux-gnu > version.string R version 2.15.1 (2012-06-22) > >

Re: [R] Vector size limit for table() in R-2.15.1

2012-08-09 Thread David Winsemius
On Aug 9, 2012, at 5:29 PM, Sean Ruddy wrote: Hi, First, thanks in advance. Some useful info: version platform x86_64-unknown-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu version.string R version 2.15.1 (2012-06-22) I'm trying to use the t

Re: [R] vector entry in matix

2012-07-05 Thread Joshua Wiley
Hi Thomas, This is non trivial to do, but if you will be working with this sort of data and are inclined to do some programming, you might consider creating a new class. S4 classes and methods are quite flexible, and you can allow them to lean on or inherit from existing classes such as matrices.

Re: [R] vector entry in matix

2012-07-05 Thread Christian Brechbühler
To second Bert Gunter: you may get better answers if you give us a complete description. On Thu, Jul 5, 2012 at 12:37 PM, Thomas C. wrote: > i have number of triangles which i'd like to store in a list, > matrix,...etc. > i thought it could look sth. like that: > > trianglenode1

Re: [R] vector entry in matix

2012-07-05 Thread Bert Gunter
You have failed to provide a complete, coherent description of what you wish to do. In the absence of such a description, all suggestions are just guesses. You need to think carefully about what information you want to associate with each triangle and the appropriate data structure to use to do thi

Re: [R] vector entry in matix

2012-07-05 Thread arun
Hi, I think it is better to store vectors in to list when the vectors are of different lengths. #Consider these cases, #vectors of equal length set.seed(1)  list1<-list(a=rnorm(5,15),b=rnorm(5,25),c=1:5,d=runif(5,0.4),e=16:20,f=rep(1,5)) mat1<-cbind(rbind(list1[[1]],list1[[2]],list1[[3]]),(rbin

Re: [R] vector entry in matix

2012-07-05 Thread Thomas C.
well thank you, i think we get closer to my problem. but i meant it in a different way. maybe i describe what i intended to do: i have number of triangles which i'd like to store in a list, matrix,...etc. i thought it could look sth. like that: trianglenode1node2no

Re: [R] vector entry in matix

2012-07-05 Thread David Winsemius
On Jul 5, 2012, at 11:22 AM, R. Michael Weylandt wrote: It is possible to put dimensionality on a list (i.e., a generic vector), which might be what you're looking for. x <- list(1:4, letters[1:4], function(x,y) x + y, rnorm(50)) dim(x) <- c(2,2) x[[1,2]] x[[2,2]] x[[3,2]] # Error That co

Re: [R] vector entry in matix

2012-07-05 Thread R. Michael Weylandt
It is possible to put dimensionality on a list (i.e., a generic vector), which might be what you're looking for. x <- list(1:4, letters[1:4], function(x,y) x + y, rnorm(50)) dim(x) <- c(2,2) x[[1,2]] x[[2,2]] x[[3,2]] # Error Best, Michael On Thu, Jul 5, 2012 at 8:19 AM, Thomas C. wrote: > h

Re: [R] vector w/o arithmetic addition for boxplot

2012-05-16 Thread Uwe Ligges
On 15.05.2012 23:47, rl269 wrote: Hello, I am having trouble asking R to read individual numeric vectors for a box plot of the residuals of a linear regression. It is performing arithmetic addition on the 16 individual variables that I want individual box plots for. I have 16 race*treatment

Re: [R] vector subtraction

2012-04-20 Thread R. Michael Weylandt
You're thinking about it wrong. This is an arithmetic sequence: seq(from = 1000, by = -30, length.out = 15) Michael On Fri, Apr 20, 2012 at 5:14 AM, uday wrote: > I would like to calculate vector from existing  value > e.g > v       <- 1000 > s       <- 30 > d1    <- v-s >                   d

Re: [R] Vector errors and missing values

2012-03-05 Thread jahughes81
Hi Petr, Thank you so much for your help. You're right, the issue was that I needed to center my predictors by adding the code 'na.rm=T': verbal.ability_C <- verbal.ability - mean(verbal.ability, na.rm=T) That removed the NA values from being included in my centering and allowed me to run the r

Re: [R] Vector errors and missing values

2012-03-05 Thread Petr PIKAL
Hi > > Here is my code: > > > ##Centering predictors### > verbal.ability_C <- verbal.ability - mean(verbal.ability) > children_C <- children - mean(children) > age_C <- age - mean(age) > education_C <- education - mean(education) > work.from.home.frequency_C <- work.from.home.frequency

Re: [R] Vector errors and missing values

2012-03-02 Thread jahughes81
Here is my code: ##Centering predictors### verbal.ability_C <- verbal.ability - mean(verbal.ability) children_C <- children - mean(children) age_C <- age - mean(age) education_C <- education - mean(education) work.from.home.frequency_C <- work.from.home.frequency - mean(work.from.home.fre

Re: [R] Vector errors and missing values

2012-03-02 Thread Petr PIKAL
Hi > > Hi Petr! > > Thank you for responding to my post. > > I checked out all my variables in the way you suggested and they are all in > integer form, but here are many missing values in some of my vectors, > denoted with NA. > > So, they are in the correct form, I am just wondering if there

Re: [R] Vector errors and missing values

2012-03-02 Thread jahughes81
Hi Petr! Thank you for responding to my post. I checked out all my variables in the way you suggested and they are all in integer form, but here are many missing values in some of my vectors, denoted with NA. So, they are in the correct form, I am just wondering if there is something else I need

Re: [R] Vector errors and missing values

2012-03-02 Thread Petr PIKAL
Hi > > Hi, > > I am trying to run two Non-Gaussian regressions: logistic and probit. I am > receiving two different errors when I try to run these regressions and I am > not sure what they mean or how to fix my syntax. > > Here is the logistic regression error: > > Error in family$linkfun(mu

Re: [R] Vector manipulation

2012-02-12 Thread syrvn
Great Dimitris. It helps indeed! Thanks a lot! -- View this message in context: http://r.789695.n4.nabble.com/Vector-manipulation-tp4381586p4381614.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https

Re: [R] Vector manipulation

2012-02-12 Thread Jorge I Velez
Hi mentor_, Try c(sapply(vec[-1], function(x) c(vec[1], x))) # [1] 2 4 2 6 2 9 2 10 HTH, Jorge.- On Sun, Feb 12, 2012 at 12:54 PM, syrvn <> wrote: > Hello, > > > I am stuck with the following problem. Consider the vector: > > vec <- c(2,4,6,9,10) > > I now want to use R to manipulate t

Re: [R] Vector manipulation

2012-02-12 Thread Dimitris Rizopoulos
One way is: vec <- c(2,4,6,9,10) c(rbind(vec[1], vec[-1])) I hope it helps. Best, Dimitris On 2/12/2012 6:54 PM, syrvn wrote: Hello, I am stuck with the following problem. Consider the vector: vec<- c(2,4,6,9,10) I now want to use R to manipulate the vector as follows: [1] 2, 4, 2, 6,

Re: [R] vector

2011-12-01 Thread Sarah Goslee
On Thu, Dec 1, 2011 at 3:11 PM, " Majid " wrote: > Hi, > yes, It is homework, Then ask your TA/instructor for help. > > These are 2 command: > first for generating data: > (1:10) > that output is 1 2 310 > ok ? > second is : > a1<-c( 1:10) > what is the output ?I didnot see any thing. Exact

Re: [R] vector

2011-12-01 Thread Sarah Goslee
Hi, On Thu, Dec 1, 2011 at 2:43 PM, " Majid " wrote: > Dear Sarah. > Thanks so much,Really I am new in this software,I am wrking to learn the > software. First, you should always send your replies to the list. That way information can help others, and more people are available to provide advice.

Re: [R] vector

2011-12-01 Thread Sarah Goslee
Hi, On Thu, Dec 1, 2011 at 10:35 AM, " Majid " wrote: > Hi. > Can you please answer to my questions about R ? > 1.how can I write command for vector ? > > for exaple in this sample : > I have this : > a1 <- c (1:10) > now how can I put in the vector ? I'm afraid I don't understand your question.

Re: [R] Vector-subsetting with ZERO - Is behavior changeable?

2011-10-10 Thread Johannes Graumann
Thank you very much. Learned something again! Joh William Dunlap wrote: > You can use [1] on the output of FUN to ensure that > exactly one value (perhaps NA from numeric(0)[1]) is > returned. E.g. > > > index <- 1 > > sapply(list(c(1,2,3),c(1,2),c(1)),function(x){x[max(length(x)- index,0)

Re: [R] Vector-subsetting with ZERO - Is behavior changeable?

2011-10-05 Thread William Dunlap
You can use [1] on the output of FUN to ensure that exactly one value (perhaps NA from numeric(0)[1]) is returned. E.g. > index <- 1 > sapply(list(c(1,2,3),c(1,2),c(1)),function(x){x[max(length(x)-index,0)][1]}) [1] 2 1 NA I'll also put in a plug for vapply, which throws an error if FUN

Re: [R] vector output loop or function

2011-09-01 Thread Dennis Murphy
Hi: Here's one approach: X1 <- sample(1:4, 10, replace = TRUE, prob = c(0.4, 0.2, 0.2, 0.2)) foo <- function(x) { m <- matrix(NA, nrow = length(x), ncol = length(x)) m[, 1] <- x idx <- seq_len(length(x)) for(j in idx[-1]) { k <- sample(idx, 2) x <- replace(x, k, 5)

Re: [R] vector of dates

2011-07-07 Thread jim holtman
You are storing the results in to a vector that is converted to numeric; that is why you see the numbers. Try this: > dataval=as.Date("2011/07/01") > date_val=seq(dataval,length=260,by="-7 day") > date_inizio=c() > date_condizione=c() > for (k in 1:length(date_val)){ + date_inizio[

Re: [R] Vector of functions

2011-07-02 Thread Dennis Murphy
Hi, To amplify on Josh's cogent remarks, the reason you can't create a vector of functions is because vectors are composed of atomic objects and functions are not atomic objects: > is.atomic(f.3) [1] FALSE > is.atomic(1) [1] TRUE > is.atomic(TRUE) [1] TRUE > is.atomic('a') [1] TRUE 'Vectors' of

Re: [R] Vector of functions

2011-07-02 Thread Joshua Wiley
Hi Thomas, On Sat, Jul 2, 2011 at 9:36 AM, Thomas Stibor wrote: > Hi there, > > I have a vector of some functions e.g. > #-# > f.1 <- function(a) { >  return( a ); > } > f.2 <- function(a) { >  return( 1 - (tanh(a))^2 ); > } > f.3 <- function(a) { >  return( 1 / (1+exp

Re: [R] Vector with factors inside lists/tuples

2011-06-25 Thread David Winsemius
On Jun 25, 2011, at 4:01 PM, Håvard Wahl Kongsgård wrote: glm( V0 ~ "HARRY" + "KLINE" + "Brown" + "Larry") No. You are mistaken. Assuming that V0 is defined and has the same length as there are rows in that data.frame, then V1 and V2 would be the arguments in the formula and they would

Re: [R] Vector with factors inside lists/tuples

2011-06-25 Thread Håvard Wahl Kongsgård
>> glm( V0 ~ "HARRY"  + "KLINE" + "Brown" + "Larry") > > No. You are mistaken. Assuming that V0 is defined and has the same length as > there are rows in that data.frame, then V1 and V2 would be the arguments in > the formula and they would not be quoted. > > ?glm   # and work through the examples

Re: [R] Vector with factors inside lists/tuples

2011-06-25 Thread David Winsemius
On Jun 25, 2011, at 2:13 PM, Håvard Wahl Kongsgård wrote: Hi, sorry my question was not really clear |Are you very early in efforts at learning R? No, have been a long term user of R, but only use R for the statistical stuff. The heart of the issue is that I have list of keywords that I w

Re: [R] Vector with factors inside lists/tuples

2011-06-25 Thread Håvard Wahl Kongsgård
Hi, sorry my question was not really clear  |Are you very early in efforts at learning R? No, have been a long term user of R, but only use R for the statistical stuff. The heart of the issue is that I have list of keywords that I want to analyse with a machine learning algorithm (20 000 keywords

Re: [R] Vector with factors inside lists/tuples

2011-06-25 Thread David Winsemius
On Jun 25, 2011, at 1:33 PM, Håvard Wahl Kongsgård wrote: Well, when a think of it using an array would be a simple solution. But to what extent are arrays supported by other R functions? Arrays are well supported by arithmetic, logical and accessor functions. Your questions seem very unfoc

Re: [R] Vector with factors inside lists/tuples

2011-06-25 Thread David Winsemius
On Jun 25, 2011, at 12:49 PM, Håvard Wahl Kongsgård wrote: Hi, this seems like a strange question, but in R is there a function that can handle vectors containing factors inside lists/tuples? Yes, A very strange question, indeed ... since dataframes are lists that commonly contain vectors

Re: [R] Vector with factors inside lists/tuples

2011-06-25 Thread Håvard Wahl Kongsgård
Well, when a think of it using an array would be a simple solution. But to what extent are arrays supported by other R functions? -Håvard 2011/6/25 Håvard Wahl Kongsgård > Hi, this seems like a strange question, but in R is there a function that > can handle vectors containing factors inside li

Re: [R] vector decreasing by a factor

2011-05-02 Thread Uwe Ligges
On 02.05.2011 09:55, andre bedon wrote: Hi, I'm quite new to R so this question will sound quite fundamental. I need to create a vector of length 160. The first element should be (1+r)^159 and each element thereafter should decrease by a factor of (1+r) until the 160th element that should b

Re: [R] vector decreasing by a factor

2011-05-02 Thread Ted Harding
On 02-May-11 07:55:27, andre bedon wrote: > Hi, > I'm quite new to R so this question will sound quite fundamental. > I need to create a vector of length 160. The first element should > be (1+r)^159 and each element thereafter should decrease by a > factor of (1+r) until the 160th element that shou

Re: [R] vector file

2011-05-01 Thread Barry Rowlingson
On Sun, May 1, 2011 at 8:08 AM, azam jaafari wrote: > Dear All > > I want to import the vector file (   .shp) to R. I could import the file by > rgdal package before, by following: > > geology<-readOGR('C:/geology//saga/geo.geom','finalgeology') > > but now there is an error: > > Error in ogrInfo

Re: [R] Vector of weekly dates starting with a given date

2011-03-09 Thread Gabor Grothendieck
On Wed, Mar 9, 2011 at 4:13 PM, Dimitri Liakhovitski wrote: > I realize I can do something like this: > date<-20081229 > mydates<-as.Date(as.character(date),"%Y%m%d") > for(i in 1:52){  # >  mydates<-c(mydates,mydates[length(mydates)]+7) > } > > I just thought maybe there is a more elegant way...

Re: [R] Vector of weekly dates starting with a given date

2011-03-09 Thread Hadley Wickham
On Wed, Mar 9, 2011 at 3:04 PM, Dimitri Liakhovitski wrote: > Hello! > > I have a date (a Monday): > > date<-20081229 > mydates<-as.Date(as.character(date),"%Y%m%d") > > What package would allow me to create a vector that starts with that > date (mydates) and contains dates for 51 Mondays that fol

Re: [R] Vector of weekly dates starting with a given date

2011-03-09 Thread Dimitri Liakhovitski
I realize I can do something like this: date<-20081229 mydates<-as.Date(as.character(date),"%Y%m%d") for(i in 1:52){ # mydates<-c(mydates,mydates[length(mydates)]+7) } I just thought maybe there is a more elegant way... Thank you! Dimitri On Wed, Mar 9, 2011 at 4:04 PM, Dimitri Liakhovitski

Re: [R] vector("integer", length) : vector size specified is too large

2011-03-04 Thread Uwe Ligges
Please ask the author of parts() in the partitions package or the author of the function that calls the former: your function calls generate a call parts(J) where J is 1272. Internally, a J*P(J) (1272 * 1.514126e+19) vector is generated (and that one is too large for R). Uwe Ligges On 0

Re: [R] Vector manipulations

2011-03-02 Thread Benjamin Hartley
Thanks Jonathan and Ista, that's really helpful. Got it running much better now. Ben On 2 March 2011 17:33, Jonathan P Daily wrote: > Is this what you want? I don't know what your v looks like, but this won't > work if there are cases in which v won't sum to exactly x. > > x <- 20 > v <- sample

Re: [R] Vector manipulations

2011-03-02 Thread Jonathan P Daily
Is this what you want? I don't know what your v looks like, but this won't work if there are cases in which v won't sum to exactly x. x <- 20 v <- sample(0:1, 100, T) w <- v[1:which(cumsum(v)==x)] -- Jonathan P. Daily Technician - USGS Leetown Science Center 1

Re: [R] Vector manipulations

2011-03-02 Thread Ista Zahn
Hi Benjamin, There may be faster ways, but v <- 1:100 x <- 10 n <- which(cumsum(v) == x) w <- v[1:n] seems pretty straightforward. Best, Ista On Wed, Mar 2, 2011 at 10:42 AM, Benjamin Hartley wrote: > I have a question regarding the most efficient way to select a substring of > a vector: > > I

  1   2   3   >