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
Related
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.
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)
I am trying to follow help and Internet examples to create a very simple animation of a 3d-line in R. This is just a test and my final goal is to use this functionality to visually verify results of some geometrical transformations on 3d-movement data that I am analysing. So basically I need nothing more than a ‘3d-player’ interface that allows for usual interaction (rotation, zoom, play, stop, slide).
I figured out that rgl package does the job and I am able to use it for the sphere/points animation. But now I need to use it on lines and I get very strange results. In the example below there are 4 points and two lines (cyan and red) that connect the same points but the red line is for some reason in the ‘wrong’ place. The animation doesn’t make sense neither. Now, I am thinking may be it is impossible to do >> to animate more than one vertex with more than one attribute? But I don’t see this in documentation and obviously it is possible because line is animated! I spent quite a long time trying to figure out what is going on and will appreciate any help/advise/directions. many thanks
Ps: Tthe code below is a chunk in the markdown file and I am using Rstudio.
require(rgl)
require(rglwidget)
p11=c(0,0,0)
p21=c(50,50,0)
p12=c(50,0,0)
p22=c(10,50,50)
saveopts <- options(rgl.useNULL = TRUE)
did=list()
did[[1]]=plot3d(rbind(p11,p21,p12,p22), type="s", alpha = 1, lwd = 5, col = c('brown','darkgreen','orange','green'))
did[[2]]=spheres3d(c(100,100,100), alpha = 1, lwd = 5, col = "blue",radius=2)
did[[3]]=lines3d(rbind(p11,p21),lwd=8, col='cyan',alpha=.9)
did[[4]]=planes3d(0, 0, 1, 0, alpha=.4, col='green')
did[[5]]=lines3d(rbind(p11,p21),lwd=2, col='red')
aspect3d(1, 1, 1)
did[[6]]=grid3d(c("x-", "z-"),at = NULL,col = "gray",lwd = .5,lty = 1,n = 5)
sceneT = rglwidget(elementId = "plot3dT",width=500, height=300) #%>%
rgl.ids()
rgl.attrib(id=did[[3]],attrib = c(1:length(did[[3]])))
playwidget(sceneT,list(
vertexControl(values = rbind(c(0,0,0,0,0,0),c(50,50,50,50,50,50)),
vertices = 1:6, attributes = "z", objid = did[[4]], param = 1:2,interp =T),
vertexControl(values = r1,
vertices = 1:2, attributes = c('x',"y","z",'x',"y","z"), objid = did[[5]], param = 1:2,interp =T)),
start = 1, stop = 2, step = .1, precision = 3)
options(saveopts)