similar to: APPLY as alternate to FOR loop?

Displaying 20 results from an estimated 6000 matches similar to: "APPLY as alternate to FOR loop?"

2011 Jan 17
1
Problem about for loop
Hi everyones, my function like; e <- rnorm(n=50, mean=0, sd=sqrt(0.5625)) x0 <- c(rep(1,50)) x1 <- rnorm(n=50,mean=2,sd=1) x2 <- rnorm(n=50,mean=2,sd=1) x3 <- rnorm(n=50,mean=2,sd=1) x4 <- rnorm(n=50,mean=2,sd=1) y <- 1+ 2*x1+4*x2+3*x3+2*x4+e x2[1] = 10 #influential observarion y[1] = 10 #influential observarion data.x <- matrix(c(x0,x1,x2,x3,x4),ncol=5) data.y
2011 Mar 20
2
Why unique(sample) decreases the performance ?
Hi, I' am interested in differences between sample's result when samples consist of full elements and consist of only distinct elements. When sample consist of full elements it take about 120 sec., but when consist of only distinct elements it take about 4.5 or 5 times more sec. I expected that opposite of this result, because unique(sample) has less elements than full sample. Code as
2009 Mar 02
2
R-code help for filtering with for loop
Dear Sir / Madam, I am new for R coding. Kindly help me out in sorting out the following problem. There are 50 rows with six coloumns(you could see in the attached .txt file). I wish to go for filtering this 50 rows for any one of the six coloumns satisfying the value >= 64. I need to have a final table with rows having >= 64 value in any one of the six coloumns and the rest could be
2007 Mar 20
1
Symbol and Ellipsis problems
Hi Everyone, When I have a load of functions which have various arguments passed via the ellipsis argument it keeps on assigning them as symbol making them unusable to the function. My current work around involves using do.call but this is rather cumbersome. Does anyone know why it suddenly changes the types to symbol and if there is a way to get the actual data pointed to by the symbol? (I
2010 Jun 24
4
Simple qqplot question
I am a beginner in R, so please don't step on me if this is too simple. I have two data sets datax and datay for which I created a qqplot qqplot(datax,datay) but now I want a line that indicates the perfect match so that I can see how much the plot diverts from the ideal. This ideal however is not normal, so I think qqnorm and qqline cannot be applied. Perhaps you can help? Ralf
2020 Jun 26
4
Quedarse con las muestras de una BD que están presentes otra, basado en dos variables
Buenas tardes, quedarme con las muestras de una BD (data) que están presentes en otra (datax), cuando se tiene una variable que nunca se repite (Key) es fácil: data <- subset(data,data$Key %in% datax$Key). Mi problema es cuando la exclusividad viene dada por dos variables. P.e., las coordenadas de un mapa: lon y lat. ¿Como puedo quedarme con las muestras de una df cuya lon y lat son iguales a
2000 Oct 12
2
works in R-1.1.1 but not in R-development; why?
Dear All, A library (PHYLOGR) that passed the usual tests in R-1.1.1 gives errors with R-devel; my (mis?)understanding of scoping rules is that it should have worked in both. The problems seem related to using the name of the data frame for extracting weights or subsets within a function call. The problems can be reproduced as follows: ********************** datai <- data.frame( y =
2009 Jan 19
3
download/retain text file structure with RCurl/getURL()
Dear list, I'm trying to download a text file directly from the internet using the RCurl package and the command getURL. Duncan Lang graciously helped me solve the first step in this problem using the following command: ################# txtfile <- getURL('ftp://ftp.wcc.nrcs.usda.gov/data/snow/snow_course/table/history/idaho/13e19.txt', ftp.use.epsv = FALSE) #################
2017 Sep 26
2
Cleaning data
Hi I want to clean my data frame, based on the age column, whereas i want to delete the rows that the difference between its elements (i+1)-i= integer. i used a <- diff(df$age) for(i in a){if(is.integer(a) == true){df <- df[-a,] }} but, it doesn?t work, any ideas Thanks in advance Bayan
2008 Aug 04
3
backslash in character string?
Dear list, After searching many old posts, I can't find the solution to a simple problem. can someone tell me how to create a character string with multiple backslashes, as in: file_dir <- c("C:\files\data\") I need to create this string and then paste it to many files names for batch processing in another software program. R won't accept the backslash and removes
2010 Aug 06
2
All keys dead, but ØÆÅ£¤§
Hi, I'm trying to run an accounting program called Mamut DaTax. Running the installation part is not a problem, but when entering the program itself all keys are dead but the following: ?????? I'm using a Norwegian keyboard, and wine version 1.3 under Kubuntu 10.04. Any suggestions for how to approach? Thanks :-) Best regards, Erik
2009 Apr 14
2
subset dataframe by rows using character vector?
Dear List, I'm stuck on what seems like a simple indexing problem, I'd be very grateful to anyone willing to help me out. I queried a dataframe which returns a character vector called "plot". I have another dataframe from which I want to subset or select only those rows that match "plot". I've tried subset, and also the "which" command. plot
2008 Feb 29
2
while loop syntax help
Dear list, I'm trying to write my first looping function in R. After many hours of searching help files and previous posts, I'm at wits end. Please forgive my programming ignorance...any help is greatly appreciated. I need to sort through a vector (x) and identify the point at which 2 successive values become smaller than the previous value. I've written a "while"
2008 Apr 23
1
64 bit Linux/Ubuntu memory limit problem?
Dear list, I've recently installed R on a 64 bit machine with 8 GB of RAM. I set this computer up as a dual-boot system, with windows XP 64 and Ubuntu 7.10. I downloaded the Linux 64 bit version of R and installed it. I'm trying to run rather large Random forest models and was running into severe memory limitations with my old windows 32 bit machines. When I run Random Forest models
2003 Oct 15
0
qqnorm(*, datax=TRUE, xlab,ylab) -- S+ compatibility problem
Just found because an old (written for S+) function of mine did label plots wrongly with R. Example --- inspired from example(qqnorm) --- data(precip) qqnorm(precip, ylab = "Precipitation [in/yr] ...") qqnorm(precip, ylab = "Precipitation [in/yr] ...", datax = TRUE) this is all "fine" -- `datax' is a switch that just switches the axes but keeps the
2008 Oct 01
1
regexpr syntax question
Greetings R list, I am stuck on a simple syntax problem. I want to list all files in a directory, excluding files of a certain type. I have tried pattern matching as follows: a <- list.files(data, full.name = TRUE, pattern != ".xml") # exclude all .xml files The warning returns that my syntax is incorrect. I have read the regexpr help files and search old posts to no
2006 Jul 31
4
question about dataframe ("sensory") in PLS package
Dear all, I am trying to my dataframe for the PLS analysis using the PLS package. However I have some trouble generating the correct dataframe. The main problem is how to use one name to represent several columns in the dataframe. The example dataframe in PLS package is called "sensory". I cannot directly read the data file since it's a binary file. If I use
2012 May 29
1
model frame and formula mismatch with latent class analysis poLCA
Dear R-users, I keep getting an ERROR saying " Error in model.matrix.default(formula, mframe) : model frame and formula mismatch in model.matrix() " when i fit poLCA with more than 63 variables. Below are the details. I am trying to do a Latent Class Analysis using poLCA. My data set contains binary scores of, for instance, 200 students on 100 items. These numbers could even be more
2005 Jul 02
1
probability-probability plot
Hi, there. Is there any function in R to plot the probability-probability plot (PP plot)? Suppose I am testing some data against normal. Thanks. Yulei $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ Yulei He 1586 Murfin Ave. Apt 37 Ann Arbor, MI 48105-3135 yuleih at umich.edu 734-647-0305(H) 734-763-0421(O) 734-763-0427(O) 734-764-8263(fax) $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
2006 Feb 01
1
Difficulty with qqline in logarithmic context
Hi, R friends. I had some difficulty with the following code: qqnorm(freq, log='y') qqline(freq) as the line drawn was seemingly random. The exact data I used appears below. After wandering a bit within the source code for "abline", I figured out I should rather write: qqnorm(freq, log='y') par(ylog=FALSE) qqline(log10(freq)) par(ylog=TRUE)