Hi
How about ...
# Data
lines = "Col1 Col2 Col3 Col4
Text1 Text2 X0.1 5
Text1 Text2 X0.2 10
Text1 Text2 X0.3 15
Text1 Text3 X0.1 5
Text1 Text3 X0.2 10
Text1 Text3 X0.3 15"
# Create Dataframe
DF <- read.table(textConnection(lines), header = TRUE, check.names = FALSE)
# Create Numeric Variable
I have a data frame called z that includes four columns:
Col1 Col2 Col3 Col4
Text1 Text2 X0.1 5
Text1 Text2 X0.2 10
Text1 Text2 X0.3 15
Text1 Text3 X0.1 5
Text1 Text3 X0.2 10
Text1 Text3 X0.3 15
I am trying to convert the 3rd column to the numeric value excluding the X so
that I can produce a la
Try
z$Col3 = as.numeric(sub('^X','',as.character(z$Col3)))
- Phil Spector
Statistical Computing Facility
Department of Statistics
U
I have a data frame called z that includes four columns:
Col1 Col2 Col3 Col4
Text1 Text2 X0.1 5
Text1 Text2 X0.2 10
Text1 Text2 X0.3 15
Text1 Text3 X0.1 5
Text1 Text3 X0.2 10
Text1 Text3 X0.3 15
I am trying to convert the 3rd column to the numeric value excluding the X so
that I can produce a la
4 matches
Mail list logo