similar to: Using a loop to define new variables

Displaying 20 results from an estimated 90 matches similar to: "Using a loop to define new variables"

2010 Oct 06
3
Adding a time variable prior to using reshape
Hi, I want to use reshape to convert from a skinny to a wide data format. My data doesn't have a time variable attached - I have a series of ordered observations for each subject, and it is this ordering that I am interested in (my objective is to model the most recent observation based on the preceding observations). From my understanding, prior to using reshape I have to attach a time
2011 Nov 04
2
Select some, but not all, variables stepwise
Hi, I would like to fit a linear model where some but not all explanators are chosen stepwise - ie I definitely want to include some terms, but others only if they are deemed significant (by AIC or whatever other approach is available). For example if I wanted to definitely include x1 and x2, but only include z1 and z2 if they are significant, something like this: df <-
2011 Oct 24
4
Lm function: Error in model.frame.default
Hello, I am trying to get a linear model of y ~ log(x). *> lm (y~log(x))* However, I always get an error report: /Error in model.frame.default(formula = y ~ log(x), drop.unused.levels = TRUE) : variable lengths differ (found for 'log(x)')/ *Here was my y:* > y [1] 0.4500000 0.0500000 0.5000000 0.4000000 0.0000000 0.5000000 0.4000000 [8] 0.0500000
2008 Aug 27
1
ifelse() fill order and recycling rules [Sec=Unclassified]
Hi all, Using R v2.7.1, platform i386-pc-mingw32 Can someone please shed some light on the behaviour of ifelse() for me? My intent is to calc relative proportions of z$b, at the same time subsetting z$b based on z$a. I could attack the problem other ways (suggestions welcome) but I am also intrigued by the _order_ in which ifelse seems to assign values, and how recycling works. For instance,
2009 Jun 10
1
R: Best way to plot a Matrix of all possible pair combinations
Hallo R Users, Please help I have some distance matrix data like > M[1:10,] [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.8750000 0.5000000 0.5000000 0.3750000 0.6250000 0.00000000 [2,] 0.8928571 1.0000000 0.0000000 0.8928571 0.1071429 0.00000000 [3,] 0.8928571 1.0000000 0.0000000 0.8928571 0.1071429 0.00000000 [4,] 0.8928571 1.0000000 0.0000000 0.8928571
2007 May 05
1
(no subject)
Dear Mailing-List, I think this is a newbie question. However, i would like to integrate a loop in the function below. So that the script calculates for each variable within the dataframe df1 the connecting data in df2. Actually it takes only the first row. I hope that's clear. My goal is to apply the function for each data in df1. Many thanks in advance. An example is as follows: df1
2011 Oct 05
1
Dealing with proportions
Dear list, I have very little experience in dealing with proportions, i am sure this is a very simple question but i could find no suitable answer beyond doing a chi-sq test and then using the Marascuilo procedure as a post-hoc analysis. I am simply wanting to know if the proportions ( i.e the number of Yes / No) significantly differ between the cases and if so which cases are significantly
2002 Mar 13
0
rpart error with 0-frequency factor levels (with partial fix) (PR#1378)
(I'm sending to r-bugs because rpart is one of the recommended packages and is always installed. I'm also sending it directly to Dr. Ripley, as the maintainer.) rpart working as a classifier does not work (produces no splits) when the class indicator has no instances of one of the factor levels, as long as the factor level is not the final level. I have at least a partial fix, which I
2007 Oct 17
1
How to save association rules generated by arules package
Hi, I have been able to generate association rules for Market Basket Analysis using the following codes: **************************************************************************** ******************************************* library("arules") rules <- read.csv("write1.csv",na.strings=c(".", "NA", "", "?"),header=TRUE)
2009 Jul 26
3
Question about rpart decision trees (being used to predict customer churn)
Hi, I am using rpart decision trees to analyze customer churn. I am finding that the decision trees created are not effective because they are not able to recognize factors that influence churn. I have created an example situation below. What do I need to do to for rpart to build a tree with the variable experience? My guess is that this would happen if rpart used the loss matrix while creating
2009 Jun 07
2
Need some help in R : value more than equals to a row.
Hallo, I was trying some code, but couldn't make one step of the code properly. Can anybody please help me? I have one matrix like this > values [,1] [,2] [,3] [,4] [,5] [1,] 0.7777778 0.36111111 0.22222222 0.1388889 0.0000000 [2,] 1.0000000 0.00000000 0.53846154 0.0000000 0.5384615 [3,] 0.5200000 0.48000000 0.64000000 0.0000000 0.8800000 [4,] 0.8928571
2009 Jul 26
2
problems hist() and density
Hello, I have a problem with the hist() function and showing densities. The densities sum to 50 and not to 1! I use R version 2.9.1 (2009-06-26) and I load the seqinR library. My data is the following vector: [1] 0.1400000 0.2000000 0.2200000 0.2828283 0.1600000 0.1600000 0.3600000 [8] 0.1600000 0.2200000 0.2600000 0.2000000 0.3000000 0.2200000 0.2342342 [15] 0.1800000 0.2200000 0.1600000
2006 Feb 08
1
adding variable into dataframe by indice
R-Helpers, I am trying to insert a value into a dataframe. This value is a proportion calculated by counting the number of those individuals with that value and then inserting the proportion at the end of the dataframe to only those individuals with the given value. The problem I am running into is that the proportions are not being attached to only those individuals with the specified value
2010 Feb 15
4
density estimates for fixed points
Problem: Based on a n x 2 data matrix i want a kernel estimate of the bivariate density. However, i also wish to specify wich points the density should be calculated at. I can offcourse just write the full kernel density estimate as a R-code, but surely there must already exist some package for this operation? The package density(), seems to create a new matrix (depending on n), where the
2002 Sep 27
1
Subsetting Matrix
Hi, This is an easy question, however I cannot remember the exact command of doing it :-( Say I have a matrix: > ff [,1] [,2] [1,] 0.1000000 116.76987 [2,] 0.6444444 108.26811 [3,] 1.1888889 95.00240 [4,] 1.7333333 112.13647 [5,] 2.2777778 107.39893 [6,] 2.8222222 115.34615 [7,] 3.3666667 97.81029 [8,] 3.9111111 105.35119 [9,] 4.4555556
2006 Apr 17
0
Problem getting R's decision tree for Quinlan's golf exam ple data [Broadcast]
See ?rpart.control. I get: > golf.rp = rpart(Outlook ~ ., golf, control=rpart.control(minsplit=1)) > golf.rp n= 14 node), split, n, loss, yval, (yprob) * denotes terminal node 1) root 14 9 rain (0.2857143 0.3571429 0.3571429) 2) Temperature< 71.5 6 2 rain (0.1666667 0.6666667 0.1666667) 4) Temperature< 64.5 1 0 overcast (1.0000000 0.0000000 0.0000000) * 5)
2007 Mar 28
2
Standardization Range
? stato filtrato un testo allegato il cui set di caratteri non era indicato... Nome: non disponibile Url: https://stat.ethz.ch/pipermail/r-help/attachments/20070328/ee4422a2/attachment.pl
2016 Apr 24
3
Dividing rows in groups
Hi I have two data frames as shown below (second one is obtained by aggregating rows of similar IDs in df1.). They both have similar number of columns but rows of df2 are lesser than rows of df1. df1: ID A B 1 1 2 1 0 3 2 5 NA 2 1 3 3 1 4 4 NA NA 4
2004 Mar 18
1
profile error on an nls object
Hello all, This is the error message that I get. > hyp.res <- nls(log(y)~log(pdf.hyperb(theta,X)), data=dataModel, + start=list(theta=thetaE0), + trace=TRUE) 45.54325 : 0.1000000 1.3862944 -4.5577142 0.0005503 3.728302 : 0.0583857346 0.4757772859 -4.9156128701 0.0005563154 1.584317 : 0.0194149477 0.3444648833 -4.9365149150 0.0004105426 1.569333 :
2010 May 06
5
frequency
Dear list, Im trying to do the following operation but im not able to do it This is my table: 1 2 3 1 0 7 4 2 0 2 0 3 0 1 3 4 0 3 4 what i would like to do is divide each row values with the corresponding column' sum,namely: 1 2 3 1 0 0.54 0.36 2 0 0.15 0 3 0 0.08