Closed Rgui closed 9 years ago
liv(y~P)
does work, however not with all data types.
The usage is the same as for lm()
.
Only variables whose type is raw, logical, integer, real, complex or character can be included directly in the formula. This does exclude types such as list or data.frame, but include vectors, arrays and matrices.
If more complex types such as lists or data.frame should be used, they have to be in the data
parameter or converted to a vector or matrix before used in the formula.
Example usage cases by data type: Vector
v1 <- c(1,2,3)
v2 <- c(4,5,6)
liv(v1~v2)
List
l1<-list(1,2,3)
l2<-list(4,5,6)
liv(unlist(l1)~unlist(l2))
liv(a~b, data=list(a=unlist(l1), b=unlist(l2)))
data.frame
df1<- data.frame(a=c(1,2,3))
df2<- data.frame(b=c(4,5,6))
liv(df1$a~df2$b)
liv(df1[,1]~df2[,1])
liv(as.matrix(df1)~as.matrix(df2))
liv(a~b, data=data.frame(df1, df2))
Example Data
input <- read.csv("PATH/Data_LIV.csv", sep=" ")
liv(input$y~input$P)
liv(y~P, data=input)
y <- input$y
P <- input$P
liv(y~P)
As said before, the usage is the same as for the standard lm()
function. This probably should have been better documented.
Call of the liv function of the type: liv(y~p) should work as well (meaning without param and data). When param = NULL, default values are given, as programmed already in liv.R At the moment the call liv(y~P) gives the following error:
Error in model.frame.default(formula = y ~ P, drop.unused.levels = TRUE) : invalid type (list) for variable 'y'.
Patrick, could you please have a look at this. Thank you