similar to: how to generate a column based on other columns in a data frame

Displaying 20 results from an estimated 400 matches similar to: "how to generate a column based on other columns in a data frame"

2008 Feb 12
2
how to specify modes of certain fields in read.table
I have a data file with 50 columns. Among them, there are two coordinates, X and Y X Y 641673.78807 3607080.78438 641436.56207 3607108.30543 641165.28042 3607136.82957 640879.58373 3607116.20568 When I use read.table, it rounds X and Y to the maximal 8 decimal number as. 641673.8 3607081 641436.6 3607108 641165.3 3607137 640879.6 3607116 640683.5 3607105 My question
2008 Feb 08
4
how to extract characters from a character string
Hi, I ran into a problem when I complied a dataset with UTM coordinates. For calculating distances between sites, I need to reformat the coordinates from, for example, 32?35.421 N, to 35.421, i.e. I need to delete all digits before symbol ? and a space and N at the end of the string. What functions I should use? Thanks in advance. Weidong Gu, Department of Medicine University of
2008 Sep 07
1
run optim() on a list
Hi, I am at the end of my wit to figure out how to run the optim function on a list. Basically, I have a data set of three columns as "Site", "Pool" and "Positivity" ( the full data set is copied at the end). I want to run the maximal likelihood estimation separately on subsets split by "Site" data<-read.table(...)
2008 Jan 31
1
decrease amount of ticks on y axis in lattice levelplot
Hi all, How can I decrease the number of ticks on the y-axis in a lattice levelplot()? I have as many ticks displayed on the y-axis as I have columns of data (1000 columns), how can I decrease this amount of ticks, while still properly displaying all the data? Note that I get my data from a matrix object, in which the z-values of the levelplot are the actual values in the matrix, whereas the
2011 Apr 08
3
a strange behavior with ifelse
I have used R for years but run into a seemingly simple problem involving 'ifelse'. condensed code like this a=c(2,NA,NA,NA,2,2,NA,2,NA,2) b=c(NA,1,1,NA,2,2,2,2,2,2) #I want to combined a and b into c so that c would be a valid number either a or b is not missing c=ifelse(a==1|b==1,1,ifelse(a==2|b==2,2,NA)) cbind(a,b,c) a b c [1,] 2 NA NA [2,] NA 1 1 [3,] NA 1 1
2008 Mar 27
1
panel function question
I have two data sets with locations, X, Y of houses (df.house) and habitats(df.habitat), respectively. In each dataset, there are 3 replicates (Repeat). Because each replicate has different locations of houses and habitats, I would like to plot them in panels. I wrote something like this: mypanel<-function(x,y,subscripts,...){ panel.xyplot(x,y,pch=20) panel.xyplot(
2008 Jan 07
1
How to rearrange lattice graphics output?
My question arises when I use levelplot graphics. For example, levelplot(z~x*y|fg) where fg is a factor with three levels of 'a','b','c'. The panels come out in a default order. I would like to rearrange the panels in a manner of 'c','b','a'. I used fg<-ordered(fg, levels=c('c','b','a')) But the panels are still the
2009 Feb 25
2
run latent class analysis with R
What's the best approach to running latent class analysis with R? I've downloaded both randomLCA and poLCA packages, but I am interesting in running a standard LCA with individual records (not frequency table) as input data. Wen Gu John Jay College of Criminal Justice445 West 59 StreetNew York, NY 10029 wgu@gc.cuny.edu _________________________________________________________________
2008 Sep 24
2
Graph question
If I have a set of data comprising a list of numbers of eggs on mosquito guts that range from 1 to 157. How can I get R to draw a barchart of the distribution of the data (i.e. x axis= number of eggs on a gut, y axis=number of mosquitoes found with that number of eggs)? Data is listed below. Thanks, Georgina Number of eggs on each mosquito gut: [1] 1 1 1 1 4 2 1 12 12 1 2
2008 May 06
1
substring
I have a data frame such as Name DISC1_5916 DABC2_789 ABCD_1234 I want to substring column Name so that DISC1 DABC2 ABCD ... Thanks. --------------------------------- [[elided Yahoo spam]] [[alternative HTML version deleted]]
2010 Dec 14
1
rpart - how to estimate the “meaningful” predictors for an outcome (in classification trees)
Hi dear R-help memebers, When building a CART model (specifically classification tree) using rpart, it is sometimes obvious that there are variables (X's) that are meaningful for predicting some of the outcome (y) variables - while other predictors are relevant for other outcome variables (y's only). *How can it be estimated, which explanatory variable is "used" for which of
2013 Feb 23
5
Selecting First Incidence from Longitudinal Data
I have a longitudinal competing risk data of the form: ID COMPL SEX HEREDITY 1 0 1 2 1 0 1 2 1 3 1 2 2 0 0 1 2 1 0 1 2 2 0 1 2 2 0 1 3 0 0 1 3 0 0 1 3 0 0 1 3 0 0 1 3 2 0 1 4 0 1 2 4 0 1
2009 Feb 23
1
why results from regression tree (rpart) are totally inconsistent with ordinary regression
Hi, In my analysis of impacts of insecticide-treated bednets on malaria, I look at the relationship between malaria incidence and mosquito behaviors. The condensed data set is copied here. Ordinary regression (lm) shows that Incidence was negatively related to Mortality. This makes sense because the latter reflected the strength of killing mosquitoes by insecticide-treated nets. Since the
2013 Feb 08
2
Can not melt data.frame
I realize it's -12C and we're having the next best thing to a blizzard but why can I not melt this data frame. I am missing something terribly obvious but I just don't understand what the error message is saying. John Kane Kingston ON Canada Code and aata below #================================================# library(reshape2) melt(mydata, id.vars = c("date"))
2013 Mar 19
1
Error when adding lines to a plot using the mixed-effect model and metafor package
Hi, I am a student using R for my final year project, with the metafor package being particularly helpful. I have been following the steps laid out in the manual 'Conducting Meta-analysis in R with the Metafor package' (Viechtbauer, 2010) and applying it to my own data of infected Anopheles mosquitoes across Africa. In particular, I am attempting to apply a mixed-effect model to my data
2010 Jan 15
1
cbind or ?
Hey Guys, It sure seems I get stuck on things that should be easy. Heres my question: PARCELS<-by(ResImp[ , "ACCOUNTNO"], ResImp["Property"], length) > PARCELS Property: UNSOLD [1] 9053 ------------------------------------------------------------------------------------------- Property: SOLD [1] 578
2006 Sep 14
5
Shorewall make my firewall fly!
I''ve just put in production a Linux firewall with 4 ethernet interfaces and 3 openvpn tun virtual interfaces. With Shorewall everything work like a charm (only a little hassle with some details, due to bad configuration, not bugs!) Great tool! Tom and other Shorewall developers, you all are great! Bye (and sorry for my bad english) -- Paolo Basenghi - Centro elaborazione dati
2008 Aug 27
3
Closest value
Hello, I have this command: x.axis <- seq(from=0.5, to=4.5, length.out=13112) How can I which of the x.axis components is the closest to a given value, for example 3.2? Best, Dani -- Daniel Valverde Saub? Grup de Biologia Molecular de Llevats Facultat de Veterin?ria de la Universitat Aut?noma de Barcelona Edifici V, Campus UAB 08193 Cerdanyola del Vall?s- SPAIN Centro de Investigaci?n
2010 Nov 11
1
NFS Mounted GlusterFS, secondary groups not working
Howdy, I have a GlusterFS 3.1 volume being mounted on a client using NFS. From the client I created a directory under the mount point and set the permissions to root:groupa 750 My user account is a member of groupa on the client, yet I am unable to list the contents of the directory: $ ls -l /gfs/dir1 ls: /gfs/dir1/: Permission denied $ ls -ld /gfs/dir1 rwxr-x--- 9 root groupa 73728 Nov 9
2008 Aug 28
2
Read a file
Hello, I have a text file with this structure: # File created = Thursday, August 28, 2008 3:33:02 PM GMT # Data set = 373 2 1 C:\Bruker\TOPSPIN GABRMN # Spectral Region: # LEFT = 4.5 ppm. RIGHT = 0.5 ppm. # # SIZE = 13111 ( = number of points) # # In the following ordering is from the 'left' to the 'right' limits! # Lines beginning with '#' must be considered as