I am using the following code semPlot::semPaths to plot a lavaan model:
semPaths(object = fit,
what = "stand",
nCharNodes = 0,
layout = "tree",
fade = FALSE,
exoCov = FALSE,
residuals = FALSE,
intercepts = FALSE,
rotation = 2,
sizeMan = 5,
sizeLat = 10,
edge.label.cex = 1.5,
minimum=0.16,
allVars = FALSE,
equalizeManifests = FALSE,
fixedStyle = 2)
And this is the figure from the semPaths output:
I want to remove all the red paths on the y-indicators (i.e., red lines on the right-hand side of the model). What argument can I add to remove them? Thanks.
I have tried adding various arguments to the semPaths() code based on R documentation and previous stackoverflow queries. These additional arguments are removing different paths and numbers, except for the paths I want to remove. Most arguments are included in the current code.
Related
Every time I try to look up how to use a function in R using the ? command, what I get is some semi-useful explanations, commands I don't understand, and some limited examples.
What I end up doing most of the time instead of using this function is googling the answers instead, which sometimes helps for nuanced questions, but just trying to understand a single package becomes a chore unless it happens to come up in a basics book I'm reading on R.
I tried looking up how to "read" the help section, but the best I could find was this Dummies page which didn't really help much more:
Dummies Page on Help in R.
The main issue I'm having is that I just dont understand the syntax portion. Here is an example:
semPaths(object, what = "paths", whatLabels, style, layout = "tree",
intercepts = TRUE, residuals = TRUE, thresholds = TRUE, intStyle = "multi",
rotation = 1, curve, curvature = 1, nCharNodes = 3, nCharEdges = 3, sizeMan = 5,
sizeLat = 8, sizeInt = 2, sizeMan2, sizeLat2, sizeInt2, shapeMan, shapeLat,
shapeInt = "triangle", ask, mar, title, title.color = "black", title.adj = 0.1,
title.line = -1, title.cex = 0.8, include, combineGroups = FALSE, manifests,
latents, groups, color, residScale, gui = FALSE, allVars = FALSE, edge.color,
reorder = TRUE, structural = FALSE, ThreshAtSide = FALSE, thresholdColor,
thresholdSize = 0.5, fixedStyle = 2, freeStyle = 1,
as.expression = character(0), optimizeLatRes = FALSE, inheritColor = TRUE,
levels, nodeLabels, edgeLabels, pastel = FALSE, rainbowStart = 0, intAtSide,
springLevels = FALSE, nDigits = 2, exoVar, exoCov = TRUE, centerLevels = TRUE,
panelGroups = FALSE, layoutSplit = FALSE, measurementLayout = "tree", subScale,
subScale2, subRes = 4, subLinks, modelOpts = list(mplusStd = "std"),
curveAdjacent = '<->', edge.label.cex = 0.6, cardinal = "none",
equalizeManifests = FALSE, covAtResiduals = TRUE, bifactor, optimPoints = 1:8 * (pi/4),
...)
What does any of this mean? All I can tell are that the stuff in "" is a possible use of a function, and thats about it. How do I explore more? For example, if I wanna find out all the potential styles for "layout" in this function, how do I look them up?
Hi to understand the information in the help you can follow the following steps,
Thee help is structured with some sections , Usage, Value, Details, References, Examples.
Usage: you have the syntax of the function and their arguments, the mandatory arguments are the ones with no values, ie in semPaths(object,...) object is a mandatory argument.
Arguments: You have the arguments that the function can take and their respective default values.
Examples: perhaps the most important section, where you have some possible usage of the function
References: other sources you may need to read to understand the logic or how the computations are being done.
You may also need to check the package documentation, there you may find more details, you can find this just by googling "package name" .pdf
I am running the parallel analysis with fa.parallel which works but the problem is that it provides or suggests a number of factors lower (3) than what I would expect (5):
fa.parallel(test3[, c(7:28)], fm="ml",sim=TRUE,n.iter = 100)
The answer I get in the R console:
Parallel analysis suggests that the number of factors = 3 and the number of components = 3
And a graph.
But how can I further see eigenvalues?
Secondly, as I tried another way to run the parallel analysis using paran package, it does not compute the parallel analysis instead gives me the error message:
Error in svd(X) : infinite or missing values in 'x'.
I have tried to search for this error message which I did not find in context of parallel analysis but in PCA and it has to do with missing values which I acknowledge I have in my dataset. What should I do? the code used for paran is:
paran(test2[, c(7:28)], iterations = 5000, centile = 0, quietly = FALSE,
status = TRUE, all = TRUE, cfa = TRUE, graph = TRUE, color = TRUE,
col = c("black", "red", "blue"), lty = c(1, 2, 3), lwd = 1, legend = TRUE,
file = "", width = 640, height = 640, grdevice = "png", seed = 0)
I'm having trouble changing the color of the bibliometric map using R. I intend to change the color to black and white. But I don't know the syntax used for that.
The code structure I use to generate the map looks like this:
conceptualStructure(M, field = "ID", method = "MCA", quali.supp = NULL, quanti.supp = NULL, minDegree = 2, clust = "auto", k.max = 5, stemming = FALSE, labelsize = 10, documents = 2, graph = TRUE)
Please help me, what code can I use to change the color of the map, background and text in my project.
I have never used conceptualStructure before, nor know what package it comes from (assuming it isn't base R), but I think you should be able to make it black and white by just specifying as such in the theme. E.g.
conceptualStructure(M,
field = "ID",
method = "MCA",
quali.supp = NULL,
quanti.supp = NULL,
minDegree = 2,
clust = "auto",
k.max = 5,
stemming = FALSE,
labelsize = 10,
documents = 2,
graph = TRUE) + theme_bw()
That may just be a ggplot2 thing though. In which case, i'm not sure I can help
I am using the following code semPlot::semPaths to plot a lavaan model (the complete reproducible code is in this Gist).
semPaths(f,
title = FALSE,
curvePivot = TRUE,
what = "std",
rotation = 2,
layout = "tree2",
optimizeLatRes = TRUE,
intercepts = FALSE,
edge.label.cex = 0.95,
exoVar=FALSE,
sizeMan=5,
sizeLat=7,
nCharNodes=5,
residuals=FALSE,
fixedStyle=1,
freeStyle=1,
curvePivot = FALSE)
And the following is the semPaths output:
As you can see, there are weired horizonla lines in the last four manifest variables. How can I remove them? (and why it's happening?)
Thanks in advance!
Update:
This is also the case if saved to PDF (by adding arguments filetype = "pdf", filename = "x") to the function:
Is it possible to highlight single words within a word cloud using 'wordcloud' or 'wordcloud2'? Does one have to add another column to the data frame as ordering factor?
I couldn't find any simple solution.
Here's what I've done:
wordcloud(text_process$words[1:n.words],
text_process$frequency[1:n.words],
scale = c(18, 0.5),
colors = c("#666666", "#3E6AA0") [factor(text_process$matches[1:n.words])],
use.r.layout = FALSE,
rot.per = 0.2,
random.order = FALSE, ordered.colors=TRUE)
I had to introduce a criterion (called 'matches') in the data frame 'text_process' that indicates the color. I was wondering whether there's a simpler way of highlighting specific words...
# Not Tested
library(randomcoloR)
cols<-randomColor(length(unique(test_process$words[1:n.words])), luminosity = "dark")
match_value<-match("HighlightThisWord", test_process$words[1:n.words])
cols[match_value]<-"orange"
wordcloud(text_process$words[1:n.words],
text_process$frequency[1:n.words],
scale = c(18, 0.5),
colors = cols,
use.r.layout = FALSE,
rot.per = 0.2,
random.order = FALSE, ordered.colors=TRUE)